Пример #1
0
  /** Compiles the compilation unit from sources. */
  public void compile(int throughPhase) throws CompilationFailedException {
    //
    // To support delta compilations, we always restart
    // the compiler.  The individual passes are responsible
    // for not reprocessing old code.
    gotoPhase(Phases.INITIALIZATION);
    throughPhase = Math.min(throughPhase, Phases.ALL);

    while (throughPhase >= phase && phase <= Phases.ALL) {

      if (phase == Phases.SEMANTIC_ANALYSIS) {
        doPhaseOperation(resolve);
        if (dequeued()) continue;
      }

      processPhaseOperations(phase);
      // Grab processing may have brought in new AST transforms into various phases, process them as
      // well
      processNewPhaseOperations(phase);

      if (progressCallback != null) progressCallback.call(this, phase);
      completePhase();
      applyToSourceUnits(mark);

      if (dequeued()) continue;

      gotoPhase(phase + 1);

      if (phase == Phases.CLASS_GENERATION) {
        sortClasses();
      }
    }

    errorCollector.failIfErrors();
  }