in compiler-jx/src/main/java/com/google/javascript/jscomp/RoyaleClosurePassConfig.java [264:525]
protected List<PassFactory> getChecks() {
List<PassFactory> checks = new ArrayList<PassFactory>();
checks.add(gatherGettersAndSetters);
if (options.shouldGenerateTypedExterns()) {
checks.add(closureGoogScopeAliases);
checks.add(closureRewriteClass);
checks.add(generateIjs);
checks.add(whitespaceWrapGoogModules);
return checks;
}
checks.add(createEmptyPass("beforeStandardChecks"));
if (options.processCommonJSModules) {
checks.add(rewriteCommonJsModules);
} else if (options.getLanguageIn().toFeatureSet().has(FeatureSet.Feature.MODULES)) {
checks.add(rewriteScriptsToEs6Modules);
}
// Note: ChromePass can rewrite invalid @type annotations into valid ones, so should run before
// JsDoc checks.
if (options.isChromePassEnabled()) {
checks.add(chromePass);
}
// Verify JsDoc annotations and check ES6 modules
checks.add(checkJsDocAndEs6Modules);
if (options.needsTranspilationFrom(TYPESCRIPT)) {
checks.add(convertEs6TypedToEs6);
}
checks.add(gatherModuleMetadataPass);
if (options.enables(DiagnosticGroups.LINT_CHECKS)) {
checks.add(lintChecks);
}
if (options.closurePass && options.enables(DiagnosticGroups.LINT_CHECKS)) {
checks.add(checkRequiresAndProvidesSorted);
}
if (options.enables(DiagnosticGroups.MISSING_REQUIRE)
|| options.enables(DiagnosticGroups.STRICT_MISSING_REQUIRE)
|| options.enables(DiagnosticGroups.EXTRA_REQUIRE)) {
checks.add(checkRequires);
}
checks.add(checkVariableReferences);
if (options.getLanguageIn().toFeatureSet().has(FeatureSet.Feature.MODULES)) {
checks.add(rewriteGoogJsImports);
TranspilationPasses.addEs6ModulePass(checks, preprocessorSymbolTableFactory);
}
checks.add(checkStrictMode);
if (options.closurePass) {
checks.add(closureCheckModule);
checks.add(closureRewriteModule);
}
if (options.declaredGlobalExternsOnWindow) {
checks.add(declaredGlobalExternsOnWindow);
}
checks.add(checkSuper);
if (options.closurePass) {
checks.add(closureGoogScopeAliases);
checks.add(closureRewriteClass);
}
checks.add(checkSideEffects);
if (options.enables(DiagnosticGroups.MISSING_PROVIDE)) {
checks.add(checkProvides);
}
if (options.angularPass) {
checks.add(angularPass);
}
if (preventRenameMxmlSymbolReferences) {
checks.add(findRoyaleMxmlPropertiesToKeep);
}
checks.add(keepRoyalePropertyNamesPass);
if (extraSymbolNamesToExport != null) {
checks.add(generateRoyaleExports);
}
if (!options.generateExportsAfterTypeChecking && options.generateExports) {
checks.add(generateExports);
}
if (options.exportTestFunctions) {
checks.add(exportTestFunctions);
}
if (options.closurePass) {
checks.add(closurePrimitives);
}
// It's important that the PolymerPass run *after* the ClosurePrimitives and ChromePass rewrites
// and *before* the suspicious code checks. This is enforced in the assertValidOrder method.
if (options.polymerVersion != null) {
checks.add(polymerPass);
}
if (options.checkSuspiciousCode
|| options.enables(DiagnosticGroups.GLOBAL_THIS)
|| options.enables(DiagnosticGroups.DEBUGGER_STATEMENT_PRESENT)) {
checks.add(suspiciousCode);
}
if (options.closurePass && options.checkMissingGetCssNameLevel.isOn()) {
checks.add(closureCheckGetCssName);
}
if (options.syntheticBlockStartMarker != null) {
// This pass must run before the first fold constants pass.
checks.add(createSyntheticBlocks);
}
checks.add(checkVars);
if (options.inferConsts) {
checks.add(inferConsts);
}
if (options.computeFunctionSideEffects) {
checks.add(checkRegExp);
}
// This pass should run before types are assigned.
if (options.processObjectPropertyString) {
checks.add(objectPropertyStringPreprocess);
}
// It's important that the Dart super accessors pass run *before* es6ConvertSuper,
// which is a "late" ES6 pass. This is enforced in the assertValidOrder method.
if (options.dartPass && !options.getOutputFeatureSet().contains(ES6)) {
checks.add(dartSuperAccessorsPass);
}
// Passes running before this point should expect to see language features up to ES_2017.
checks.add(createEmptyPass(PassNames.BEFORE_ES_2017_TRANSPILATION));
TranspilationPasses.addPreTypecheckTranspilationPasses(checks, options);
if (options.rewritePolyfills && !options.checksOnly) {
TranspilationPasses.addRewritePolyfillPass(checks);
}
checks.add(injectRuntimeLibraries);
checks.add(createEmptyPass(PassNames.BEFORE_TYPE_CHECKING));
addTypeCheckerPasses(checks, options);
if (options.j2clPassMode.shouldAddJ2clPasses()) {
checks.add(j2clSourceFileChecker);
}
if (!options.disables(DiagnosticGroups.CHECK_USELESS_CODE)
|| !options.disables(DiagnosticGroups.MISSING_RETURN)) {
checks.add(checkControlFlow);
}
/* The AS compiler should have checked the same thing
* that CheckAccessControls checks. CheckAccessControls
* also outputs false positives when compiling modules.
// CheckAccessControls only works if check types is on.
if (options.isTypecheckingEnabled()
&& (!options.disables(DiagnosticGroups.ACCESS_CONTROLS)
|| options.enables(DiagnosticGroups.CONSTANT_PROPERTY))) {
checks.add(checkAccessControls);
}
*/
/* The AS compiler should have checked the same thing
* that CheckConsts checks. CheckConsts
* also outputs false positives when compiling modules.
checks.add(checkConsts);
*/
// Analyzer checks must be run after typechecking.
if (options.enables(DiagnosticGroups.ANALYZER_CHECKS) && options.isTypecheckingEnabled()) {
checks.add(analyzerChecks);
}
if (options.checkGlobalNamesLevel.isOn()) {
checks.add(checkGlobalNames);
}
if (!options.getConformanceConfigs().isEmpty()) {
checks.add(checkConformance);
}
// Replace 'goog.getCssName' before processing defines but after the
// other checks have been done.
if (options.closurePass && !options.shouldPreserveGoogLibraryPrimitives()) {
checks.add(closureReplaceGetCssName);
}
if (options.getTweakProcessing().isOn()) {
checks.add(processTweaks);
}
if (options.instrumentationTemplate != null || options.recordFunctionInformation) {
checks.add(computeFunctionNames);
}
if (options.checksOnly) {
// Run process defines here so that warnings/errors from that pass are emitted as part of
// checks.
// TODO(rluble): Split process defines into two stages, one that performs only checks to be
// run here, and the one that actually changes the AST that would run in the optimization
// phase.
checks.add(processDefines);
}
if (options.j2clPassMode.shouldAddJ2clPasses()) {
checks.add(j2clChecksPass);
}
if (options.shouldRunTypeSummaryChecksLate()) {
checks.add(generateIjs);
}
// When options.generateExportsAfterTypeChecking is true, run GenerateExports after
// both type checkers, not just after NTI.
if (options.generateExportsAfterTypeChecking && options.generateExports) {
checks.add(generateExports);
}
checks.add(createEmptyPass(PassNames.AFTER_STANDARD_CHECKS));
if (!options.checksOnly) {
// At this point all checks have been done.
// There's no need to complete transpilation if we're only running checks.
TranspilationPasses.addPostCheckTranspilationPasses(checks, options);
if (options.needsTranspilationFrom(ES6)) {
// This pass used to be necessary to make the typechecker happy with class-side inheritance.
// It's not necessary for typechecking now that class transpilation is post-typechecking,
// but it turned out to be necessary to avoid CollapseProperties breaking static inheritance
// TODO(b/116054203): try to only run this pass when property collapsing is enabled during
// the optimizations. Even better, find a way to get rid of this pass completely.
checks.add(convertStaticInheritance);
}
}
assertAllOneTimePasses(checks);
assertValidOrderForChecks(checks);
return checks;
}