@Override public final ASTNode getTargetNode() throws JavaModelException { return JavadocUtil.createParamTag(fTargetName, declaration.getAST(), fMethod.getJavaProject()); } });
@Override public final ASTNode getTargetNode() throws JavaModelException { return JavadocUtil.createParamTag(fTargetName, declaration.getAST(), fMethod.getJavaProject()); } });
public IMethodBinding findRealMethod(final MethodDeclaration node, final IMethodBinding meth, final ITypeBinding mockedType) { IMethodBinding origMethod = null; if (mockedType != null) origMethod = MockUtil.findRealMethodInType(mockedType, new InvocationFilter(meth), node.getAST()); return origMethod; }
protected static void copyThrownExceptions(final MethodDeclaration oldMethod, final MethodDeclaration newMethod) { final AST ast= newMethod.getAST(); for (int index= 0, n= oldMethod.thrownExceptions().size(); index < n; index++) newMethod.thrownExceptions().add(index, ASTNode.copySubtree(ast, (Name) oldMethod.thrownExceptions().get(index))); }
protected static void copyAnnotations(final MethodDeclaration oldMethod, final MethodDeclaration newMethod) { final AST ast= newMethod.getAST(); for (int index= 0, n= oldMethod.modifiers().size(); index < n; index++) { final IExtendedModifier modifier= (IExtendedModifier) oldMethod.modifiers().get(index); final List<IExtendedModifier> modifiers= newMethod.modifiers(); if (modifier.isAnnotation() && !modifiers.contains(modifier)) modifiers.add((IExtendedModifier) ASTNode.copySubtree(ast, (Annotation) modifier)); } }
@SuppressWarnings("unchecked") @Override public TypeVariableSource<O> addTypeVariable() { TypeParameter tp2 = method.getAST().newTypeParameter(); method.typeParameters().add(tp2); return new TypeVariableImpl<O>(parent, tp2); }
/** * @param decl the method declaration * @return the return type * @deprecated Deprecated to avoid deprecated warnings */ @Deprecated private static ASTNode getReturnType(MethodDeclaration decl) { // used from API, can't eliminate return decl.getAST().apiLevel() == AST.JLS2 ? decl.getReturnType() : decl.getReturnType2(); }
@SuppressWarnings("unchecked") @Override public TypeVariableSource<O> addTypeVariable() { TypeParameter tp2 = method.getAST().newTypeParameter(); method.typeParameters().add(tp2); return new TypeVariableImpl<O>(parent, tp2); }
/** * @deprecated Deprecated to avoid deprecated warnings */ private static ASTNode getReturnType(MethodDeclaration decl) { // used from API, can't eliminate return (decl.getAST().apiLevel() == AST.JLS2) ? decl.getReturnType() : decl.getReturnType2(); }
public final ASTNode getArgumentNode(final IVariableBinding argument, final boolean last) throws JavaModelException { Assert.isNotNull(argument); if (elements.containsKey(argument.getKey())) return rewrite.createCopyTarget((ASTNode) elements.get(argument.getKey())); return JavadocUtil.createParamTag(argument.getName(), declaration.getAST(), fMethod.getJavaProject()); }
@Override public JavaDocSource<MethodSource<O>> getJavaDoc() { Javadoc javadoc = method.getJavadoc(); if (javadoc == null) { javadoc = method.getAST().newJavadoc(); method.setJavadoc(javadoc); } return new JavaDocImpl<MethodSource<O>>(this, javadoc); }
@Override public MethodSource<O> setBody(final String body) { String stub = "public class Stub { public void method() {" + body + "} }"; JavaClassSource temp = (JavaClassSource) Roaster.parse(stub); List<MethodSource<JavaClassSource>> methods = temp.getMethods(); Block block = ((MethodDeclaration) methods.get(0).getInternal()).getBody(); block = (Block) ASTNode.copySubtree(method.getAST(), block); method.setBody(block); return this; }
public TextEdit getDeleteEdit() { final ASTRewrite rewriter= ASTRewrite.create(fDeclaration.getAST()); rewriter.remove(fDeclaration, null); return rewriter.rewriteAST(fDocument, fTypeRoot.getJavaProject().getOptions(true)); }
public TextEdit getDeleteEdit() { final ASTRewrite rewriter= ASTRewrite.create(fDeclaration.getAST()); rewriter.remove(fDeclaration, null); return rewriter.rewriteAST(fDocument, fTypeRoot.getJavaProject().getOptions(true)); }
public TextEdit getDeleteEdit() { final ASTRewrite rewriter= ASTRewrite.create(fDeclaration.getAST()); rewriter.remove(fDeclaration, null); return rewriter.rewriteAST(fDocument, fTypeRoot.getJavaProject().getOptions(true)); }
public static void addMethodWithConstrNameProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { ICompilationUnit cu= context.getCompilationUnit(); ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot()); if (selectedNode instanceof MethodDeclaration) { MethodDeclaration declaration= (MethodDeclaration) selectedNode; ASTRewrite rewrite= ASTRewrite.create(declaration.getAST()); rewrite.set(declaration, MethodDeclaration.CONSTRUCTOR_PROPERTY, Boolean.TRUE, null); String label= CorrectionMessages.ReturnTypeSubProcessor_constrnamemethod_description; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, IProposalRelevance.CHANGE_TO_CONSTRUCTOR, image); proposals.add(proposal); } }
private void addParameterToConstructor(final ASTRewrite rewrite, final MethodDeclaration declaration) throws JavaModelException { Assert.isNotNull(rewrite); Assert.isNotNull(declaration); final AST ast= declaration.getAST(); final String name= getNameForEnclosingInstanceConstructorParameter(); final SingleVariableDeclaration variable= ast.newSingleVariableDeclaration(); variable.setType(createEnclosingType(ast)); variable.setName(ast.newSimpleName(name)); rewrite.getListRewrite(declaration, MethodDeclaration.PARAMETERS_PROPERTY).insertFirst(variable, null); JavadocUtil.addParamJavadoc(name, declaration, rewrite, fType.getJavaProject(), null); }
@SuppressWarnings("deprecation") private void clearExtraDimensions() { if (getASTNode().getAST().apiLevel() <= 4) { setNodeProperty(getASTNode(), 0, MethodDeclaration.EXTRA_DIMENSIONS_PROPERTY); } else { setListNodeProperty(getASTNode(), EMPTY_STRING_ARRAY, EXTRA_DIMENSIONS2_PROPERTY, DIMENSION); } }
private void addExplicitSuperConstructorCall(MethodDeclaration constructor, CompilationUnitRewrite cuRewrite) { SuperConstructorInvocation superCall= constructor.getAST().newSuperConstructorInvocation(); addArgumentsToNewSuperConstructorCall(superCall, cuRewrite); String msg= RefactoringCoreMessages.ChangeSignatureRefactoring_add_super_call; TextEditGroup description= cuRewrite.createGroupDescription(msg); cuRewrite.getASTRewrite().getListRewrite(constructor.getBody(), Block.STATEMENTS_PROPERTY).insertFirst(superCall, description); }
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; }