示例#1
0
  public void makeDeclaration(Set done) {
    if (constrAna != null) constrAna.transform();
    if (staticConstructor != null) {
      new TransformConstructors(this, true, new MethodAnalyzer[] {staticConstructor}).transform();
    }

    // If output should be immediate, we delay analyzation to output.
    // Note that this may break anonymous classes, but the user
    // has been warned.
    if ((Options.options & Options.OPTION_IMMEDIATE) != 0) return;

    for (int j = 0; j < fields.length; j++) fields[j].makeDeclaration(done);
    for (int j = 0; j < inners.length; j++) inners[j].makeDeclaration(done);
    for (int j = 0; j < methods.length; j++) methods[j].makeDeclaration(done);
  }
示例#2
0
  public void analyze(ProgressListener pl, double done, double scale) {
    if (GlobalOptions.verboseLevel > 0) GlobalOptions.err.println("Class " + name);
    double subScale = scale / methodComplexity;
    if (pl != null) pl.updateProgress(done, name);

    imports.useClass(clazz);
    if (clazz.getSuperclass() != null) imports.useClass(clazz.getSuperclass());
    ClassInfo[] interfaces = clazz.getInterfaces();
    for (int j = 0; j < interfaces.length; j++) imports.useClass(interfaces[j]);

    if (fields == null) {
      /* This means that the class could not be loaded.
       * give up.
       */
      return;
    }

    // First analyze constructors and synthetic fields:
    constrAna = null;
    if (constructors.length > 0) {
      for (int j = 0; j < constructors.length; j++) {
        if (pl != null) {
          double constrCompl = constructors[j].getComplexity() * subScale;
          if (constrCompl > STEP_COMPLEXITY) constructors[j].analyze(pl, done, constrCompl);
          else {
            pl.updateProgress(done, name);
            constructors[j].analyze(null, 0.0, 0.0);
          }
          done += constrCompl;
        } else constructors[j].analyze(null, 0.0, 0.0);
      }
      constrAna = new TransformConstructors(this, false, constructors);
      constrAna.removeSynthInitializers();
    }
    if (staticConstructor != null) {
      if (pl != null) {
        double constrCompl = staticConstructor.getComplexity() * subScale;
        if (constrCompl > STEP_COMPLEXITY) staticConstructor.analyze(pl, done, constrCompl);
        else {
          pl.updateProgress(done, name);
          staticConstructor.analyze(null, 0.0, 0.0);
        }
        done += constrCompl;
      } else staticConstructor.analyze(null, 0.0, 0.0);
    }

    // If output should be immediate, we delay analyzation to output.
    // Note that this may break anonymous classes, but the user
    // has been warned.
    if ((Options.options & Options.OPTION_IMMEDIATE) != 0) return;

    // Analyze fields
    for (int j = 0; j < fields.length; j++) fields[j].analyze();

    // Now analyze remaining methods.
    for (int j = 0; j < methods.length; j++) {
      if (!methods[j].isConstructor())
        if (pl != null) {
          double methodCompl = methods[j].getComplexity() * subScale;
          if (methodCompl > STEP_COMPLEXITY) methods[j].analyze(pl, done, methodCompl);
          else {
            pl.updateProgress(done, methods[j].getName());
            methods[j].analyze(null, 0.0, 0.0);
          }
          done += methodCompl;
        } else methods[j].analyze(null, 0.0, 0.0);
    }
  }