protected static void copyTypeParameters(final MethodDeclaration oldMethod, final MethodDeclaration newMethod) { final AST ast= newMethod.getAST(); for (int index= 0, n= oldMethod.typeParameters().size(); index < n; index++) newMethod.typeParameters().add(ASTNode.copySubtree(ast, (TypeParameter) oldMethod.typeParameters().get(index))); }
protected static void copyTypeParameters(final MethodDeclaration oldMethod, final MethodDeclaration newMethod) { final AST ast= newMethod.getAST(); for (int index= 0, n= oldMethod.typeParameters().size(); index < n; index++) newMethod.typeParameters().add(ASTNode.copySubtree(ast, (TypeParameter) oldMethod.typeParameters().get(index))); }
protected static void copyTypeParameters(final MethodDeclaration oldMethod, final MethodDeclaration newMethod) { final AST ast= newMethod.getAST(); for (int index= 0, n= oldMethod.typeParameters().size(); index < n; index++) newMethod.typeParameters().add(index, ASTNode.copySubtree(ast, (TypeParameter) oldMethod.typeParameters().get(index))); }
@Override @SuppressWarnings("unchecked") public List<TypeVariableSource<O>> getTypeVariables() { List<TypeVariableSource<O>> result = new ArrayList<TypeVariableSource<O>>(); List<TypeParameter> typeParameters = method.typeParameters(); if (typeParameters != null) { for (TypeParameter typeParameter : typeParameters) { result.add(new TypeVariableImpl<O>(parent, typeParameter)); } } return Collections.unmodifiableList(result); }
@Override public MethodSource<O> removeTypeVariable(String name) { @SuppressWarnings("unchecked") List<TypeParameter> typeParameters = method.typeParameters(); for (Iterator<TypeParameter> iter = typeParameters.iterator(); iter.hasNext();) { if (Strings.areEqual(name, iter.next().getName().getIdentifier())) { iter.remove(); break; } } return this; }
@Override public MethodSource<O> removeTypeVariable(String name) { @SuppressWarnings("unchecked") List<TypeParameter> typeParameters = method.typeParameters(); for (Iterator<TypeParameter> iter = typeParameters.iterator(); iter.hasNext();) { if (Strings.areEqual(name, iter.next().getName().getIdentifier())) { iter.remove(); break; } } return this; }
@SuppressWarnings("unchecked") public String[] getTypeParameters() { if (typeParameters == EMPTY_STRING_ARRAY) { typeParameters = convertASTNodeListToStringArray(getASTNode().typeParameters()); } return typeParameters; }
@SuppressWarnings("unchecked") public String[] getTypeParameters() { if (typeParameters == EMPTY_STRING_ARRAY) { typeParameters = convertASTNodeListToStringArray(getASTNode().typeParameters()); } return typeParameters; }
@SuppressWarnings("unchecked") @Override public TypeVariableSource<O> addTypeVariable() { TypeParameter tp2 = method.getAST().newTypeParameter(); method.typeParameters().add(tp2); return new TypeVariableImpl<O>(parent, tp2); }
@SuppressWarnings("unchecked") @Override public TypeVariableSource<O> addTypeVariable() { TypeParameter tp2 = method.getAST().newTypeParameter(); method.typeParameters().add(tp2); return new TypeVariableImpl<O>(parent, tp2); }
public static TypeParameter newTypeParameter(AST ast, String content) { StringBuffer buffer= new StringBuffer(TYPEPARAM_HEADER); buffer.append(content); buffer.append(TYPEPARAM_FOOTER); ASTParser p= ASTParser.newParser(ast.apiLevel()); p.setSource(buffer.toString().toCharArray()); CompilationUnit root= (CompilationUnit) p.createAST(null); List list= root.types(); TypeDeclaration typeDecl= (TypeDeclaration) list.get(0); MethodDeclaration methodDecl= typeDecl.getMethods()[0]; TypeParameter tp= (TypeParameter) methodDecl.typeParameters().get(0); ASTNode result= ASTNode.copySubtree(ast, tp); result.accept(new PositionClearer()); return (TypeParameter) result; }
@SuppressWarnings("unchecked") @Override public boolean hasTypeVariable(String name) { List<TypeParameter> typeParameters = method.typeParameters(); for (TypeParameter typeParameter : typeParameters) { if (Strings.areEqual(name, typeParameter.getName().getIdentifier())) { return true; } } return false; }
@Override @SuppressWarnings("unchecked") public TypeVariableSource<O> getTypeVariable(String name) { List<TypeParameter> typeParameters = method.typeParameters(); for (TypeParameter typeParameter : typeParameters) { if (Strings.areEqual(name, typeParameter.getName().getIdentifier())) { return new TypeVariableImpl<O>(parent, typeParameter); } } return null; }
@Override public TypeVariableSource<O> getTypeVariable(String name) { @SuppressWarnings("unchecked") List<TypeParameter> typeParameters = method.typeParameters(); for (TypeParameter typeParameter : typeParameters) { if (Strings.areEqual(name, typeParameter.getName().getIdentifier())) { return(new TypeVariableImpl<O>(parent, typeParameter)); } } return null; }
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); } }
@Override public boolean visit(MethodDeclaration node) { if (isInside(node)) { Block body= node.getBody(); if (body != null) { body.accept(this); } visitBackwards(node.parameters()); visitBackwards(node.typeParameters()); } return false; }
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, TypeLocation.TYPE_BOUND)); intermediary.typeParameters().add(parameter); } }
@Override public boolean visit(MethodDeclaration node) { if (isInside(node)) { Block body= node.getBody(); if (body != null) { body.accept(this); } visitBackwards(node.parameters()); visitBackwards(node.typeParameters()); } return false; }
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew) { 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())); intermediary.typeParameters().add(parameter); } }
public boolean visit(MethodDeclaration node) { if (isInside(node)) { Block body= node.getBody(); if (body != null) { body.accept(this); } visitBackwards(node.parameters()); if (node.getAST().apiLevel() >= AST.JLS3) { visitBackwards(node.typeParameters()); } } return false; }