public String getName() { return methodDeclaration.getName(); }
@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 n, Visit v) { Iterator<Signature> signatures = ((Visit.TD)v).methodSignatures; if (!signatures.hasNext()) { throw new CodeSourceException("Did not find a method signature for declaration " + n.getName()); } // Signature signature = signatures.next(); // SignedMemberSource methodSource = new SignedMemberSource( new MemberKey(n.getName(), signature), clip(n), v.javaDoc(n)); // ((Visit.TD)v).stack.getLast().addLast(methodSource); return super.visit(n, v); }
@Override public void visit(ClassOrInterfaceDeclaration n, List<String> excludedMethods) { n.setAnnotations(null); List<MethodDeclaration> methodToRemove = new ArrayList<MethodDeclaration>(); for (BodyDeclaration bodyDeclaration : n.getMembers()) { if(bodyDeclaration instanceof MethodDeclaration) { MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration; if (excludedMethods.contains(methodDeclaration.getName())) { methodToRemove.add(methodDeclaration); } } } n.getMembers().removeAll(methodToRemove); // if (n.getAnnotations() != null) annotationExprs.addAll(n.getAnnotations()); n.setName(name); super.visit(n, excludedMethods); }
@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(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(); }
annotationExprs.addAll(methodDeclaration.getAnnotations()); fieldInfos.add(new FieldInfo(methodDeclaration.getType(), methodDeclaration.getName(), methodDeclaration.getAnnotations(), methodDeclaration)); if (bodyDeclaration instanceof MethodDeclaration) { MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration; if (methodDeclaration.getName().equals(fieldInfo.getName().replace("get", "set"))) { if (methodDeclaration.getAnnotations() != null) fieldDeclaration.getAnnotations().addAll(methodDeclaration.getAnnotations());
printer.print(n.getName());
printer.print(n.getName());
@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; }