/**
  * @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);
   }
 }
 @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(";");
 }
 @Override
 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);
     }
     printer.printLn();
   }
   if (n.getTypes() != null) {
     for (Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext(); ) {
       i.next().accept(this, arg);
       printer.printLn();
       if (i.hasNext()) {
         printer.printLn();
       }
     }
   }
 }