track end of node positions for sourcemaps - fixes douglasduteil/isparta#8

This commit is contained in:
Sebastian McKenzie
2015-02-04 23:10:54 +11:00
parent d6b39bc89b
commit c84af909f7
2 changed files with 4 additions and 3 deletions

View File

@@ -190,7 +190,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
newline(true);
if (opts.before) opts.before();
this.map.mark(node);
this.map.mark(node, "start");
this[node.type](node, this.buildPrint(node), parent);
@@ -200,6 +200,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
}
if (needsParens) this.push(")");
this.map.mark(node, "end");
if (opts.after) opts.after();
newline(false);

View File

@@ -30,7 +30,7 @@ SourceMap.prototype.get = function () {
}
};
SourceMap.prototype.mark = function (node) {
SourceMap.prototype.mark = function (node, type) {
var loc = node.loc;
if (!loc) return; // no location info
@@ -46,7 +46,7 @@ SourceMap.prototype.mark = function (node) {
column: position.column
};
var original = loc.start;
var original = loc[type];
map.addMapping({
source: this.opts.sourceFileName,