change offsetToLineColumn implementation

pull/3094/head
yann300 6 years ago
parent bc634055c6
commit c5274eb93c
  1. 4
      src/app/debugger/debugger.js
  2. 2
      src/app/editor/contextView.js
  3. 2
      src/app/editor/contextualListener.js
  4. 2
      src/app/staticanalysis/staticAnalysisView.js
  5. 4
      src/lib/cmdInterpreterAPI.js
  6. 9
      src/lib/offsetToLineColumnConverter.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)

@ -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')) {

@ -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.

@ -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++

@ -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)

@ -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]
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])
}

Loading…
Cancel
Save