Skip to content

Commit

Permalink
Edit the text of "Reference to fully qualified import name" warning
Browse files Browse the repository at this point in the history
This is to make it clearer what the intended fix should be in case there is
no "short name" yet.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129680669
  • Loading branch information
blickly committed Aug 8, 2016
1 parent 75d0d95 commit ca17ffe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/com/google/javascript/jscomp/ClosureCheckModule.java
Expand Up @@ -20,7 +20,6 @@
import com.google.javascript.rhino.JSDocInfo; import com.google.javascript.rhino.JSDocInfo;
import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.Token; import com.google.javascript.rhino.Token;

import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


Expand Down Expand Up @@ -91,10 +90,11 @@ public final class ClosureCheckModule extends AbstractModuleCallback
"JSC_REFERENCE_TO_MODULE_GLOBAL_NAME", "JSC_REFERENCE_TO_MODULE_GLOBAL_NAME",
"References to the global name of a module are not allowed. Perhaps you meant exports?"); "References to the global name of a module are not allowed. Perhaps you meant exports?");


static final DiagnosticType REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME = static final DiagnosticType REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME =
DiagnosticType.disabled( DiagnosticType.disabled(
"JSC_REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME", "JSC_REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME",
"Reference to fully qualified import name ''{0}''. Please use the short name instead."); "Reference to fully qualified import name ''{0}''."
+ " Imports in goog.module should use the return value of goog.require instead.");


static final DiagnosticType REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME = static final DiagnosticType REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME =
DiagnosticType.disabled( DiagnosticType.disabled(
Expand Down Expand Up @@ -205,7 +205,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
} else if (shortRequiredNamespaces.containsKey(n.getQualifiedName())) { } else if (shortRequiredNamespaces.containsKey(n.getQualifiedName())) {
String shortName = shortRequiredNamespaces.get(n.getQualifiedName()); String shortName = shortRequiredNamespaces.get(n.getQualifiedName());
if (shortName == null) { if (shortName == null) {
t.report(n, REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME, n.getQualifiedName()); t.report(n, REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME, n.getQualifiedName());
} else { } else {
t.report(n, REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME, t.report(n, REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME,
n.getQualifiedName(), shortName); n.getQualifiedName(), shortName);
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/DiagnosticGroups.java
Expand Up @@ -533,7 +533,7 @@ public DiagnosticGroup forName(String name) {
CheckUnusedLabels.UNUSED_LABEL, CheckUnusedLabels.UNUSED_LABEL,
CheckUselessBlocks.USELESS_BLOCK, CheckUselessBlocks.USELESS_BLOCK,
ClosureCheckModule.LET_GOOG_REQUIRE, ClosureCheckModule.LET_GOOG_REQUIRE,
ClosureCheckModule.REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME, ClosureCheckModule.REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME,
ClosureCheckModule.REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME, ClosureCheckModule.REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME,
ClosureRewriteModule.USELESS_USE_STRICT_DIRECTIVE, ClosureRewriteModule.USELESS_USE_STRICT_DIRECTIVE,
RhinoErrorReporter.JSDOC_MISSING_BRACES_WARNING, RhinoErrorReporter.JSDOC_MISSING_BRACES_WARNING,
Expand Down
10 changes: 5 additions & 5 deletions test/com/google/javascript/jscomp/ClosureCheckModuleTest.java
Expand Up @@ -24,8 +24,8 @@
import static com.google.javascript.jscomp.ClosureCheckModule.MODULE_AND_PROVIDES; import static com.google.javascript.jscomp.ClosureCheckModule.MODULE_AND_PROVIDES;
import static com.google.javascript.jscomp.ClosureCheckModule.MULTIPLE_MODULES_IN_FILE; import static com.google.javascript.jscomp.ClosureCheckModule.MULTIPLE_MODULES_IN_FILE;
import static com.google.javascript.jscomp.ClosureCheckModule.ONE_REQUIRE_PER_DECLARATION; import static com.google.javascript.jscomp.ClosureCheckModule.ONE_REQUIRE_PER_DECLARATION;
import static com.google.javascript.jscomp.ClosureCheckModule.REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME;
import static com.google.javascript.jscomp.ClosureCheckModule.REFERENCE_TO_MODULE_GLOBAL_NAME; import static com.google.javascript.jscomp.ClosureCheckModule.REFERENCE_TO_MODULE_GLOBAL_NAME;
import static com.google.javascript.jscomp.ClosureCheckModule.REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME;
import static com.google.javascript.jscomp.ClosureCheckModule.REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME; import static com.google.javascript.jscomp.ClosureCheckModule.REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME_INCLUDING_SHORT_NAME;
import static com.google.javascript.jscomp.ClosureCheckModule.REQUIRE_NOT_AT_TOP_LEVEL; import static com.google.javascript.jscomp.ClosureCheckModule.REQUIRE_NOT_AT_TOP_LEVEL;


Expand Down Expand Up @@ -358,7 +358,7 @@ public void testIllegalShortImportDestructuring() {
"var {doThing} = goog.require('foo.utils');", "var {doThing} = goog.require('foo.utils');",
"", "",
"exports = function() { return foo.utils.doThing(''); };"), "exports = function() { return foo.utils.doThing(''); };"),
REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME); REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME);
} }


public void testIllegalImportNoAlias() { public void testIllegalImportNoAlias() {
Expand All @@ -369,7 +369,7 @@ public void testIllegalImportNoAlias() {
"goog.require('foo.utils');", "goog.require('foo.utils');",
"", "",
"exports = function() { return foo.utils.doThing(''); };"), "exports = function() { return foo.utils.doThing(''); };"),
REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME); REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME);
} }


// TODO(johnlenz): Re-enable these tests (they are a bit tricky). // TODO(johnlenz): Re-enable these tests (they are a bit tricky).
Expand All @@ -381,7 +381,7 @@ public void disable_testSingleNameImportNoAlias1() {
"goog.require('foo');", "goog.require('foo');",
"", "",
"exports = function() { return foo.doThing(''); };"), "exports = function() { return foo.doThing(''); };"),
REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME); REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME);
} }


public void disable_testSingleNameImportWithAlias() { public void disable_testSingleNameImportWithAlias() {
Expand All @@ -392,7 +392,7 @@ public void disable_testSingleNameImportWithAlias() {
"var bar = goog.require('foo');", "var bar = goog.require('foo');",
"", "",
"exports = function() { return foo.doThing(''); };"), "exports = function() { return foo.doThing(''); };"),
REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME); REFERENCE_TO_FULLY_QUALIFIED_IMPORT_NAME);
} }


public void testSingleNameImportCrossAlias() { public void testSingleNameImportCrossAlias() {
Expand Down

0 comments on commit ca17ffe

Please sign in to comment.