@GwtIncompatible("Unnecessary")
  protected int doRun() throws IOException {
    Compiler.setLoggingLevel(Level.parse(config.loggingLevel));

    compiler = createCompiler();
    B options = createOptions();
    setRunOptions(options);

    List<SourceFile> externs = createExterns(options);
    List<JSModule> modules = null;
    Result result = null;

    rootRelativePathsMap = constructRootRelativePathsMap();

    boolean writeOutputToFile = !config.jsOutputFile.isEmpty();
    List<String> outputFileNames = new ArrayList<>();
    if (writeOutputToFile) {
      outputFileNames.add(config.jsOutputFile);
    }

    boolean createCommonJsModules = false;
    if (options.processCommonJSModules
        && (config.module.size() == 1 && "auto".equals(config.module.get(0)))) {
      createCommonJsModules = true;
      config.module.remove(0);
    }

    List<JsModuleSpec> jsModuleSpecs = new ArrayList<>();
    for (int i = 0; i < config.module.size(); i++) {
      jsModuleSpecs.add(JsModuleSpec.create(config.module.get(i), i == 0));
    }
    List<JsonFileSpec> jsonFiles = null;

    if (config.jsonStreamMode == JsonStreamMode.IN ||
        config.jsonStreamMode == JsonStreamMode.BOTH) {
      jsonFiles = parseJsonFilesFromInputStream();

      ImmutableMap.Builder<String, SourceMapInput> inputSourceMaps
          = new ImmutableMap.Builder<>();
      ImmutableMap.Builder<String, String> inputPathByWebpackId = new ImmutableMap.Builder<>();

      boolean foundJsonInputSourceMap = false;
      for (JsonFileSpec jsonFile : jsonFiles) {
        if (jsonFile.getSourceMap() != null && jsonFile.getSourceMap().length() > 0) {
          String sourceMapPath = jsonFile.getPath() + ".map";
          SourceFile sourceMap = SourceFile.fromCode(sourceMapPath,
              jsonFile.getSourceMap());
          inputSourceMaps.put(jsonFile.getPath(), new SourceMapInput(sourceMap));
          foundJsonInputSourceMap = true;
        }
        if (jsonFile.getWebpackId() != null) {
          inputPathByWebpackId.put(jsonFile.getWebpackId(), jsonFile.getPath());
        }
      }

      if (foundJsonInputSourceMap) {
        inputSourceMaps.putAll(options.inputSourceMaps);
        options.inputSourceMaps = inputSourceMaps.build();
      }

      compiler.initWebpackMap(inputPathByWebpackId.build());
    } else {
      ImmutableMap<String, String> emptyMap = ImmutableMap.of();
      compiler.initWebpackMap(emptyMap);
    }

    compiler.initWarningsGuard(options.getWarningsGuard());

    List<SourceFile> inputs =
        createSourceInputs(jsModuleSpecs, config.mixedJsSources, jsonFiles, config.moduleRoots);
    if (!jsModuleSpecs.isEmpty()) {
      if (isInTestMode()) {
        modules = modulesSupplierForTesting.get();
      } else {
        if (JsonStreamMode.IN.equals(config.jsonStreamMode)
            || JsonStreamMode.NONE.equals(config.jsonStreamMode)) {
          for (JsModuleSpec m : jsModuleSpecs) {
            checkModuleName(m.getName());
          }
        }
        modules = createJsModules(jsModuleSpecs, inputs);
      }
      for (JSModule m : modules) {
        outputFileNames.add(getModuleOutputFileName(m));
      }

      compiler.initModules(externs, modules, options);
    } else {
      compiler.init(externs, inputs, options);
    }

    if (options.printConfig) {
      compiler.printConfig(System.err);
    }


    String saveAfterChecksFilename = config.getSaveAfterChecksFileName();
    String continueSavedCompilationFilename = config.getContinueSavedCompilationFileName();
    if (config.skipNormalOutputs) {
      // TODO(bradfordcsmith): Should we be ignoring possible init/initModules() errors here?
      compiler.orderInputsWithLargeStack();
    } else if (compiler.hasErrors()) {
      // init() or initModules() encountered an error.
      compiler.generateReport();
      result = compiler.getResult();
    } else if (options.getInstrumentForCoverageOnly()) {
      result = instrumentForCoverage();
    } else if (saveAfterChecksFilename != null) {
      result = performStage1andSave(saveAfterChecksFilename);
    } else if (continueSavedCompilationFilename != null) {
      result = restoreAndPerformStage2(continueSavedCompilationFilename);
      if (modules != null) {
        modules = ImmutableList.copyOf(compiler.getModules());
      }
    } else {
      result = performFullCompilation();
    }

    if (createCommonJsModules) {
      // For CommonJS modules construct modules from actual inputs.
      modules = ImmutableList.copyOf(compiler.getModules());
      for (JSModule m : modules) {
        outputFileNames.add(getModuleOutputFileName(m));
      }
    }

    for (String outputFileName : outputFileNames) {
      if (compiler.getSourceFileByName(outputFileName) != null) {
        compiler.report(
            JSError.make(OUTPUT_SAME_AS_INPUT_ERROR, outputFileName));
        return 1;
      }
    }

    return processResults(result, modules, options);
  }
@ GwtIncompatible ( "Unnecessary" ) protected int doRun ( ) throws IOException { Compiler . setLoggingLevel ( Level . parse ( config . loggingLevel ) ) ; compiler = createCompiler ( ) ; B options = createOptions ( ) ; setRunOptions ( options ) ; List < SourceFile > externs = createExterns ( options ) ; List < JSModule > modules = null ; Result result = null ; rootRelativePathsMap = constructRootRelativePathsMap ( ) ; boolean writeOutputToFile = ! config . jsOutputFile . isEmpty ( ) ; List < String > outputFileNames = new ArrayList < > ( ) ; if ( writeOutputToFile ) { outputFileNames . add ( config . jsOutputFile ) ; } boolean createCommonJsModules = false ; if ( options . processCommonJSModules && ( config . module . size ( ) == 1 && "auto" . equals ( config . module . get ( 0 ) ) ) ) { createCommonJsModules = true ; config . module . remove ( 0 ) ; } List < JsModuleSpec > jsModuleSpecs = new ArrayList < > ( ) ; for ( int i = 0 ; i < config . module . size ( ) ; i ++ ) { jsModuleSpecs . add ( JsModuleSpec . create ( config . module . get ( i ) , i == 0 ) ) ; } List < JsonFileSpec > jsonFiles = null ; if ( config . jsonStreamMode == JsonStreamMode . IN || config . jsonStreamMode == JsonStreamMode . BOTH ) { jsonFiles = parseJsonFilesFromInputStream ( ) ; ImmutableMap . Builder < String , SourceMapInput > inputSourceMaps = new ImmutableMap . Builder < > ( ) ; ImmutableMap . Builder < String , String > inputPathByWebpackId = new ImmutableMap . Builder < > ( ) ; boolean foundJsonInputSourceMap = false ; for ( JsonFileSpec jsonFile : jsonFiles ) { if ( jsonFile . getSourceMap ( ) != null && jsonFile . getSourceMap ( ) . length ( ) > 0 ) { String sourceMapPath = jsonFile . getPath ( ) + ".map" ; SourceFile sourceMap = SourceFile . fromCode ( sourceMapPath , jsonFile . getSourceMap ( ) ) ; inputSourceMaps . put ( jsonFile . getPath ( ) , new SourceMapInput ( sourceMap ) ) ; foundJsonInputSourceMap = true ; } if ( jsonFile . getWebpackId ( ) != null ) { inputPathByWebpackId . put ( jsonFile . getWebpackId ( ) , jsonFile . getPath ( ) ) ; } } if ( foundJsonInputSourceMap ) { inputSourceMaps . putAll ( options . inputSourceMaps ) ; options . inputSourceMaps = inputSourceMaps . build ( ) ; } compiler . initWebpackMap ( inputPathByWebpackId . build ( ) ) ; } else { ImmutableMap < String , String > emptyMap = ImmutableMap . of ( ) ; compiler . initWebpackMap ( emptyMap ) ; } compiler . initWarningsGuard ( options . getWarningsGuard ( ) ) ; List < SourceFile > inputs = createSourceInputs ( jsModuleSpecs , config . mixedJsSources , jsonFiles , config . moduleRoots ) ; if ( ! jsModuleSpecs . isEmpty ( ) ) { if ( isInTestMode ( ) ) { modules = modulesSupplierForTesting . get ( ) ; } else { if ( JsonStreamMode . IN . equals ( config . jsonStreamMode ) || JsonStreamMode . NONE . equals ( config . jsonStreamMode ) ) { for ( JsModuleSpec m : jsModuleSpecs ) { checkModuleName ( m . getName ( ) ) ; } } modules = createJsModules ( jsModuleSpecs , inputs ) ; } for ( JSModule m : modules ) { outputFileNames . add ( getModuleOutputFileName ( m ) ) ; } compiler . initModules ( externs , modules , options ) ; } else { compiler . init ( externs , inputs , options ) ; } if ( options . printConfig ) { compiler . printConfig ( System . err ) ; } String saveAfterChecksFilename = config . getSaveAfterChecksFileName ( ) ; String continueSavedCompilationFilename = config . getContinueSavedCompilationFileName ( ) ; if ( config . skipNormalOutputs ) { compiler . orderInputsWithLargeStack ( ) ; } else if ( compiler . hasErrors ( ) ) { compiler . generateReport ( ) ; result = compiler . getResult ( ) ; } else if ( options . getInstrumentForCoverageOnly ( ) ) { result = instrumentForCoverage ( ) ; } else if ( saveAfterChecksFilename != null ) { result = performStage1andSave ( saveAfterChecksFilename ) ; } else if ( continueSavedCompilationFilename != null ) { result = restoreAndPerformStage2 ( continueSavedCompilationFilename ) ; if ( modules != null ) { modules = ImmutableList . copyOf ( compiler . getModules ( ) ) ; } } else { result = performFullCompilation ( ) ; } if ( createCommonJsModules ) { modules = ImmutableList . copyOf ( compiler . getModules ( ) ) ; for ( JSModule m : modules ) { outputFileNames . add ( getModuleOutputFileName ( m ) ) ; } } for ( String outputFileName : outputFileNames ) { if ( compiler . getSourceFileByName ( outputFileName ) != null ) { compiler . report ( JSError . make ( OUTPUT_SAME_AS_INPUT_ERROR , outputFileName ) ) ; return 1 ; } } return processResults ( result , modules , options ) ; }
Parses command-line arguments and runs the compiler.

@return system exit status