Skip to content

Commit

Permalink
Never let JSDoc from one statement spill into the next statement.
Browse files Browse the repository at this point in the history
See
http://code.google.com/p/closure-compiler/issues/detail?id=428
for more info

Committed by Nick Santos
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=26339541
  • Loading branch information
Nick Santos authored and hns committed May 9, 2012
1 parent 2bb5493 commit af4a9af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/org/mozilla/javascript/Parser.java
Expand Up @@ -2075,7 +2075,7 @@ private AstNode assignExpr()
if (jsdocNode != null) {
pn.setJsDocNode(jsdocNode);
}
} else if (tt == Token.SEMI && pn.getType() == Token.GETPROP) {
} else if (tt == Token.SEMI) {
// This may be dead code added intentionally, for JSDoc purposes.
// For example: /** @type Number */ C.prototype.x;
if (currentJsDocComment != null) {
Expand Down
9 changes: 9 additions & 0 deletions testsrc/org/mozilla/javascript/tests/ParserTest.java
Expand Up @@ -931,6 +931,15 @@ public void testJSDocAttachment9() {
.getExpression().getJsDoc());
}

public void testJSDocAttachment15() {
AstRoot root = parse("/** @private */ x(); function f() {}");
assertNotNull(root.getComments());
assertEquals(1, root.getComments().size());

ExpressionStatement st = (ExpressionStatement) root.getFirstChild();
assertNotNull(st.getExpression().getJsDoc());
}

public void testParsingWithoutJSDoc() {
AstRoot root = parse("var a = /** @type number */(x);", false);
assertNotNull(root.getComments());
Expand Down

0 comments on commit af4a9af

Please sign in to comment.