Commit b75dd57a authored by yann300's avatar yann300

fix offsetToLineColumn

parent 3840aee8
...@@ -36,7 +36,7 @@ function Debugger (id, sourceHighlighter, localRegistry) { ...@@ -36,7 +36,7 @@ function Debugger (id, sourceHighlighter, localRegistry) {
this.isActive = false this.isActive = false
this.breakPointManager = new remixCore.code.BreakpointManager(this.debugger, (sourceLocation) => { this.breakPointManager = new remixCore.code.BreakpointManager(this.debugger, (sourceLocation) => {
return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.data) return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources)
}) })
this.debugger.setBreakpointManager(this.breakPointManager) this.debugger.setBreakpointManager(this.breakPointManager)
...@@ -74,8 +74,8 @@ function Debugger (id, sourceHighlighter, localRegistry) { ...@@ -74,8 +74,8 @@ function Debugger (id, sourceHighlighter, localRegistry) {
this.debugger.codeManager.event.register('changed', this, function (code, address, index) { this.debugger.codeManager.event.register('changed', this, function (code, address, index) {
if (self._deps.compiler.lastCompilationResult) { if (self._deps.compiler.lastCompilationResult) {
self.debugger.callTree.sourceLocationTracker.getSourceLocationFromInstructionIndex(address, index, self._deps.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) { self.debugger.callTree.sourceLocationTracker.getSourceLocationFromInstructionIndex(address, index, self._deps.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) {
if (!error) { if (!error && self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) {
var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult) var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources)
self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation)
} else { } else {
self._components.sourceHighlighter.currentSourceLocation(null) self._components.sourceHighlighter.currentSourceLocation(null)
......
...@@ -98,7 +98,7 @@ class ContextView { ...@@ -98,7 +98,7 @@ class ContextView {
} }
} }
if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) {
var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult) var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources)
var filename = self._deps.compiler.getSourceName(position.file) var filename = self._deps.compiler.getSourceName(position.file)
// TODO: refactor with rendererAPI.errorClick // TODO: refactor with rendererAPI.errorClick
if (filename !== self._deps.config.get('currentFile')) { if (filename !== self._deps.config.get('currentFile')) {
......
...@@ -114,7 +114,7 @@ class ContextualListener { ...@@ -114,7 +114,7 @@ class ContextualListener {
_highlightInternal (position, node) { _highlightInternal (position, node) {
var self = this var self = this
if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) {
var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult) var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources)
var css = 'highlightreference' var css = 'highlightreference'
if (node.children && node.children.length) { 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. // If node has children, highlight the entire line. if not, just highlight the current source position of the node.
......
...@@ -20,6 +20,7 @@ function staticAnalysisView (localRegistry) { ...@@ -20,6 +20,7 @@ function staticAnalysisView (localRegistry) {
this.runner = new StaticAnalysisRunner() this.runner = new StaticAnalysisRunner()
this.modulesView = renderModules(this.runner.modules()) this.modulesView = renderModules(this.runner.modules())
this.lastCompilationResult = null this.lastCompilationResult = null
this.lastCompilationSource = null
self._components = {} self._components = {}
self._components.registry = localRegistry || globlalRegistry self._components.registry = localRegistry || globlalRegistry
// dependencies // dependencies
...@@ -31,9 +32,11 @@ function staticAnalysisView (localRegistry) { ...@@ -31,9 +32,11 @@ function staticAnalysisView (localRegistry) {
self._deps.compiler.event.register('compilationFinished', function (success, data, source) { self._deps.compiler.event.register('compilationFinished', function (success, data, source) {
self.lastCompilationResult = null self.lastCompilationResult = null
self.lastCompilationSource = null
$('#staticanalysisresult').empty() $('#staticanalysisresult').empty()
if (success) { if (success) {
self.lastCompilationResult = data self.lastCompilationResult = data
self.lastCompilationSource = source
if (self.view.querySelector('#autorunstaticanalysis').checked) { if (self.view.querySelector('#autorunstaticanalysis').checked) {
self.run() self.run()
} }
...@@ -94,7 +97,7 @@ staticAnalysisView.prototype.run = function () { ...@@ -94,7 +97,7 @@ staticAnalysisView.prototype.run = function () {
start: parseInt(split[0]), start: parseInt(split[0]),
length: parseInt(split[1]) length: parseInt(split[1])
} }
location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, file) location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, file, self.lastCompilationSource.sources)
location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':' location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':'
} }
warningCount++ warningCount++
......
...@@ -10,10 +10,10 @@ function offsetToColumnConverter (compilerEvent) { ...@@ -10,10 +10,10 @@ function offsetToColumnConverter (compilerEvent) {
}) })
} }
offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, compilationResult) { offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, sources) {
if (!this.lineBreakPositionsByContent[file]) { if (!this.lineBreakPositionsByContent[file]) {
var filename = Object.keys(compilationResult.data.sources)[file] var filename = Object.keys(sources)[file]
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(compilationResult.source.sources[filename].content) this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content)
} }
return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file])
} }
......
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