예제 #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();
  }
예제 #2
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);
 }