/*
  * @see ASTVisitor#visit(CompilationUnit)
  */
 @Override
 public boolean visit(CompilationUnit node) {
   if (node.getPackage() != null) {
     node.getPackage().accept(this);
   }
   for (Iterator<ImportDeclaration> it = node.imports().iterator(); it.hasNext(); ) {
     ImportDeclaration d = it.next();
     d.accept(this);
   }
   for (Iterator<AbstractTypeDeclaration> it = node.types().iterator(); it.hasNext(); ) {
     AbstractTypeDeclaration d = it.next();
     d.accept(this);
   }
   return false;
 }
Esempio n. 2
0
 public void visit(CompilationUnit n, Object arg) {
   if (n.getPackage() != null) {
     n.getPackage().accept(this, arg);
   }
   if (n.getImports() != null) {
     for (ImportDeclaration i : n.getImports()) {
       i.accept(this, arg);
     }
   }
   if (n.getTypes() != null) {
     for (Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext(); ) {
       i.next().accept(this, arg);
       if (i.hasNext()) {}
     }
   }
 }
 @Override
 public void visit(final CompilationUnit n, final A arg) {
   visitComment(n.getComment(), arg);
   if (n.getPackage() != null) {
     n.getPackage().accept(this, arg);
   }
   if (n.getImports() != null) {
     for (final ImportDeclaration i : n.getImports()) {
       i.accept(this, arg);
     }
   }
   if (n.getTypes() != null) {
     for (final TypeDeclaration<?> typeDeclaration : n.getTypes()) {
       typeDeclaration.accept(this, arg);
     }
   }
 }
Esempio n. 4
0
 /** Gets the fully qualified name of the main type in this compilation unit. */
 public static String getQualifiedMainTypeName(CompilationUnit unit) {
   PackageDeclaration pkg = unit.getPackage();
   if (pkg.isDefaultPackage()) {
     return unit.getMainTypeName();
   } else {
     return pkg.getName().getFullyQualifiedName() + '.' + unit.getMainTypeName();
   }
 }