Update source map handling to be reentrant

Rather than repeating the original location when we exit a node, we need to restore the previous parent’s original line location, since the source map format denotes the start location.
This commit is contained in:
kpdecker
2015-12-18 00:16:20 -06:00
parent 9b79fbcdf5
commit 94e7e4da8e
12 changed files with 14 additions and 14 deletions

View File

@@ -46,7 +46,7 @@ export default class Printer extends Buffer {
if (opts.before) opts.before();
this.map.mark(node, "start");
this.map.mark(node);
this._print(node, parent);
@@ -58,7 +58,7 @@ export default class Printer extends Buffer {
if (needsParens) this.push(")");
// end
this.map.mark(node, "end");
if (parent) this.map.mark(parent);
if (opts.after) opts.after();
this.format.concise = oldConcise;

View File

@@ -40,7 +40,7 @@ export default class SourceMap {
* Mark a node's generated position, and add it to the sourcemap.
*/
mark(node, type) {
mark(node) {
let loc = node.loc;
if (!loc) return; // no location info
@@ -56,7 +56,7 @@ export default class SourceMap {
column: position.column
};
let original = loc[type];
let original = loc.start;
// Avoid emitting duplicates on either side. Duplicated
// original values creates unnecesssarily large source maps