AbstractCommandLineRunner: Refactor to allow for save/restore implementation.
@@ -1092,19 +1092,23 @@ public abstract class AbstractCommandLineRunner<A extends Compiler,
outputFileNames.add(getModuleOutputFileName(m));
}
- if (config.skipNormalOutputs) {
compiler.initModules(externs, modules, options);
- compiler.orderInputsWithLargeStack();
} else {
- result = performFullCompilationWithModules(options, externs, modules);
+ compiler.init(externs, inputs, options);
}
- } else {
+
+ // TODO(rluble): Add save and restore cases here.
if (config.skipNormalOutputs) {
- compiler.init(externs, inputs, options);
+ // 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 {
- result = performFullCompilation(options, externs, inputs);
- }
+ result = performFullCompilation();
}
if (createCommonJsModules) {
@@ -1127,22 +1131,15 @@ public abstract class AbstractCommandLineRunner<A extends Compiler,
return processResults(result, modules, options);
}
- private Result performFullCompilationWithModules(
- B options, List<SourceFile> externs, List<JSModule> modules) {
+ private Result performFullCompilation() {
+ Result result;
try {
- compiler.initModules(externs, modules, options);
- if (!compiler.hasErrors()) {
compiler.parseForCompilation();
- }
if (!compiler.hasErrors()) {
- if (options.getInstrumentForCoverageOnly()) {
- compiler.instrumentForCoverage();
- } else {
compiler.stage1Passes();
if (!compiler.hasErrors()) {
compiler.stage2Passes();
}
- }
compiler.completeCompilation();
}
} finally {
@@ -1150,33 +1147,22 @@ public abstract class AbstractCommandLineRunner<A extends Compiler,
// exception somewhere.
compiler.generateReport();
}
- return compiler.getResult();
+ result = compiler.getResult();
+ return result;
}
- private Result performFullCompilation(
- B options, List<SourceFile> externs, List<SourceFile> inputs) {
+ private Result instrumentForCoverage() {
+ Result result;
try {
- compiler.init(externs, inputs, options);
- if (!compiler.hasErrors()) {
compiler.parseForCompilation();
- }
if (!compiler.hasErrors()) {
- if (options.getInstrumentForCoverageOnly()) {
compiler.instrumentForCoverage();
- } else {
- compiler.stage1Passes();
- if (!compiler.hasErrors()) {
- compiler.stage2Passes();
- }
- }
- compiler.completeCompilation();
}
} finally {
- // Make sure we generate a report of errors and warnings even if the compiler throws an
- // exception somewhere.
compiler.generateReport();
}
- return compiler.getResult();
+ result = compiler.getResult();
+ return result;
}
/**
