@Override
 public Void visit(ObjectCreationExpr expr, AElement elem) {
   ClassOrInterfaceType type = expr.getType();
   AClass clazz = scene.classes.vivify(type.getName());
   Expression scope = expr.getScope();
   List<Type> typeArgs = expr.getTypeArgs();
   List<Expression> args = expr.getArgs();
   List<BodyDeclaration> decls = expr.getAnonymousClassBody();
   if (scope != null) {
     scope.accept(this, elem);
   }
   if (args != null) {
     for (Expression arg : args) {
       arg.accept(this, elem);
     }
   }
   if (typeArgs != null) {
     for (Type typeArg : typeArgs) {
       typeArg.accept(this, elem);
     }
   }
   type.accept(this, clazz);
   if (decls != null) {
     for (BodyDeclaration decl : decls) {
       decl.accept(this, clazz);
     }
   }
   return null;
 }
示例#2
0
  @Override
  public void visit(ObjectCreationExpr n, Object arg) {
    if (n.getScope() != null) {
      n.getScope().accept(this, arg);
      printer.print(".");
    }

    printer.print("new ");

    printTypeArgs(n.getTypeArgs(), arg);
    n.getType().accept(this, arg);

    printArguments(n.getArgs(), arg);

    if (n.getAnonymousClassBody() != null) {
      printer.printLn(" {");
      printer.indent();
      printMembers(n.getAnonymousClassBody(), arg);
      printer.unindent();
      printer.print("}");
    }
  }