diff options
Diffstat (limited to 'lib/sourcemap.js')
-rw-r--r-- | lib/sourcemap.js | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/sourcemap.js b/lib/sourcemap.js index 6cbce5e1..da4ab4fe 100644 --- a/lib/sourcemap.js +++ b/lib/sourcemap.js @@ -45,16 +45,30 @@ function SourceMap(options) { options = defaults(options, { file : null, - root : null + root : null, + orig : null, }); var generator = new MOZ_SourceMap.SourceMapGenerator({ file : options.file, sourceRoot : options.root }); + var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig); function add(source, gen_line, gen_col, orig_line, orig_col, name) { + orig_line++; + gen_line++; + if (orig_map) { + var info = orig_map.originalPositionFor({ + line: orig_line, + column: orig_col + }); + source = info.source; + orig_line = info.line; + orig_col = info.column; + name = info.name; + } generator.addMapping({ - generated : { line: gen_line + 1, column: gen_col }, - original : { line: orig_line + 1, column: orig_col }, + generated : { line: gen_line, column: gen_col }, + original : { line: orig_line, column: orig_col }, source : source, name : name }); @@ -65,15 +79,3 @@ function SourceMap(options) { toString : function() { return generator.toString() } }; }; - -function SourceMapInput(map) { - map = new MOZ_SourceMap.SourceMapConsumer(map); - return { - info: function(line, col) { - return map.originalPositionFor({ - line: line, - column: col - }); - } - }; -}; |