diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index fb681bce03..9d95854307 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -5,9 +5,6 @@ var EventManager = remixLib.EventManager var executionContext = require('../../execution-context') var globalRegistry = require('../../global/registry') -/** - * Manage remix and source highlighting - */ function Debugger () { var self = this this.event = new EventManager() @@ -40,26 +37,10 @@ function Debugger () { this.debugger.setBreakpointManager(this.breakPointManager) - self._deps.editor.event.register('breakpointCleared', (fileName, row) => { - this.breakPointManager.remove({fileName: fileName, row: row}) - }) - - self._deps.editor.event.register('breakpointAdded', (fileName, row) => { - this.breakPointManager.add({fileName: fileName, row: row}) - }) - executionContext.event.register('contextChanged', this, function (context) { self.switchProvider(context) }) - // unload if a file has changed (but not if tabs were switched) - self._deps.editor.event.register('contentChanged', function () { - self.debugger.unLoad() - }) - - // - // ==================== - // listen to events this.debugger.event.register('newTraceLoaded', this, function () { self.event.trigger('debuggerStatus', [true]) }) @@ -68,8 +49,6 @@ function Debugger () { self.event.trigger('debuggerStatus', [false]) }) - // ==================== - // add providers this.debugger.addProvider('vm', executionContext.vm()) this.debugger.addProvider('injected', executionContext.internalWeb3()) this.debugger.addProvider('web3', executionContext.internalWeb3()) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index f6e495f1e0..716acd6a2b 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -14,6 +14,8 @@ var traceHelper = remixLib.helpers.trace var VmDebuggerLogic = require('./VmDebugger') +var globalRegistry = require('../../global/registry') + var yo = require('yo-yo') var csjs = require('csjs-inject') @@ -59,9 +61,29 @@ class DebuggerUI { container.appendChild(this.render()) + this.registry = globalRegistry + this.setEditor() this.listenToEvents() } + setEditor () { + const self = this + this.editor = this.registry.get('editor').api + + self.editor.event.register('breakpointCleared', (fileName, row) => { + self.transactionDebugger.breakPointManager.remove({fileName: fileName, row: row}) + }) + + self.editor.event.register('breakpointAdded', (fileName, row) => { + self.transactionDebugger.breakPointManager.add({fileName: fileName, row: row}) + }) + + // unload if a file has changed (but not if tabs were switched) + self.editor.event.register('contentChanged', function () { + self.transactionDebugger.debugger.unLoad() + }) + } + listenToEvents () { const self = this this.transactionDebugger.event.register('debuggerStatus', function (isActive) { @@ -77,7 +99,7 @@ class DebuggerUI { self.transactionDebugger.registerAndHighlightCodeItem(index) }) - this.event.register('newSourceLocation', function (lineColumnPos, rawLocation) { + this.transactionDebugger.event.register('newSourceLocation', function (lineColumnPos, rawLocation) { self.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) }) }