Add more descriptive line numbers to node toString()
This commit is contained in:
parent
c407a0bf19
commit
b9ebcbf555
|
@ -122,14 +122,16 @@
|
|||
};
|
||||
|
||||
Base.prototype.toString = function(idt, name) {
|
||||
var location, tree, _ref2;
|
||||
var firstLine, lastLine, location, tree, _ref2, _ref3;
|
||||
if (idt == null) {
|
||||
idt = '';
|
||||
}
|
||||
if (name == null) {
|
||||
name = this.constructor.name;
|
||||
}
|
||||
location = (((_ref2 = this.locationData) != null ? _ref2.first_line : void 0) || "unknown") + ": ";
|
||||
firstLine = ((_ref2 = this.locationData) != null ? _ref2.first_line : void 0) || "unknown";
|
||||
lastLine = ((_ref3 = this.locationData) != null ? _ref3.last_line : void 0) || "unknown";
|
||||
location = firstLine + (lastLine !== firstLine ? "-" + lastLine : "") + ": ";
|
||||
tree = '\n' + idt + location + name;
|
||||
if (this.soak) {
|
||||
tree += '?';
|
||||
|
|
|
@ -108,7 +108,9 @@ exports.Base = class Base
|
|||
# `toString` representation of the node, for inspecting the parse tree.
|
||||
# This is what `coffee --nodes` prints out.
|
||||
toString: (idt = '', name = @constructor.name) ->
|
||||
location = (@locationData?.first_line || "unknown") + ": "
|
||||
firstLine = @locationData?.first_line || "unknown"
|
||||
lastLine = @locationData?.last_line || "unknown"
|
||||
location = firstLine + (if lastLine != firstLine then "-" + lastLine else "") + ": "
|
||||
tree = '\n' + idt + location + name
|
||||
tree += '?' if @soak
|
||||
@eachChild (node) -> tree += node.toString idt + TAB
|
||||
|
|
Loading…
Reference in New Issue