SearchResult result = new SearchResult();
ICallerSideEvent event = null;
ICallerSideEvent previousEvent = null;
ILogEvent ile;
ICallerSideEvent validEvent = null;
if (this.events != null && this.events.hasPrevious()) {
// Go backwards. First, position the event log at the first line
// we see that is NOT the line we are currently on.
ILogEvent pointerEvent = null;
do {
ile = events.previous();
if (depth != -1 && (computeDepth(ile) != depth && computeDepth(ile) != depth - 1)) {
continue;
}
if (ile instanceof ICallerSideEvent && !(ile instanceof BehaviorExitEvent)) {
event = (ICallerSideEvent)ile;
int lineNum = TypeUtils.calculateLineNumber(event.getOperationBehavior(), event.getOperationBytecodeIndex());
if (skippable(event) || lineNum == -1) {
continue;
}
if (targetLine == -1 && lineNum != lineNumber) {
targetLine = lineNum;
pointerEvent = event;
} else if (targetLine != -1 && targetLine != lineNum) {
result.lastEvent = event;
break;
}
}
} while (events.hasPrevious());
// Reset the event pointer to the first event on the target line.
if (pointerEvent != null) {
events.setNextTimestamp(pointerEvent.getTimestamp());
ile = pointerEvent;
}
do {
if (depth != -1 && computeDepth(ile) != depth && computeDepth(ile) != depth - 1) {
ile = events.previous();