Skip to content

Commit

Permalink
Remove CheckRequiresAndProvidesSorted in favor of CheckProvidesSorted…
Browse files Browse the repository at this point in the history
… and CheckRequiresSorted.

We can also reenable the disabled tests in ErrorToFixMapperTest, since the linter and suggested fix logic is now the same.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=237321038
  • Loading branch information
tjgq authored and blickly committed Mar 7, 2019
1 parent b2b2346 commit 5af9208
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 743 deletions.
9 changes: 7 additions & 2 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Expand Up @@ -55,7 +55,8 @@
import com.google.javascript.jscomp.lint.CheckNullableReturn;
import com.google.javascript.jscomp.lint.CheckPrimitiveAsObject;
import com.google.javascript.jscomp.lint.CheckPrototypeProperties;
import com.google.javascript.jscomp.lint.CheckRequiresAndProvidesSorted;
import com.google.javascript.jscomp.lint.CheckProvidesSorted;
import com.google.javascript.jscomp.lint.CheckRequiresSorted;
import com.google.javascript.jscomp.lint.CheckUnusedLabels;
import com.google.javascript.jscomp.lint.CheckUselessBlocks;
import com.google.javascript.jscomp.modules.ModuleMapCreator;
Expand Down Expand Up @@ -2074,7 +2075,11 @@ protected FeatureSet featureSet() {
new HotSwapPassFactory("checkRequiresAndProvidesSorted") {
@Override
protected HotSwapCompilerPass create(AbstractCompiler compiler) {
return new CheckRequiresAndProvidesSorted(compiler);
return combineChecks(
compiler,
ImmutableList.of(
new CheckProvidesSorted(CheckProvidesSorted.Mode.COLLECT_AND_REPORT),
new CheckRequiresSorted(CheckRequiresSorted.Mode.COLLECT_AND_REPORT)));
}

@Override
Expand Down
9 changes: 4 additions & 5 deletions src/com/google/javascript/jscomp/DiagnosticGroups.java
Expand Up @@ -41,7 +41,8 @@
import com.google.javascript.jscomp.lint.CheckNullableReturn;
import com.google.javascript.jscomp.lint.CheckPrimitiveAsObject;
import com.google.javascript.jscomp.lint.CheckPrototypeProperties;
import com.google.javascript.jscomp.lint.CheckRequiresAndProvidesSorted;
import com.google.javascript.jscomp.lint.CheckProvidesSorted;
import com.google.javascript.jscomp.lint.CheckRequiresSorted;
import com.google.javascript.jscomp.lint.CheckUnusedLabels;
import com.google.javascript.jscomp.lint.CheckUselessBlocks;
import com.google.javascript.jscomp.modules.ModuleMapCreator;
Expand Down Expand Up @@ -616,10 +617,8 @@ public DiagnosticGroup forName(String name) {
CheckPrimitiveAsObject.NEW_PRIMITIVE_OBJECT,
CheckPrimitiveAsObject.PRIMITIVE_OBJECT_DECLARATION,
CheckPrototypeProperties.ILLEGAL_PROTOTYPE_MEMBER,
CheckRequiresAndProvidesSorted.DUPLICATE_REQUIRE,
CheckRequiresAndProvidesSorted.REQUIRES_NOT_SORTED,
CheckRequiresAndProvidesSorted.PROVIDES_NOT_SORTED,
CheckRequiresAndProvidesSorted.PROVIDES_AFTER_REQUIRES,
CheckProvidesSorted.PROVIDES_NOT_SORTED,
CheckRequiresSorted.REQUIRES_NOT_SORTED,
CheckUnusedLabels.UNUSED_LABEL,
CheckUselessBlocks.USELESS_BLOCK,
ClosureCheckModule.DECLARE_LEGACY_NAMESPACE_IN_NON_MODULE,
Expand Down
6 changes: 4 additions & 2 deletions src/com/google/javascript/jscomp/LintPassConfig.java
Expand Up @@ -26,7 +26,8 @@
import com.google.javascript.jscomp.lint.CheckNullabilityModifiers;
import com.google.javascript.jscomp.lint.CheckPrimitiveAsObject;
import com.google.javascript.jscomp.lint.CheckPrototypeProperties;
import com.google.javascript.jscomp.lint.CheckRequiresAndProvidesSorted;
import com.google.javascript.jscomp.lint.CheckProvidesSorted;
import com.google.javascript.jscomp.lint.CheckRequiresSorted;
import com.google.javascript.jscomp.lint.CheckUnusedLabels;
import com.google.javascript.jscomp.lint.CheckUselessBlocks;
import com.google.javascript.jscomp.parsing.parser.FeatureSet;
Expand Down Expand Up @@ -92,7 +93,8 @@ protected CompilerPass create(AbstractCompiler compiler) {
new CheckPrimitiveAsObject(compiler),
new ClosureCheckModule(compiler, compiler.getModuleMetadataMap()),
new CheckNullabilityModifiers(compiler),
new CheckRequiresAndProvidesSorted(compiler),
new CheckProvidesSorted(CheckProvidesSorted.Mode.COLLECT_AND_REPORT),
new CheckRequiresSorted(CheckRequiresSorted.Mode.COLLECT_AND_REPORT),
new CheckSideEffects(
compiler, /* report */ true, /* protectSideEffectFreeCode */ false),
new CheckTypeImportCodeReferences(compiler),
Expand Down
Expand Up @@ -17,9 +17,9 @@
package com.google.javascript.jscomp.lint;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.javascript.jscomp.lint.CheckRequiresAndProvidesSorted.PROVIDES_NOT_SORTED;

import com.google.common.collect.Iterables;
import com.google.javascript.jscomp.DiagnosticType;
import com.google.javascript.jscomp.NodeTraversal;
import com.google.javascript.rhino.Node;
import java.util.ArrayList;
Expand All @@ -31,6 +31,11 @@
* information to produce a suggested fix.
*/
public final class CheckProvidesSorted implements NodeTraversal.Callback {
public static final DiagnosticType PROVIDES_NOT_SORTED =
DiagnosticType.warning(
"JSC_PROVIDES_NOT_SORTED",
"goog.provide() statements are not sorted."
+ " The correct order is:\n\n{0}\n");

/** Operation modes. */
public enum Mode {
Expand Down

This file was deleted.

Expand Up @@ -17,7 +17,6 @@
package com.google.javascript.jscomp.lint;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.javascript.jscomp.lint.CheckRequiresAndProvidesSorted.REQUIRES_NOT_SORTED;

import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
Expand All @@ -27,6 +26,7 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.errorprone.annotations.Immutable;
import com.google.javascript.jscomp.DiagnosticType;
import com.google.javascript.jscomp.NodeTraversal;
import com.google.javascript.jscomp.NodeUtil;
import com.google.javascript.rhino.JSDocInfo;
Expand All @@ -42,6 +42,11 @@
* are sorted and deduplicated, exposing the necessary information to produce a suggested fix.
*/
public final class CheckRequiresSorted implements NodeTraversal.Callback {
public static final DiagnosticType REQUIRES_NOT_SORTED =
DiagnosticType.warning(
"JSC_REQUIRES_NOT_SORTED",
"goog.require() and goog.requireType() statements are not sorted."
+ " The correct order is:\n\n{0}\n");

/** Operation modes. */
public enum Mode {
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
package com.google.javascript.jscomp.lint;

import static com.google.javascript.jscomp.lint.CheckRequiresAndProvidesSorted.PROVIDES_NOT_SORTED;
import static com.google.javascript.jscomp.lint.CheckProvidesSorted.PROVIDES_NOT_SORTED;

import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions;
Expand Down

0 comments on commit 5af9208

Please sign in to comment.