public static void addPostCheckTranspilationPasses ( List < PassFactory > passes , CompilerOptions options ) { if ( options . needsTranspilationFrom ( FeatureSet . ES_NEXT ) ) { passes . add ( rewriteCatchWithNoBinding ) ; } if ( options . needsTranspilationFrom ( ES2018 ) ) { passes . add ( rewriteAsyncIteration ) ; passes . add ( rewriteObjectSpread ) ; } if ( options . needsTranspilationFrom ( ES8 ) ) { // Trailing commas in parameter lists are flagged as present by the parser, // but never actually represented in the AST. // The only thing we need to do is mark them as not present in the AST. passes . add ( createFeatureRemovalPass ( "markTrailingCommasInParameterListsRemoved" , Feature . TRAILING_COMMA_IN_PARAM_LIST ) ) ; passes . add ( rewriteAsyncFunctions ) ; } if ( options . needsTranspilationFrom ( ES7 ) ) { passes . add ( rewriteExponentialOperator ) ; } if ( options . needsTranspilationFrom ( ES6 ) ) { // TODO(b/73387406): Move passes here as typechecking & other check passes are updated to cope // with the features they transpile and as the passes themselves are updated to propagate type // information to the transpiled code. // Binary and octal literals are effectively transpiled by the parser. // There's no transpilation we can do for the new regexp flags. passes . add ( createFeatureRemovalPass ( "markEs6FeaturesNotRequiringTranspilationAsRemoved" , Feature . BINARY_LITERALS , Feature . OCTAL_LITERALS , Feature . REGEXP_FLAG_U , Feature . REGEXP_FLAG_Y ) ) ; passes . add ( es6NormalizeShorthandProperties ) ; passes . add ( es6RewriteClassExtends ) ; passes . add ( es6ConvertSuper ) ; passes . add ( es6RenameVariablesInParamLists ) ; passes . add ( es6SplitVariableDeclarations ) ; passes . add ( getEs6RewriteDestructuring ( ObjectDestructuringRewriteMode . REWRITE_ALL_OBJECT_PATTERNS ) ) ; passes . add ( es6RewriteArrowFunction ) ; passes . add ( es6ExtractClasses ) ; passes . add ( es6RewriteClass ) ; passes . add ( es6RewriteRestAndSpread ) ; passes . add ( lateConvertEs6ToEs3 ) ; passes . add ( es6ForOf ) ; passes . add ( rewriteBlockScopedFunctionDeclaration ) ; passes . add ( rewriteBlockScopedDeclaration ) ; passes . add ( rewriteGenerators ) ; passes . add ( es6ConvertSuperConstructorCalls ) ; } else if ( options . needsTranspilationOf ( Feature . OBJECT_PATTERN_REST ) ) { passes . add ( es6RenameVariablesInParamLists ) ; passes . add ( es6SplitVariableDeclarations ) ; passes . add ( getEs6RewriteDestructuring ( ObjectDestructuringRewriteMode . REWRITE_OBJECT_REST ) ) ; } }
Adds transpilation passes that should run after all checks are done .