Exemplo n.º 1
0
  public void dumpDeclaration(
      TabbedPrintWriter writer, ProgressListener pl, double done, double scale) throws IOException {
    if (fields == null) {
      /* This means that the class could not be loaded.
       * give up.
       */
      return;
    }

    writer.startOp(writer.NO_PAREN, 0);
    /* Clear the SUPER bit, which is also used as SYNCHRONIZED bit. */
    int modifiedModifiers = modifiers & ~(Modifier.SYNCHRONIZED | STRICTFP);
    if (clazz.isInterface())
      /* interfaces are implicitily abstract */
      modifiedModifiers &= ~Modifier.ABSTRACT;
    if (parent instanceof MethodAnalyzer) {
      /* method scope classes are implicitly private */
      modifiedModifiers &= ~Modifier.PRIVATE;
      /* anonymous classes are implicitly final */
      if (name == null) modifiedModifiers &= ~Modifier.FINAL;
    }
    String modif = Modifier.toString(modifiedModifiers);
    if (modif.length() > 0) writer.print(modif + " ");
    if (isStrictFP()) {
      /* The STRICTFP modifier is set.
       * We handle it, since java.lang.reflect.Modifier is too dumb.
       */
      writer.print("strictfp ");
    }
    /* interface is in modif */
    if (!clazz.isInterface()) writer.print("class ");
    writer.print(name);
    ClassInfo superClazz = clazz.getSuperclass();
    if (superClazz != null && superClazz != ClassInfo.javaLangObject) {
      writer.breakOp();
      writer.print(" extends " + (writer.getClassString(superClazz, Scope.CLASSNAME)));
    }
    ClassInfo[] interfaces = clazz.getInterfaces();
    if (interfaces.length > 0) {
      writer.breakOp();
      writer.print(clazz.isInterface() ? " extends " : " implements ");
      writer.startOp(writer.EXPL_PAREN, 1);
      for (int i = 0; i < interfaces.length; i++) {
        if (i > 0) {
          writer.print(", ");
          writer.breakOp();
        }
        writer.print(writer.getClassString(interfaces[i], Scope.CLASSNAME));
      }
      writer.endOp();
    }
    writer.println();

    writer.openBraceClass();
    writer.tab();
    dumpBlock(writer, pl, done, scale);
    writer.untab();
    writer.closeBraceClass();
  }
Exemplo n.º 2
0
 public void closeBraceContinue() {
   if ((Options.outputStyle & Options.BRACE_AT_EOL) != 0) print("} ");
   else {
     println("}");
     if ((Options.outputStyle & Options.BRACE_FLUSH_LEFT) == 0 && currentIndent > 0) untab();
   }
 }
Exemplo n.º 3
0
 public void openBraceClass() {
   if (currentLine.length() > 0) {
     if ((Options.outputStyle & Options.BRACE_AT_EOL) != 0) print(" ");
     else println();
   }
   println("{");
 }
Exemplo n.º 4
0
 /**
  * Print a opening brace with the current indentation style. Called at the end the line of a
  * method declaration.
  */
 public void openBraceNoIndent() {
   if ((Options.outputStyle & Options.BRACE_AT_EOL) != 0) {
     print(currentLine.length() > 0 ? " {" : "{");
     println();
   } else {
     if (currentLine.length() > 0) println();
     println("{");
   }
 }
Exemplo n.º 5
0
 /**
  * Print a opening brace with the current indentation style. Called at the end of the line of the
  * instance that opens the brace. It doesn't do a tab stop after opening the brace.
  */
 public void openBrace() {
   if ((Options.outputStyle & Options.BRACE_AT_EOL) != 0) {
     print(currentLine.length() > 0 ? " {" : "{");
     println();
   } else {
     if (currentLine.length() > 0) println();
     if ((Options.outputStyle & Options.BRACE_FLUSH_LEFT) == 0 && currentIndent > 0) tab();
     println("{");
   }
 }
Exemplo n.º 6
0
 public void dumpExpression(TabbedPrintWriter writer) throws java.io.IOException {
   subExpressions[0].dumpExpression(writer, getPriority() + 1);
   writer.breakOp();
   writer.print(getOperatorString());
   subExpressions[1].dumpExpression(writer, getPriority() + 1);
 }
Exemplo n.º 7
0
 public void closeBraceClass() {
   print("}");
 }
Exemplo n.º 8
0
 public void printType(Type type) {
   print(getTypeString(type));
 }
Exemplo n.º 9
0
 public void println(String str) {
   print(str);
   println();
 }