ASTNode clone0(AST target) { TypeParameter result = new TypeParameter(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) ((ASTNode) getName()).clone(target)); result.typeBounds().addAll( ASTNode.copySubtrees(target, typeBounds())); return result; }
public boolean visit(TypeParameter node) { if (found(node, node.getName()) && this.resolveBinding) this.foundBinding = node.resolveBinding(); return true; }
public void visitTypeParameters(@SuppressWarnings("rawtypes") List parameters) { fBuffer.append('<'); for (Object p : parameters) ((TypeParameter) p).accept(this); fBuffer.append('>'); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS_PROPERTY) { return modifiers(); } if (property == TYPE_BOUNDS_PROPERTY) { return typeBounds(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
public boolean visit(TypeParameter node) { if (node.getAST().apiLevel() >= AST.JLS8) { printModifiers(node.modifiers()); } node.getName().accept(this); if (!node.typeBounds().isEmpty()) { this.buffer.append(" extends ");//$NON-NLS-1$ for (Iterator it = node.typeBounds().iterator(); it.hasNext(); ) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(" & ");//$NON-NLS-1$ } } } return false; }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == NAME_PROPERTY) { if (get) { return getName(); } else { setName((SimpleName) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
@Override public void endVisit(TypeParameter node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getName()); process(info, node.typeBounds()); }
public TypeParameter convert(org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter) { final TypeParameter typeParameter2 = new TypeParameter(this.ast); final SimpleName simpleName = new SimpleName(this.ast); simpleName.internalSetIdentifier(new String(typeParameter.name)); int end = typeParameter.sourceEnd; simpleName.setSourceRange(start, end - start + 1); typeParameter2.setName(simpleName); final TypeReference superType = typeParameter.type; end = typeParameter.declarationSourceEnd; if (superType != null) { Type type = convertType(superType); typeParameter2.typeBounds().add(type); end = type.getStartPosition() + type.getLength() - 1; for (int index = 0, length = bounds.length; index < length; index++) { type = convertType(bounds[index]); typeParameter2.typeBounds().add(type); end = type.getStartPosition() + type.getLength() - 1; typeParameter2.setSourceRange(start, end - start + 1); if (this.resolveBindings) { recordName(simpleName, typeParameter); recordNodes(typeParameter2, typeParameter); typeParameter2.resolveBinding();
@Override public boolean visit(TypeParameter node) { printModifiers(node.modifiers()); node.getName().accept(this); if (!node.typeBounds().isEmpty()) { this.fBuffer.append(" extends ");//$NON-NLS-1$ for (Iterator<Type> it= node.typeBounds().iterator(); it.hasNext();) { Type t= it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(" & ");//$NON-NLS-1$ } } } return false; }
@Override public TypeVariableSource<O> removeBounds() { internal.typeBounds().clear(); return this; }
public boolean visit(TypeParameter node) { if (hasFlag(TYPES, fFlags) && node.getStartPosition() < fPosition) { fBreak= fRequestor.acceptBinding(node.getName().resolveBinding()); } return !fBreak; }
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew, ImportRewriteContext context) { ITypeBinding[] typeParameters= fTargetMethodBinding.getTypeParameters(); for (int i= 0; i < typeParameters.length; i++) { ITypeBinding current= typeParameters[i]; TypeParameter parameter= rew.getAST().newTypeParameter(); parameter.setName(rew.getAST().newSimpleName(current.getName())); ITypeBinding[] bounds= current.getTypeBounds(); for (int j= 0; j < bounds.length; j++) if (!"java.lang.Object".equals(bounds[j].getQualifiedName())) //$NON-NLS-1$ parameter.typeBounds().add(rew.getImportRewrite().addImport(bounds[j], rew.getAST(), context)); intermediary.typeParameters().add(parameter); } }
@SuppressWarnings("unchecked") @Override public TypeVariableSource<O> setBounds(String... bounds) { internal.typeBounds().clear(); for (String s : bounds) { org.eclipse.jdt.core.dom.Type copy = (org.eclipse.jdt.core.dom.Type) ASTNode.copySubtree(internal.getAST(), parseTypeBound(s)); internal.typeBounds().add(copy); } return this; }
@Override public final boolean visit(TypeParameter parameter) { ITypeBinding binding= parameter.resolveBinding(); if (binding != null) { // don't collect type parameters declared inside the anonymous fBindings.put(binding.getKey(), binding); } return false; }
@Override public boolean visit(TypeParameter node) { if (!hasChildrenChanges(node)) { return doVisitUnchangedChildren(node); } int pos; if (node.getAST().apiLevel() >= JLS8_INTERNAL) { pos = rewriteModifiers2(node, TypeParameter.MODIFIERS_PROPERTY, node.getStartPosition()); } pos= rewriteRequiredNode(node, TypeParameter.NAME_PROPERTY); rewriteNodeList(node, TypeParameter.TYPE_BOUNDS_PROPERTY, pos, " extends ", " & "); //$NON-NLS-1$ //$NON-NLS-2$ return false; }
public static Set<String> getPreviousTypeParamNames(List<TypeParameter> typeParams, ASTNode missingNode) { Set<String> previousNames= new HashSet<>(); for (int i = 0; i < typeParams.size(); i++) { TypeParameter curr= typeParams.get(i); if (curr == missingNode) { return previousNames; } previousNames.add('<' + curr.getName().getIdentifier() + '>'); } return previousNames; }
td.setName(ast.newSimpleName("Foo")); TypeParameter tp = ast.newTypeParameter(); tp.setName(ast.newSimpleName("X")); td.typeParameters().add(tp); cu.types().add(td);
private void annotateTypeParameter(TypeParameter typeParameter, org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : case AST.JLS3_INTERNAL : case AST.JLS4_INTERNAL: typeParameter.setFlags(typeParameter.getFlags() | ASTNode.MALFORMED); break; default: int annotationsLength = annotations.length; for (int i = 0; i < annotationsLength; i++) { org.eclipse.jdt.internal.compiler.ast.Annotation typeAnnotation = annotations[i]; if (typeAnnotation != null) { Annotation annotation = convert(typeAnnotation); typeParameter.modifiers().add(annotation); } } } }