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);
 }
Beispiel #2
0
  public void dumpBlock(TabbedPrintWriter writer, ProgressListener pl, double done, double scale)
      throws IOException {
    double subScale = scale / getComplexity();
    writer.pushScope(this);
    boolean needFieldNewLine = false;
    boolean needNewLine = false;
    Set declared = null;
    if ((Options.options & Options.OPTION_IMMEDIATE) != 0) declared = new SimpleSet();
    for (int i = 0; i < fields.length; i++) {
      if (blockInitializers[i] != null) {
        if (needNewLine) writer.println();
        writer.openBrace();
        writer.tab();
        blockInitializers[i].dumpSource(writer);
        writer.untab();
        writer.closeBrace();
        needFieldNewLine = needNewLine = true;
      }
      if ((Options.options & Options.OPTION_IMMEDIATE) != 0) {
        // We now do the analyzation we skipped before.
        fields[i].analyze();
        fields[i].makeDeclaration(declared);
      }
      if (fields[i].skipWriting()) continue;
      if (needFieldNewLine) writer.println();
      fields[i].dumpSource(writer);
      needNewLine = true;
    }
    if (blockInitializers[fields.length] != null) {
      if (needNewLine) writer.println();
      writer.openBrace();
      writer.tab();
      blockInitializers[fields.length].dumpSource(writer);
      writer.untab();
      writer.closeBrace();
      needNewLine = true;
    }
    for (int i = 0; i < inners.length; i++) {
      if (needNewLine) writer.println();

      if ((Options.options & Options.OPTION_IMMEDIATE) != 0) {
        // We now do the analyzation we skipped before.
        inners[i].analyze(null, 0.0, 0.0);
        inners[i].analyzeInnerClasses(null, 0.0, 0.0);
        inners[i].makeDeclaration(declared);
      }

      if (pl != null) {
        double innerCompl = inners[i].getComplexity() * subScale;
        if (innerCompl > STEP_COMPLEXITY) inners[i].dumpSource(writer, pl, done, innerCompl);
        else {
          pl.updateProgress(done, name);
          inners[i].dumpSource(writer);
        }
        done += innerCompl;
      } else inners[i].dumpSource(writer);
      needNewLine = true;
    }
    for (int i = 0; i < methods.length; i++) {
      if ((Options.options & Options.OPTION_IMMEDIATE) != 0) {
        // We now do the analyzation we skipped before.
        if (!methods[i].isConstructor()) methods[i].analyze(null, 0.0, 0.0);
        methods[i].analyzeInnerClasses();
        methods[i].makeDeclaration(declared);
      }

      if (methods[i].skipWriting()) continue;
      if (needNewLine) writer.println();

      if (pl != null) {
        double methodCompl = methods[i].getComplexity() * subScale;
        pl.updateProgress(done, methods[i].getName());
        methods[i].dumpSource(writer);
        done += methodCompl;
      } else methods[i].dumpSource(writer);
      needNewLine = true;
    }
    writer.popScope();
    clazz.dropInfo(clazz.KNOWNATTRIBS | clazz.UNKNOWNATTRIBS);
  }
Beispiel #3
0
 public void dumpSource(TabbedPrintWriter writer, ProgressListener pl, double done, double scale)
     throws IOException {
   dumpDeclaration(writer, pl, done, scale);
   writer.println();
 }
Beispiel #4
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();
  }