Commit d0c14614 authored by yann300's avatar yann300 Committed by ioedeveloper

check is ast present

parent 075867a5
...@@ -32,6 +32,10 @@ module.exports = class CompilerAbstract { ...@@ -32,6 +32,10 @@ module.exports = class CompilerAbstract {
getSourceName (fileIndex) { getSourceName (fileIndex) {
if (this.data && this.data.sources) { if (this.data && this.data.sources) {
return Object.keys(this.data.sources)[fileIndex] return Object.keys(this.data.sources)[fileIndex]
} else if (Object.keys(this.source.sources).length === 1) {
// if we don't have ast, we return the only one filename present.
const sourcesArray = Object.keys(this.source.sources)
return sourcesArray[0]
} }
return null return null
} }
......
...@@ -19,11 +19,17 @@ export class OffsetToLineColumnConverter extends Plugin { ...@@ -19,11 +19,17 @@ export class OffsetToLineColumnConverter extends Plugin {
offsetToLineColumn (rawLocation, file, sources, asts) { offsetToLineColumn (rawLocation, file, sources, asts) {
if (!this.lineBreakPositionsByContent[file]) { if (!this.lineBreakPositionsByContent[file]) {
for (var filename in asts) { const sourcesArray = Object.keys(sources)
var source = asts[filename] if (!asts && file === 0 && sourcesArray.length === 1) {
if (source.id === file) { // if we don't have ast, we process the only one available content
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[sourcesArray[0]].content)
break } else {
for (var filename in asts) {
var source = asts[filename]
if (source.id === file) {
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content)
break
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment