From b3bd2656e06f3c37d7d9e7a6591e630bc970fc3f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 13:20:22 -0400 Subject: [PATCH] remove logic to set revertPoint and reason from button navigator into caller --- .../debugger/debuggerUI/ButtonNavigator.js | 53 +++++-------------- src/app/debugger/debuggerUI/StepManager.js | 39 ++++++++++++++ 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js index 884880e617..59e09a5328 100644 --- a/src/app/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -49,42 +49,6 @@ function ButtonNavigator (_parent, _traceManager) { this.traceManager = _traceManager this.currentCall = null this.revertionPoint = null - - _parent.event.register('indexChanged', this, (index) => { - if (!this.view) return - if (index < 0) return - if (_parent.currentStepIndex !== index) return - - this.traceManager.buildCallPath(index, (error, callsPath) => { - if (error) { - console.log(error) - resetWarning(this) - } else { - this.currentCall = callsPath[callsPath.length - 1] - if (this.currentCall.reverted) { - this.revertionPoint = this.currentCall.return - this.view.querySelector('#reverted').style.display = 'block' - this.view.querySelector('#reverted #outofgas').style.display = this.currentCall.outOfGas ? 'inline' : 'none' - this.view.querySelector('#reverted #parenthasthrown').style.display = 'none' - } else { - var k = callsPath.length - 2 - while (k >= 0) { - var parent = callsPath[k] - if (parent.reverted) { - this.revertionPoint = parent.return - this.view.querySelector('#reverted').style.display = 'block' - this.view.querySelector('#reverted #parenthasthrown').style.display = parent ? 'inline' : 'none' - this.view.querySelector('#reverted #outofgas').style.display = 'none' - return - } - k-- - } - resetWarning(this) - } - } - }) - }) - this.view } @@ -125,7 +89,7 @@ ButtonNavigator.prototype.reset = function () { this.jumpOutDisabled = true this.jumpNextBreakpointDisabled = true this.jumpPreviousBreakpointDisabled = true - resetWarning(this) + this.resetWarning('') } ButtonNavigator.prototype.stepChanged = function (stepState, jumpOutDisabled) { @@ -166,10 +130,17 @@ ButtonNavigator.prototype.updateDisabled = function (id, disabled) { } } -function resetWarning (self) { - self.view.querySelector('#reverted #outofgas').style.display = 'none' - self.view.querySelector('#reverted #parenthasthrown').style.display = 'none' - self.view.querySelector('#reverted').style.display = 'none' +ButtonNavigator.prototype.resetAndCheckRevertionPoint = function (revertedReason, revertionPoint) { + if (revertionPoint) { + this.revertionPoint = revertionPoint + } + this.resetWarning(revertedReason) +} + +ButtonNavigator.prototype.resetWarning = function (revertedReason) { + this.view.querySelector('#reverted #outofgas').style.display = (revertedReason === 'outofgas') ? 'inline' : 'none' + this.view.querySelector('#reverted #parenthasthrown').style.display = (revertedReason === 'parenthasthrown') ? 'inline' : 'none' + this.view.querySelector('#reverted').style.display = (revertedReason === '') ? 'none' : 'block' } module.exports = ButtonNavigator diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index ed8edafb68..f0d0df3738 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -41,6 +41,45 @@ function StepManager (_parent, _traceManager) { }) this.buttonNavigator = new ButtonNavigator(_parent, this.traceManager) + + _parent.event.register('indexChanged', this, (index) => { + // if (!this.view) return + if (index < 0) return + if (_parent.currentStepIndex !== index) return + + self.traceManager.buildCallPath(index, (error, callsPath) => { + if (error) { + console.log(error) + if (self.buttonNavigator) { + self.buttonNavigator.resetWarning('') + } + } else { + self.currentCall = callsPath[callsPath.length - 1] + if (self.currentCall.reverted) { + let revertedReason = self.currentCall.outofgas ? 'outofgas' : '' + if (self.buttonNavigator) { + self.buttonNavigator.resetAndCheckRevertionPoint(revertedReason, self.currentCall.return) + } + } else { + var k = callsPath.length - 2 + while (k >= 0) { + var parent = callsPath[k] + if (parent.reverted) { + let revertedReason = parent ? 'parenthasthrown' : '' + if (self.buttonNavigator) { + return self.buttonNavigator.resetAndCheckRevertionPoint(revertedReason, parent.return) + } + } + k-- + } + if (self.buttonNavigator) { + self.buttonNavigator.resetWarning('') + } + } + } + }) + }) + this.buttonNavigator.event.register('stepIntoBack', this, function () { self.stepIntoBack() })