docs: public CompilationUnitDeclaration resolve(
              CompilationUnitDeclaration unit,
              ICompilationUnit sourceUnit,
              boolean verifyMethods,
              boolean analyzeCode,
              boolean generateCode) {
  
          try {
              if (unit == null) {
                  // build and record parsed units
                  this.parseThreshold = 0; // will request a full parse
                  beginToCompile(new ICompilationUnit[] { sourceUnit });
                  // find the right unit from what was injected via accept(ICompilationUnit,..):
                  for (int i=0; i<this.totalUnits; i++) {
                      if (   this.unitsToProcess[i] != null
                          && this.unitsToProcess[i].compilationResult.compilationUnit == sourceUnit)
                      {
                          unit = this.unitsToProcess[i];
                          break;
                      }
                  }
                  if (unit == null)
                      unit = this.unitsToProcess[0]; // fall back to old behavior
  
              } else {
                  // initial type binding creation
                  this.lookupEnvironment.buildTypeBindings(unit, null /*no access restriction*/);
  
                  // binding resolution
                  this.lookupEnvironment.completeTypeBindings();
              }
              this.lookupEnvironment.unitBeingCompleted = unit;
              this.parser.getMethodBodies(unit);
              if (unit.scope != null) {
                  // fault in fields & methods
                  unit.scope.faultInTypes();
                  if (unit.scope != null && verifyMethods) {
                      // http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
                       // verify inherited methods
                      unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
                  }
                  // type checking
                  unit.resolve();
  
                  // flow analysis
                  if (analyzeCode) unit.analyseCode();
  
                  // code generation
                  if (generateCode) unit.generateCode();
  
                  // finalize problems (suppressWarnings)
                  unit.finalizeProblems();
              }
              if (this.unitsToProcess != null) this.unitsToProcess[0] = null; // release reference to processed unit declaration
              this.requestor.acceptResult(unit.compilationResult.tagAsAccepted());
              return unit;
          } catch (AbortCompilation e) {
              this.handleInternalException(e, unit);
              return unit == null ? this.unitsToProcess[0] : unit;
          } catch (Error e) {
              this.handleInternalException(e, unit, null);
              throw e; // rethrow
          } catch (RuntimeException e) {
              this.handleInternalException(e, unit, null);
              throw e; // rethrow
          } finally {
              // leave this.lookupEnvironment.unitBeingCompleted set to the unit, until another unit is resolved
              // other calls to dom can cause classpath errors to be detected, resulting in AbortCompilation exceptions
  
              // No reset is performed there anymore since,
              // within the CodeAssist (or related tools),
              // the compiler may be called *after* a call
              // to this resolve(...) method. And such a call
              // needs to have a compiler with a non-empty
              // environment.
              // this.reset();
          }
      }