コード例 #1
0
 /**
  * @param pkgDecl AST node for package declaration
  * @param importDecls AST node for import declarations
  * @param scene scene for visitor methods to fill in
  */
 public ToIndexFileConverter(
     PackageDeclaration pkgDecl, List<ImportDeclaration> importDecls, AScene scene) {
   this.scene = scene;
   if (pkgDecl == null) {
     pkgName = "";
   } else {
     Matcher m = packagePattern.matcher(pkgDecl.toString());
     String s = m.find() ? m.group(1) : null;
     pkgName = s == null ? "" : s;
   }
   if (importDecls == null) {
     imports = Collections.emptyList();
   } else {
     ArrayList<String> imps = new ArrayList<String>(importDecls.size());
     for (ImportDeclaration decl : importDecls) {
       if (!decl.isStatic()) {
         Matcher m = importPattern.matcher(decl.toString());
         if (m.find()) {
           String s = m.group(1);
           if (s != null) {
             imps.add(s);
           }
         }
       }
     }
     imps.trimToSize();
     imports = Collections.unmodifiableList(imps);
   }
 }
コード例 #2
0
 @Override
 public void visit(ImportDeclaration n, Object arg) {
   printer.print("import ");
   if (n.isStatic()) {
     printer.print("static ");
   }
   n.getName().accept(this, arg);
   if (n.isAsterisk()) {
     printer.print(".*");
   }
   printer.printLn(";");
 }