@Override public void visit(MethodDeclaration n, List<String> arg) { if (n.getAnnotations() != null) annotationExprs.addAll(n.getAnnotations()); super.visit(n, arg); }
@Override public void visit(MethodDeclaration method, A result) { if (CollectionUtils.isEmpty(method.getAnnotations())) { return; } for (AnnotationExpr annotation : method.getAnnotations()) { if (!annotation.getClass().equals(NormalAnnotationExpr.class)) { continue; } NormalAnnotationExpr annot = (NormalAnnotationExpr) annotation; if (annot.getName().toString().equals(SampleCode.class.getSimpleName()) && !CollectionUtils.isEmpty(annot.getPairs())) { for (MemberValuePair pair : annot.getPairs()) { // get the 'api' parameter from the annotation to let us know which api this function belongs to if (StringUtils.equals(pair.getName(), "api") && !StringUtils.isBlank(pair.getValue().toString())) { result.put(getCacheRowKey(type, pair.getValue().toString().replace("\"", "")), stripTestPrefix(method.getName()), stripCurlyBrackets(method.getBody().toString())); return; } } } } } }
if (bodyDeclaration instanceof MethodDeclaration) { MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration; if (methodDeclaration.getAnnotations() != null) { annotationExprs.addAll(methodDeclaration.getAnnotations()); fieldInfos.add(new FieldInfo(methodDeclaration.getType(), methodDeclaration.getName(), methodDeclaration.getAnnotations(), methodDeclaration)); MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration; if (methodDeclaration.getName().equals(fieldInfo.getName().replace("get", "set"))) { if (methodDeclaration.getAnnotations() != null) fieldDeclaration.getAnnotations().addAll(methodDeclaration.getAnnotations());
@Override public void visit(MethodDeclaration n, Object arg) { // here you can access the attributes of the method. // this method will be called for all methods in this // CompilationUnit, including inner class methods currentMethod = new CGEntry(TYPE.METHOD, currentClass, currentMethod, n.getName()); if (isDebug()) System.out.println("M:" + currentMethod); list.add(currentMethod); List<AnnotationExpr> annos = n.getAnnotations(); if (annos != null) { for (AnnotationExpr anno : annos) { if (isDebug()) System.out.println("A:" + anno.getName()); currentMethod.addAnnotation(new CGEntry(TYPE.ANNOTATION, currentClass, currentMethod, anno.getName().getName())); } } super.visit(n, arg); if (currentMethod != null) currentMethod = currentMethod.getMethod(); }
n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); final List<AnnotationExpr> annotations = n.getAnnotations(); if (annotations != null) { for (int i = 0; i < annotations.size(); i++) {
public void visit(MethodDeclaration n, Object arg) { printJavadoc(n.getJavaDoc(), arg); printMemberAnnotations(n.getAnnotations(), arg); printModifiers(n.getModifiers());
printMemberAnnotations(n.getAnnotations(), arg); printModifiers(n.getModifiers());
@Override public void visit(final MethodDeclaration n, final A arg) { visitComment(n.getComment(), arg); if (n.getJavaDoc() != null) { n.getJavaDoc().accept(this, arg); } if (n.getAnnotations() != null) { for (final AnnotationExpr a : n.getAnnotations()) { a.accept(this, arg); } } if (n.getTypeParameters() != null) { for (final TypeParameter t : n.getTypeParameters()) { t.accept(this, arg); } } n.getType().accept(this, arg); if (n.getParameters() != null) { for (final Parameter p : n.getParameters()) { p.accept(this, arg); } } if (n.getThrows() != null) { for (final NameExpr name : n.getThrows()) { name.accept(this, arg); } } if (n.getBody() != null) { n.getBody().accept(this, arg); } }
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { return Boolean.FALSE;
if (n.getAnnotations() != null) { for (final AnnotationExpr a : n.getAnnotations()) {
@Override public Node visit(MethodDeclaration _n, Object _arg) { JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); Type type_ = cloneNodes(_n.getType(), _arg); List<Parameter> parameters = visit(_n.getParameters(), _arg); List<NameExpr> throws_ = visit(_n.getThrows(), _arg); BlockStmt block = cloneNodes(_n.getBody(), _arg); Comment comment = cloneNodes(_n.getComment(), _arg); MethodDeclaration r = new MethodDeclaration( _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getModifiers(), annotations, typeParameters, type_, _n.getName(), parameters, _n.getArrayCount(), throws_, block ); r.setComment(comment); return r; }
ClassOrInterfaceDeclaration a = file.assertDeclaration(); MethodDeclaration decl = (MethodDeclaration)a.getMembers().get(0); decl.getAnnotations().get(0).setName(ASTHelper.createNameExpr(Action.class.getName())); file.assertSave();
ClassOrInterfaceDeclaration a = file.assertDeclaration(); MethodDeclaration decl = (MethodDeclaration)a.getMembers().get(0); decl.getAnnotations().clear(); file.assertSave();
ClassOrInterfaceDeclaration a = file.assertDeclaration(); MethodDeclaration decl = (MethodDeclaration)a.getMembers().get(0); decl.getAnnotations().clear(); file.assertSave();
ClassOrInterfaceDeclaration a = file.assertDeclaration(); MethodDeclaration decl = (MethodDeclaration)a.getMembers().get(0); decl.getAnnotations().get(0).setName(ASTHelper.createNameExpr(Action.class.getName())); file.assertSave();