@VisibleForTesting static CompilerOptions getCompilerOptions() { CompilerOptions options = new CompilerOptions(); DependencyOptions deps = new DependencyOptions(); deps.setDependencySorting(true); options.setDependencyOptions(deps); options.setIdeMode(true); options.setCheckSuspiciousCode(true); options.setCheckSymbols(true); options.setCheckTypes(true); options.setClosurePass(true); options.setPreserveGoogRequires(true); options.setWarningLevel(DiagnosticGroups.MISSING_REQUIRE, CheckLevel.ERROR); return options; }
@VisibleForTesting static CompilerOptions createOptions( FileSystem fileSystem, TypeRegistry typeRegistry, DossierCompiler compiler) { CompilerOptions options = new CompilerOptions(); options.setCodingConvention(new ClosureCodingConvention()); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.ADVANCED_OPTIMIZATIONS.setTypeBasedOptimizationOptions(options); // IDE mode must be enabled or all of the jsdoc info will be stripped from the AST. options.setIdeMode(true); // For easier debugging. options.setPrettyPrint(true); ProvidedSymbolsCollectionPass providedNamespacesPass = new ProvidedSymbolsCollectionPass(compiler, typeRegistry, fileSystem); options.addCustomPass(CustomPassExecutionTime.BEFORE_CHECKS, providedNamespacesPass); options.addCustomPass( CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new DocPass(compiler, typeRegistry, fileSystem)); return options; }
@Override void apply(CompilerOptions options, boolean value) { options.setIdeMode(value); }