Fixes Issue #573. Herecomments inside of class literals.

This commit is contained in:
Jeremy Ashkenas 2010-08-10 23:02:24 -04:00
parent 60a4138d50
commit 5bdf78d5ec
4 changed files with 6 additions and 2 deletions

View File

@ -446,7 +446,7 @@
CommentNode.prototype.compileNode = function(o) {
var sep;
sep = '\n' + this.tab;
return "" + (this.tab) + "/*#" + (sep + this.lines.join(sep)) + "\n" + (this.tab) + "*/";
return "" + (this.tab) + "/*" + (sep + this.lines.join(sep)) + "\n" + (this.tab) + "*/";
};
return CommentNode;
})();

View File

@ -154,6 +154,9 @@
one = _c[0];
two = _c[1];
three = _c[2];
if ((this.tag(i + 1) === 'HERECOMMENT' || this.tag(i - 1) === 'HERECOMMENT')) {
return false;
}
return ((('TERMINATOR' === (_d = token[0]) || 'OUTDENT' === _d)) && !((two && two[0] === ':') || (one && one[0] === '@' && three && three[0] === ':'))) || (token[0] === ',' && one && (!('IDENTIFIER' === (_e = one[0]) || 'STRING' === _e || '@' === _e || 'TERMINATOR' === _e || 'OUTDENT' === _e)));
};
action = function(token, i) {

View File

@ -399,7 +399,7 @@ exports.CommentNode = class CommentNode extends BaseNode
compileNode: (o) ->
sep = '\n' + @tab
"#{@tab}/*##{sep + @lines.join(sep) }\n#{@tab}*/"
"#{@tab}/*#{sep + @lines.join(sep) }\n#{@tab}*/"
#### CallNode

View File

@ -136,6 +136,7 @@ exports.Rewriter = class Rewriter
@tokens.splice idx, 0, ['{', '{', token[2]]
condition = (token, i) ->
[one, two, three] = @tokens.slice(i + 1, i + 4)
return false if 'HERECOMMENT' in [@tag(i + 1), @tag(i - 1)]
((token[0] in ['TERMINATOR', 'OUTDENT']) and not ((two and two[0] is ':') or (one and one[0] is '@' and three and three[0] is ':'))) or
(token[0] is ',' and one and (one[0] not in ['IDENTIFIER', 'STRING', '@', 'TERMINATOR', 'OUTDENT']))
action = (token, i) ->