From 5bdf78d5ec406a1b4d2767d674cbdfa54db8e26b Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 10 Aug 2010 23:02:24 -0400 Subject: [PATCH] Fixes Issue #573. Herecomments inside of class literals. --- lib/nodes.js | 2 +- lib/rewriter.js | 3 +++ src/nodes.coffee | 2 +- src/rewriter.coffee | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/nodes.js b/lib/nodes.js index bd0de8a8..cd1776c7 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -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; })(); diff --git a/lib/rewriter.js b/lib/rewriter.js index 1226064b..35ce28c0 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -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) { diff --git a/src/nodes.coffee b/src/nodes.coffee index 2c2ba3aa..e813378d 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -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 diff --git a/src/rewriter.coffee b/src/rewriter.coffee index 9198a82c..cd71afc0 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -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) ->