use of com.intellij.debugger.engine.requests.LocatableEventRequestor in project intellij-community by JetBrains.
the class DebugProcessEvents method processLocatableEvent.
private void processLocatableEvent(final SuspendContextImpl suspendContext, final LocatableEvent event) {
ThreadReference thread = event.thread();
//LOG.assertTrue(thread.isSuspended());
preprocessEvent(suspendContext, thread);
//we use schedule to allow processing other events during processing this one
//this is especially necessary if a method is breakpoint condition
getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction() throws Exception {
final SuspendManager suspendManager = getSuspendManager();
SuspendContextImpl evaluatingContext = SuspendManagerUtil.getEvaluatingContext(suspendManager, suspendContext.getThread());
if (evaluatingContext != null && !DebuggerSession.enableBreakpointsDuringEvaluation()) {
// is inside evaluation, so ignore any breakpoints
suspendManager.voteResume(suspendContext);
return;
}
final LocatableEventRequestor requestor = (LocatableEventRequestor) getRequestsManager().findRequestor(event.request());
boolean resumePreferred = requestor != null && DebuggerSettings.SUSPEND_NONE.equals(requestor.getSuspendPolicy());
boolean requestHit;
try {
requestHit = (requestor != null) && requestor.processLocatableEvent(this, event);
} catch (final LocatableEventRequestor.EventProcessingException ex) {
if (LOG.isDebugEnabled()) {
LOG.debug(ex.getMessage());
}
final boolean[] considerRequestHit = new boolean[] { true };
DebuggerInvocationUtil.invokeAndWait(getProject(), () -> {
final String displayName = requestor instanceof Breakpoint ? ((Breakpoint) requestor).getDisplayName() : requestor.getClass().getSimpleName();
final String message = DebuggerBundle.message("error.evaluating.breakpoint.condition.or.action", displayName, ex.getMessage());
considerRequestHit[0] = Messages.showYesNoDialog(getProject(), message, ex.getTitle(), Messages.getQuestionIcon()) == Messages.YES;
}, ModalityState.NON_MODAL);
requestHit = considerRequestHit[0];
resumePreferred = !requestHit;
}
if (requestHit && requestor instanceof Breakpoint) {
// if requestor is a breakpoint and this breakpoint was hit, no matter its suspend policy
ApplicationManager.getApplication().runReadAction(() -> {
XDebugSession session = getSession().getXDebugSession();
if (session != null) {
XBreakpoint breakpoint = ((Breakpoint) requestor).getXBreakpoint();
if (breakpoint != null) {
((XDebugSessionImpl) session).processDependencies(breakpoint);
}
}
});
}
if (!requestHit || resumePreferred) {
suspendManager.voteResume(suspendContext);
} else {
if (myReturnValueWatcher != null) {
myReturnValueWatcher.disable();
}
//if (suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL) {
// // there could be explicit resume as a result of call to voteSuspend()
// // e.g. when breakpoint was considered invalid, in that case the filter will be applied _after_
// // resuming and all breakpoints in other threads will be ignored.
// // As resume() implicitly cleares the filter, the filter must be always applied _before_ any resume() action happens
// myBreakpointManager.applyThreadFilter(DebugProcessEvents.this, event.thread());
//}
suspendManager.voteSuspend(suspendContext);
showStatusText(DebugProcessEvents.this, event);
}
}
});
}
Aggregations