mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fixing #934 (at least partially).
This commit is contained in:
parent
3c558ebbee
commit
76e11e6f64
5 changed files with 15 additions and 4 deletions
|
@ -604,7 +604,7 @@
|
|||
HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/;
|
||||
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
|
||||
WHITESPACE = /^[^\n\S]+/;
|
||||
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*\n|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/;
|
||||
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/;
|
||||
CODE = /^[-=]>/;
|
||||
MULTI_DENT = /^(?:\n[^\n\S]*)+/;
|
||||
SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/;
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
};
|
||||
Base.prototype.containsPureStatement = function() {
|
||||
return this.isPureStatement() || this.contains(function(node) {
|
||||
return node.isPureStatement();
|
||||
return node.isPureStatement() && !(node instanceof Comment);
|
||||
});
|
||||
};
|
||||
Base.prototype.toString = function(idt, name) {
|
||||
|
|
|
@ -550,7 +550,7 @@ OPERATOR = /// ^ (
|
|||
|
||||
WHITESPACE = /^[^\n\S]+/
|
||||
|
||||
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*\n|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/
|
||||
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/
|
||||
|
||||
CODE = /^[-=]>/
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ exports.Base = class Base
|
|||
# Convenience for the most common use of contains. Does the node contain
|
||||
# a pure statement?
|
||||
containsPureStatement: ->
|
||||
@isPureStatement() or @contains (node) -> node.isPureStatement()
|
||||
@isPureStatement() or @contains (node) ->
|
||||
node.isPureStatement() and node not instanceof Comment
|
||||
|
||||
# `toString` representation of the node, for inspecting the parse tree.
|
||||
# This is what `coffee --nodes` prints out.
|
||||
|
|
|
@ -199,3 +199,13 @@ test "block comments inside class bodies", ->
|
|||
b: ->
|
||||
|
||||
ok B.prototype.a instanceof Function
|
||||
|
||||
test "#934, block comments inside conditional bodies", ->
|
||||
|
||||
eq undefined, (if true
|
||||
###
|
||||
block comment
|
||||
###
|
||||
else
|
||||
# comment
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue