add jumpPreviousBreakpoint

pull/7/head
yann300 8 years ago
parent ef7ec7d27f
commit 981b2ebef0
  1. 49
      src/code/breakpointManager.js
  2. 6
      src/ui/ButtonNavigator.js
  3. 3
      src/ui/StepManager.js

@ -17,37 +17,58 @@ class breakpointManager {
this.event = new EventManager()
this.debugger = _debugger
this.breakpoints = {}
this.isPlaying = false
this.locationToRowConverter = _locationToRowConverter
this.currentLine
this.previousLine
}
/**
* start looking for the next breakpoint
* @param {Bool} defaultToLimit - if true jump to the enf of the trace if no more breakpoint found
*
*/
async jumpNextBreakpoint (defaultToEnd) {
this.isPlaying = true
async jumpNextBreakpoint (defaultToLimit) {
this.jump(1, defaultToLimit)
}
/**
* start looking for the previous breakpoint
* @param {Bool} defaultToLimit - if true jump to the enf of the trace if no more breakpoint found
*
*/
async jumpPreviousBreakpoint (defaultToLimit) {
this.jump(-1, defaultToLimit)
}
/**
* start looking for the previous or next breakpoint
* @param {Int} direction - 1 or -1 direction of the search
* @param {Bool} defaultToLimit - if true jump to the enf of the trace if no more breakpoint found
*
*/
async jump (direction, defaultToLimit) {
if (!this.locationToRowConverter) {
return
}
var sourceLocation
for (var currentStep = this.debugger.currentStepIndex + 1; currentStep < this.debugger.traceManager.trace.length; currentStep++) {
var currentStep = this.debugger.currentStepIndex + direction
while (currentStep > 0 && currentStep < this.debugger.traceManager.trace.length) {
try {
sourceLocation = await this.debugger.callTree.extractSourceLocation(currentStep)
} catch (e) {
console.log('cannot jump to breakpoint ' + e)
}
if (this.locationToRowConverter) {
var lineColumn = this.locationToRowConverter(sourceLocation)
if (this.currentLine === lineColumn.start.line) {
if (defaultToEnd && currentStep === this.debugger.traceManager.trace.length - 1) {
this.debugger.stepManager.jumpTo(currentStep) // jump to the end
}
continue
if (this.previousLine !== lineColumn.start.line) {
this.previousLine = lineColumn.start.line
if (this.checkSourceLocation(sourceLocation.file, lineColumn.start.line)) {
this.debugger.stepManager.jumpTo(currentStep)
this.event.trigger('breakpointHit', [sourceLocation])
break
}
this.currentLine = lineColumn.start.line
}
if (this.checkSourceLocation(sourceLocation.file, this.currentLine)) {
currentStep += direction
if (defaultToLimit && (currentStep === this.debugger.traceManager.trace.length - 1 || currentStep === 0)) {
this.debugger.stepManager.jumpTo(currentStep)
this.event.trigger('breakpointHit', [sourceLocation])
break
}
}

@ -12,6 +12,7 @@ function ButtonNavigator (_parent, _traceManager) {
this.overForwardDisabled = true
this.jumpOutDisabled = true
this.jumpNextBreakpointDisabled = true
this.jumpPreviousBreakpointDisabled = true
this.traceManager = _traceManager
this.currentCall = null
@ -69,6 +70,8 @@ ButtonNavigator.prototype.render = function () {
</button>
<button id='jumpout' title='jump out' class='fa fa-share' style=${ui.formatCss(style.button)} onclick=${function () { self.event.trigger('jumpOut') }} disabled=${this.jumpOutDisabled} >
</button>
<button id='jumppreviousbreakpoint' title='jump to the previous breakpoint' class='fa fa-step-backward' style=${ui.formatCss(style.button)} onclick=${function () { self.event.trigger('jumpPreviousBreakpoint') }} disabled=${this.jumpPreviousBreakpointDisabled} >
</button>
<button id='jumpnextbreakpoint' title='jump to the next breakpoint' class='fa fa-step-forward' style=${ui.formatCss(style.button)} onclick=${function () { self.event.trigger('jumpNextBreakpoint') }} disabled=${this.jumpNextBreakpointDisabled} >
</button>
<div id='reverted' style="display:none">
@ -92,6 +95,7 @@ ButtonNavigator.prototype.reset = function () {
this.overForwardDisabled = true
this.jumpOutDisabled = true
this.jumpNextBreakpointDisabled = true
this.jumpPreviousBreakpointDisabled = true
resetWarning(this)
}
@ -109,6 +113,7 @@ ButtonNavigator.prototype.stepChanged = function (step) {
console.log(error)
} else {
self.jumpNextBreakpointDisabled = step >= length - 1
self.jumpPreviousBreakpointDisabled = step <= 0
self.intoForwardDisabled = step >= length - 1
self.overForwardDisabled = step >= length - 1
var stepOut = self.traceManager.findStepOut(step)
@ -128,6 +133,7 @@ ButtonNavigator.prototype.updateAll = function () {
this.updateDisabled('jumpout', this.jumpOutDisabled)
this.updateDisabled('jumptoexception', this.jumpOutDisabled)
this.updateDisabled('jumpnextbreakpoint', this.jumpNextBreakpointDisabled)
this.updateDisabled('jumppreviousbreakpoint', this.jumpPreviousBreakpointDisabled)
}
ButtonNavigator.prototype.updateDisabled = function (id, disabled) {

@ -63,6 +63,9 @@ function StepManager (_parent, _traceManager) {
this.buttonNavigator.event.register('jumpNextBreakpoint', (exceptionIndex) => {
self.parent.breakpointManager.jumpNextBreakpoint(true)
})
this.buttonNavigator.event.register('jumpPreviousBreakpoint', (exceptionIndex) => {
self.parent.breakpointManager.jumpPreviousBreakpoint(true)
})
}
StepManager.prototype.resolveToReducedTrace = function (value, incr) {

Loading…
Cancel
Save