Skip to content

Commit

Permalink
Allow aliases like "var MSG_SOMETHING = some.namespace.MSG_SOMETHING"…
Browse files Browse the repository at this point in the history
… in JsMessageVisitor

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128022782
  • Loading branch information
tbreisacher authored and blickly committed Jul 21, 2016
1 parent a0d1f55 commit 2e8835f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/JsMessageVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void visit(NodeTraversal traversal, Node node, Node parent) {
return;
}

if (node.isAssign()
if ((node.isAssign() || node.isName())
&& msgNode.isQualifiedName()
&& msgNode.getLastChild().getString().equals(messageKey)) {
// foo.Thing.MSG_EXAMPLE = bar.OtherThing.MSG_EXAMPLE;
Expand Down
5 changes: 5 additions & 0 deletions test/com/google/javascript/jscomp/JsMessageVisitorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ public void testInvalidJsMessageOnObjLit() {
assertError(compiler.getErrors()[0]).hasType(JsMessageVisitor.MESSAGE_TREE_MALFORMED);
}

public void testJsMessageOnRHSOfVar() {
extractMessagesSafely("var MSG_MENU_MARK_AS_UNREAD = a.name.space.MSG_MENU_MARK_AS_UNREAD;");
assertThat(messages).isEmpty();
}

public void testOrphanedJsMessage() {
extractMessagesSafely("goog.getMsg('a')");
assertThat(compiler.getWarnings()).hasLength(1);
Expand Down

0 comments on commit 2e8835f

Please sign in to comment.