Skip to content

Commit

Permalink
Combining CheckJsDoc and Es6CheckModule passes in DefaultPassConfig.j…
Browse files Browse the repository at this point in the history
…ava.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164292919
  • Loading branch information
hjkaria authored and dimvar committed Aug 4, 2017
1 parent 851a4a4 commit 775c334
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Expand Up @@ -249,8 +249,8 @@ protected List<PassFactory> getChecks() {
checks.add(chromePass); checks.add(chromePass);
} }


// Verify JsDoc annotations // Verify JsDoc annotations and check ES6 modules
checks.add(checkJsDoc); checks.add(checkJsDocAndEs6Modules);


if (options.needsTranspilationFrom(TYPESCRIPT)) { if (options.needsTranspilationFrom(TYPESCRIPT)) {
checks.add(convertEs6TypedToEs6); checks.add(convertEs6TypedToEs6);
Expand All @@ -270,8 +270,6 @@ protected List<PassFactory> getChecks() {
checks.add(checkRequires); checks.add(checkRequires);
} }


checks.add(es6CheckModule);

if (options.needsTranspilationOf(FeatureSet.Feature.MODULES)) { if (options.needsTranspilationOf(FeatureSet.Feature.MODULES)) {
TranspilationPasses.addEs6ModulePass(checks); TranspilationPasses.addEs6ModulePass(checks);
} }
Expand Down Expand Up @@ -1110,8 +1108,8 @@ private void assertValidOrderForChecks(List<PassFactory> checks) {
assertPassOrder( assertPassOrder(
checks, checks,
chromePass, chromePass,
checkJsDoc, checkJsDocAndEs6Modules,
"The ChromePass must run before after JsDoc checking."); "The ChromePass must run before after JsDoc and Es6 module checking.");
assertPassOrder( assertPassOrder(
checks, checks,
closureRewriteModule, closureRewriteModule,
Expand Down Expand Up @@ -1219,12 +1217,16 @@ protected FeatureSet featureSet() {
"JSC_GENERATE_EXPORTS_ERROR", "JSC_GENERATE_EXPORTS_ERROR",
"Exports can only be generated if export symbol/property functions are set."); "Exports can only be generated if export symbol/property functions are set.");


/** Verifies JSDoc annotations are used properly. */ /** Verifies JSDoc annotations are used properly and checks for ES6 modules. */
private final HotSwapPassFactory checkJsDoc = private final HotSwapPassFactory checkJsDocAndEs6Modules =
new HotSwapPassFactory("checkJsDoc", true) { new HotSwapPassFactory("checkJsDocAndEs6Modules", true) {
@Override @Override
protected HotSwapCompilerPass create(AbstractCompiler compiler) { protected HotSwapCompilerPass create(AbstractCompiler compiler) {
return new CheckJSDoc(compiler); ImmutableList.Builder<Callback> callbacks =
ImmutableList.<Callback>builder()
.add(new CheckJSDoc(compiler))
.add(new Es6CheckModule(compiler));
return combineChecks(compiler, callbacks.build());
} }


@Override @Override
Expand Down Expand Up @@ -1450,19 +1452,6 @@ protected FeatureSet featureSet() {
} }
}; };


private final HotSwapPassFactory es6CheckModule =
new HotSwapPassFactory("es6CheckModule", true) {
@Override
protected HotSwapCompilerPass create(AbstractCompiler compiler) {
return new Es6CheckModule(compiler);
}

@Override
protected FeatureSet featureSet() {
return ES8_MODULES;
}
};

/** Desugars ES6_TYPED features into ES6 code. */ /** Desugars ES6_TYPED features into ES6 code. */
final HotSwapPassFactory convertEs6TypedToEs6 = final HotSwapPassFactory convertEs6TypedToEs6 =
new HotSwapPassFactory("convertEs6Typed", true) { new HotSwapPassFactory("convertEs6Typed", true) {
Expand Down

0 comments on commit 775c334

Please sign in to comment.