コード例 #1
0
 @Override
 public void visit(BlockStmt n, Object arg) {
   printer.printLn("{");
   if (n.getStmts() != null) {
     printer.indent();
     for (Statement s : n.getStmts()) {
       s.accept(this, arg);
       printer.printLn();
     }
     printer.unindent();
   }
   printer.print("}");
 }
コード例 #2
0
 @Override
 public void visit(SwitchStmt n, Object arg) {
   printer.print("switch(");
   n.getSelector().accept(this, arg);
   printer.printLn(") {");
   if (n.getEntries() != null) {
     printer.indent();
     for (SwitchEntryStmt e : n.getEntries()) {
       e.accept(this, arg);
     }
     printer.unindent();
   }
   printer.print("}");
 }
コード例 #3
0
  @Override
  public void visit(AnnotationDeclaration n, Object arg) {
    printJavadoc(n.getJavaDoc(), arg);
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    printer.print("@interface ");
    printer.print(n.getName());
    printer.printLn(" {");
    printer.indent();
    if (n.getMembers() != null) {
      printMembers(n.getMembers(), arg);
    }
    printer.unindent();
    printer.print("}");
  }
コード例 #4
0
  @Override
  public void visit(ClassOrInterfaceDeclaration n, Object arg) {
    printJavadoc(n.getJavaDoc(), arg);
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    if (n.isInterface()) {
      printer.print("interface ");
    } else {
      printer.print("class ");
    }

    printer.print(n.getName());

    printTypeParameters(n.getTypeParameters(), arg);

    if (n.getExtends() != null) {
      printer.print(" extends ");
      for (Iterator<ClassOrInterfaceType> i = n.getExtends().iterator(); i.hasNext(); ) {
        ClassOrInterfaceType c = i.next();
        c.accept(this, arg);
        if (i.hasNext()) {
          printer.print(", ");
        }
      }
    }

    if (n.getImplements() != null) {
      printer.print(" implements ");
      for (Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext(); ) {
        ClassOrInterfaceType c = i.next();
        c.accept(this, arg);
        if (i.hasNext()) {
          printer.print(", ");
        }
      }
    }

    printer.printLn(" {");
    printer.indent();
    if (n.getMembers() != null) {
      printMembers(n.getMembers(), arg);
    }
    printer.unindent();
    printer.print("}");
  }
コード例 #5
0
  @Override
  public void visit(EnumConstantDeclaration n, Object arg) {
    printJavadoc(n.getJavaDoc(), arg);
    printMemberAnnotations(n.getAnnotations(), arg);
    printer.print(n.getName());

    if (n.getArgs() != null) {
      printArguments(n.getArgs(), arg);
    }

    if (n.getClassBody() != null) {
      printer.printLn(" {");
      printer.indent();
      printMembers(n.getClassBody(), arg);
      printer.unindent();
      printer.printLn("}");
    }
  }
コード例 #6
0
  @Override
  public void visit(EnumDeclaration n, Object arg) {
    printJavadoc(n.getJavaDoc(), arg);
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    printer.print("enum ");
    printer.print(n.getName());

    if (n.getImplements() != null) {
      printer.print(" implements ");
      for (Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext(); ) {
        ClassOrInterfaceType c = i.next();
        c.accept(this, arg);
        if (i.hasNext()) {
          printer.print(", ");
        }
      }
    }

    printer.printLn(" {");
    printer.indent();
    if (n.getEntries() != null) {
      printer.printLn();
      for (Iterator<EnumConstantDeclaration> i = n.getEntries().iterator(); i.hasNext(); ) {
        EnumConstantDeclaration e = i.next();
        e.accept(this, arg);
        if (i.hasNext()) {
          printer.print(", ");
        }
      }
    }
    if (n.getMembers() != null) {
      printer.printLn(";");
      printMembers(n.getMembers(), arg);
    } else {
      if (n.getEntries() != null) {
        printer.printLn();
      }
    }
    printer.unindent();
    printer.print("}");
  }
コード例 #7
0
 @Override
 public void visit(SwitchEntryStmt n, Object arg) {
   if (n.getLabel() != null) {
     printer.print("case ");
     n.getLabel().accept(this, arg);
     printer.print(":");
   } else {
     printer.print("default:");
   }
   printer.printLn();
   printer.indent();
   if (n.getStmts() != null) {
     for (Statement s : n.getStmts()) {
       s.accept(this, arg);
       printer.printLn();
     }
   }
   printer.unindent();
 }
コード例 #8
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("}");
    }
  }