@Override public void visit(MethodDeclaration n, ExecutableElement element) { if (element.getSimpleName().toString().equals(n.getName()) && (n.getParameters() == null ? 0 : n.getParameters().size()) - (element.getParameters() == null ? 0 : element.getParameters().size()) == 0) { if (n.getBody() == null) { this.methodBody = null; } else { this.methodBody = n.getBody().toString(); } } }
@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; } } } } } }
@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); } }
@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; }