Commit 61c96866 authored by Iuri Matias's avatar Iuri Matias

move source highlighter out of debugger

parent e3a5255f
...@@ -8,14 +8,13 @@ var globalRegistry = require('../../global/registry') ...@@ -8,14 +8,13 @@ var globalRegistry = require('../../global/registry')
/** /**
* Manage remix and source highlighting * Manage remix and source highlighting
*/ */
function Debugger (sourceHighlighter) { function Debugger () {
var self = this var self = this
this.event = new EventManager() this.event = new EventManager()
this.sourceHighlighter = sourceHighlighter
this.registry = globalRegistry this.registry = globalRegistry
this.offsetToLineColumnConverter = this.registry.get('offsettolinecolumnconverter').api, this.offsetToLineColumnConverter = this.registry.get('offsettolinecolumnconverter').api
this.editor = this.registry.get('editor').api, this.editor = this.registry.get('editor').api
this.compiler = this.registry.get('compiler').api this.compiler = this.registry.get('compiler').api
this.debugger = new Ethdebugger( this.debugger = new Ethdebugger(
...@@ -63,7 +62,6 @@ function Debugger (sourceHighlighter) { ...@@ -63,7 +62,6 @@ function Debugger (sourceHighlighter) {
}) })
this.debugger.event.register('traceUnloaded', this, function () { this.debugger.event.register('traceUnloaded', this, function () {
self.sourceHighlighter.currentSourceLocation(null)
self.event.trigger('debuggerStatus', [false]) self.event.trigger('debuggerStatus', [false])
}) })
...@@ -78,19 +76,18 @@ function Debugger (sourceHighlighter) { ...@@ -78,19 +76,18 @@ function Debugger (sourceHighlighter) {
Debugger.prototype.registerAndHighlightCodeItem = function (index) { Debugger.prototype.registerAndHighlightCodeItem = function (index) {
const self = this const self = this
// register selected code item, highlight the corresponding source location // register selected code item, highlight the corresponding source location
if (self.compiler.lastCompilationResult) { if (!self.compiler.lastCompilationResult) return
self.debugger.traceManager.getCurrentCalledAddressAt(index, (error, address) => { self.debugger.traceManager.getCurrentCalledAddressAt(index, (error, address) => {
if (error) return console.log(error) if (error) return console.log(error)
self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, self.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) { self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, self.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) {
if (!error && self.compiler.lastCompilationResult && self.compiler.lastCompilationResult.data) { if (!error && self.compiler.lastCompilationResult && self.compiler.lastCompilationResult.data) {
var lineColumnPos = self.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self.compiler.lastCompilationResult.source.sources) var lineColumnPos = self.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self.compiler.lastCompilationResult.source.sources)
self.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) self.event.trigger('newSourceLocation', [lineColumnPos, rawLocation])
} else { } else {
self.sourceHighlighter.currentSourceLocation(null) self.event.trigger('newSourceLocation', [null])
} }
}) })
}) })
}
} }
module.exports = Debugger module.exports = Debugger
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