Exemple #1
0
 /**
  *
  *
  * <pre>
  * ImportDeclaration : ModuleImport
  * ImportDeclaration : import ImportClause FromClause ;
  * ImportDeclaration : import ModuleSpecifier ;
  * </pre>
  */
 @Override
 public List<Name> visit(ImportDeclaration node, List<Name> names) {
   switch (node.getType()) {
     case ImportFrom:
       return node.getImportClause().accept(this, names);
     case ImportModule:
       return names;
     default:
       throw new AssertionError();
   }
 }
 /*
  * @see ASTVisitor#visit(ImportDeclaration)
  */
 @Override
 public boolean visit(ImportDeclaration node) {
   this.fBuffer.append("import "); // $NON-NLS-1$
   if (node.getAST().apiLevel() >= JLS3) {
     if (node.isStatic()) {
       this.fBuffer.append("static "); // $NON-NLS-1$
     }
   }
   node.getName().accept(this);
   if (node.isOnDemand()) {
     this.fBuffer.append(".*"); // $NON-NLS-1$
   }
   this.fBuffer.append(";"); // $NON-NLS-1$
   return false;
 }
 /*
  * @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;
 }
 @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);
     }
   }
 }
 @Override
 public void visit(final ImportDeclaration n, final A arg) {
   visitComment(n.getComment(), arg);
   n.getName().accept(this, arg);
 }