예제 #1
0
 private void printAnnotations(List<AnnotationExpr> annotations, Object arg) {
   if (annotations != null) {
     for (AnnotationExpr a : annotations) {
       a.accept(this, arg);
     }
   }
 }
 public void visit(MethodDeclaration n, A arg) {
   if (n.getJavaDoc() != null) {
     n.getJavaDoc().accept(this, arg);
   }
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   if (n.getTypeParameters() != null) {
     for (TypeParameter t : n.getTypeParameters()) {
       t.accept(this, arg);
     }
   }
   n.getType().accept(this, arg);
   if (n.getParameters() != null) {
     for (Parameter p : n.getParameters()) {
       p.accept(this, arg);
     }
   }
   if (n.getThrows() != null) {
     for (NameExpr name : n.getThrows()) {
       name.accept(this, arg);
     }
   }
   if (n.getBody() != null) {
     n.getBody().accept(this, arg);
   }
 }
 public void visit(EnumDeclaration n, A arg) {
   if (n.getJavaDoc() != null) {
     n.getJavaDoc().accept(this, arg);
   }
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   if (n.getImplements() != null) {
     for (ClassOrInterfaceType c : n.getImplements()) {
       c.accept(this, arg);
     }
   }
   if (n.getEntries() != null) {
     for (EnumConstantDeclaration e : n.getEntries()) {
       e.accept(this, arg);
     }
   }
   if (n.getMembers() != null) {
     for (BodyDeclaration member : n.getMembers()) {
       member.accept(this, arg);
     }
   }
 }
  public void visit(ClassOrInterfaceDeclaration n, A arg) {
    if (n.getJavaDoc() != null) {
      n.getJavaDoc().accept(this, arg);
    }
    if (n.getAnnotations() != null) {
      for (AnnotationExpr a : n.getAnnotations()) {
        a.accept(this, arg);
      }
    }
    if (n.getTypeParameters() != null) {
      for (TypeParameter t : n.getTypeParameters()) {
        t.accept(this, arg);
      }
    }
    if (n.getExtends() != null) {
      for (ClassOrInterfaceType c : n.getExtends()) {
        c.accept(this, arg);
      }
    }

    if (n.getImplements() != null) {
      for (ClassOrInterfaceType c : n.getImplements()) {
        c.accept(this, arg);
      }
    }
    if (n.getMembers() != null) {
      for (BodyDeclaration member : n.getMembers()) {
        member.accept(this, arg);
      }
    }
  }
 public void visit(PackageDeclaration n, A arg) {
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   n.getName().accept(this, arg);
 }
 public void visit(Parameter n, A arg) {
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   n.getType().accept(this, arg);
   n.getId().accept(this, arg);
 }
 public void visit(VariableDeclarationExpr n, A arg) {
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   n.getType().accept(this, arg);
   for (VariableDeclarator v : n.getVars()) {
     v.accept(this, arg);
   }
 }
 public static String translateAnnotations(List<AnnotationExpr> annotations) {
   String annotationTranslated = "";
   if (annotations != null) {
     for (AnnotationExpr ann : annotations) {
       annotationTranslated += ann.toString() + "\n\t";
     }
   }
   if (annotationTranslated.endsWith("\n\t"))
     annotationTranslated = annotationTranslated.substring(0, annotationTranslated.length() - 2);
   return annotationTranslated;
 }
 public void visit(FieldDeclaration n, A arg) {
   if (n.getJavaDoc() != null) {
     n.getJavaDoc().accept(this, arg);
   }
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   n.getType().accept(this, arg);
   for (VariableDeclarator var : n.getVariables()) {
     var.accept(this, arg);
   }
 }
 public void visit(AnnotationMemberDeclaration n, A arg) {
   if (n.getJavaDoc() != null) {
     n.getJavaDoc().accept(this, arg);
   }
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   n.getType().accept(this, arg);
   if (n.getDefaultValue() != null) {
     n.getDefaultValue().accept(this, arg);
   }
 }
 public void visit(AnnotationDeclaration n, A arg) {
   if (n.getJavaDoc() != null) {
     n.getJavaDoc().accept(this, arg);
   }
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   if (n.getMembers() != null) {
     for (BodyDeclaration member : n.getMembers()) {
       member.accept(this, arg);
     }
   }
 }
 public void visit(EnumConstantDeclaration n, A arg) {
   if (n.getJavaDoc() != null) {
     n.getJavaDoc().accept(this, arg);
   }
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   if (n.getArgs() != null) {
     for (Expression e : n.getArgs()) {
       e.accept(this, arg);
     }
   }
   if (n.getClassBody() != null) {
     for (BodyDeclaration member : n.getClassBody()) {
       member.accept(this, arg);
     }
   }
 }