diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 6cd6eb1cc9..2cf969d405 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -39,7 +39,7 @@ function Debugger (container, sourceHighlighter, localRegistry) { this.isActive = false this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, (sourceLocation) => { - return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources) + return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources, this._deps.compiler.lastCompilationResult.data.sources) }, (step) => { this.debugger_ui.stepManager.jumpTo(step) }) @@ -80,7 +80,7 @@ function Debugger (container, sourceHighlighter, localRegistry) { if (error) return console.log(error) self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, self._deps.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) { if (!error && self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { - var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) } else { self._components.sourceHighlighter.currentSourceLocation(null) diff --git a/src/app/editor/contextView.js b/src/app/editor/contextView.js index e4781f6b68..68f861681b 100644 --- a/src/app/editor/contextView.js +++ b/src/app/editor/contextView.js @@ -98,7 +98,7 @@ class ContextView { } } if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { - var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) var filename = self._deps.compiler.getSourceName(position.file) // TODO: refactor with rendererAPI.errorClick if (filename !== self._deps.config.get('currentFile')) { diff --git a/src/app/editor/contextualListener.js b/src/app/editor/contextualListener.js index d55965fd49..0b6848b3b4 100644 --- a/src/app/editor/contextualListener.js +++ b/src/app/editor/contextualListener.js @@ -114,7 +114,7 @@ class ContextualListener { _highlightInternal (position, node) { var self = this if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { - var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) var css = 'highlightreference' if (node.children && node.children.length) { // If node has children, highlight the entire line. if not, just highlight the current source position of the node. diff --git a/src/app/staticanalysis/staticAnalysisView.js b/src/app/staticanalysis/staticAnalysisView.js index 6bb5b56398..498c1de87b 100644 --- a/src/app/staticanalysis/staticAnalysisView.js +++ b/src/app/staticanalysis/staticAnalysisView.js @@ -97,7 +97,7 @@ staticAnalysisView.prototype.run = function () { start: parseInt(split[0]), length: parseInt(split[1]) } - location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, file, self.lastCompilationSource.sources) + location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':' } warningCount++ diff --git a/src/lib/cmdInterpreterAPI.js b/src/lib/cmdInterpreterAPI.js index 321d5692cb..5f6d8bbe8f 100644 --- a/src/lib/cmdInterpreterAPI.js +++ b/src/lib/cmdInterpreterAPI.js @@ -46,7 +46,7 @@ class CmdInterpreterAPI { self._components.sourceHighlighter.currentSourceLocation(null) return } - var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) } debug (hash, cb) { @@ -107,7 +107,7 @@ class CmdInterpreterAPI { self.d.goTo = (row) => { if (self._deps.editor.current()) { var breakPoint = new remixLib.code.BreakpointManager(self.d, (sourceLocation) => { - return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, self._deps.compiler.lastCompilationResult.source.sources) + return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) }) breakPoint.event.register('breakpointHit', (sourceLocation, currentStep) => { self.log(null, 'step index ' + currentStep) diff --git a/src/lib/offsetToLineColumnConverter.js b/src/lib/offsetToLineColumnConverter.js index 2a73dfbe6f..d85d443f89 100644 --- a/src/lib/offsetToLineColumnConverter.js +++ b/src/lib/offsetToLineColumnConverter.js @@ -10,10 +10,15 @@ function offsetToColumnConverter (compilerEvent) { }) } -offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, sources) { +offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, sources, asts) { if (!this.lineBreakPositionsByContent[file]) { - var filename = Object.keys(sources)[file] - this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) + for (var filename in asts) { + var source = asts[filename] + if (source.id === file) { + this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) + break + } + } } return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) }