1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

made --nodes output soak-aware

This commit is contained in:
satyr 2010-09-30 05:29:20 +09:00
parent b5261abb6b
commit 54f162e523
2 changed files with 7 additions and 5 deletions

View file

@ -103,7 +103,7 @@
return this.traverseChildren(true, block);
};
BaseNode.prototype.toString = function(idt, override) {
var _i, _len, _ref2, _result, child, children;
var _i, _len, _ref2, _result, child, children, klass;
idt || (idt = '');
children = (function() {
_result = []; _ref2 = this.collectChildren();
@ -113,7 +113,8 @@
}
return _result;
}).call(this).join('');
return '\n' + idt + (override || this["class"]) + children;
klass = override || this["class"] + (this.soakNode || this.exist ? '?' : '');
return '\n' + idt + klass + children;
};
BaseNode.prototype.eachChild = function(func) {
var _i, _j, _len, _len2, _ref2, _ref3, _result, attr, child;
@ -1302,7 +1303,7 @@
};
OpNode.prototype.isMutator = function() {
var _ref2;
return ends(this.operator, '=') && !(('===' === (_ref2 = this.operator) || '!==' === _ref2));
return ends(this.operator, '=') && !('===' === (_ref2 = this.operator) || '!==' === _ref2);
};
OpNode.prototype.isChainable = function() {
return include(this.CHAINABLE, this.operator);

View file

@ -117,7 +117,8 @@ exports.BaseNode = class BaseNode
toString: (idt, override) ->
idt or= ''
children = (child.toString idt + TAB for child in @collectChildren()).join('')
'\n' + idt + (override or @class) + children
klass = override or @class + if @soakNode or @exist then '?' else ''
'\n' + idt + klass + children
eachChild: (func) ->
return unless @children
@ -1159,7 +1160,7 @@ exports.OpNode = class OpNode extends BaseNode
isComplex: -> @operator isnt '!' or @first.isComplex()
isMutator: ->
ends(@operator, '=') and not (@operator in ['===', '!=='])
ends(@operator, '=') and @operator not in ['===', '!==']
isChainable: ->
include(@CHAINABLE, @operator)