fix offsetToLineColumn

pull/1/head
yann300 6 years ago
parent 3840aee8c9
commit b75dd57a09
  1. 6
      src/app/debugger/debugger.js
  2. 2
      src/app/editor/contextView.js
  3. 2
      src/app/editor/contextualListener.js
  4. 5
      src/app/staticanalysis/staticAnalysisView.js
  5. 6
      src/lib/offsetToLineColumnConverter.js

@ -36,7 +36,7 @@ function Debugger (id, sourceHighlighter, localRegistry) {
this.isActive = false
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)
@ -74,8 +74,8 @@ function Debugger (id, sourceHighlighter, localRegistry) {
this.debugger.codeManager.event.register('changed', this, function (code, address, index) {
if (self._deps.compiler.lastCompilationResult) {
self.debugger.callTree.sourceLocationTracker.getSourceLocationFromInstructionIndex(address, index, self._deps.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) {
if (!error) {
var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult)
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)
self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation)
} else {
self._components.sourceHighlighter.currentSourceLocation(null)

@ -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)
var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources)
var filename = self._deps.compiler.getSourceName(position.file)
// TODO: refactor with rendererAPI.errorClick
if (filename !== self._deps.config.get('currentFile')) {

@ -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)
var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.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.

@ -20,6 +20,7 @@ function staticAnalysisView (localRegistry) {
this.runner = new StaticAnalysisRunner()
this.modulesView = renderModules(this.runner.modules())
this.lastCompilationResult = null
this.lastCompilationSource = null
self._components = {}
self._components.registry = localRegistry || globlalRegistry
// dependencies
@ -31,9 +32,11 @@ function staticAnalysisView (localRegistry) {
self._deps.compiler.event.register('compilationFinished', function (success, data, source) {
self.lastCompilationResult = null
self.lastCompilationSource = null
$('#staticanalysisresult').empty()
if (success) {
self.lastCompilationResult = data
self.lastCompilationSource = source
if (self.view.querySelector('#autorunstaticanalysis').checked) {
self.run()
}
@ -94,7 +97,7 @@ staticAnalysisView.prototype.run = function () {
start: parseInt(split[0]),
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) + ':'
}
warningCount++

@ -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]) {
var filename = Object.keys(compilationResult.data.sources)[file]
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(compilationResult.source.sources[filename].content)
var filename = Object.keys(sources)[file]
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content)
}
return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file])
}

Loading…
Cancel
Save