use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.
the class JavaExceptionBreakpointType method addBreakpoint.
//public Key<ExceptionBreakpoint> getBreakpointCategory() {
// return ExceptionBreakpoint.CATEGORY;
//}
@Nullable
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
final PsiClass throwableClass = JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_THROWABLE, GlobalSearchScope.allScope(project));
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project).createInheritanceClassChooser(DebuggerBundle.message("add.exception.breakpoint.classchooser.title"), GlobalSearchScope.allScope(project), throwableClass, true, true, null);
chooser.showDialog();
final PsiClass selectedClass = chooser.getSelected();
final String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass);
if (qName != null && qName.length() > 0) {
return ApplicationManager.getApplication().runWriteAction(new Computable<XBreakpoint<JavaExceptionBreakpointProperties>>() {
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> compute() {
return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(JavaExceptionBreakpointType.this, new JavaExceptionBreakpointProperties(qName, ((PsiClassOwner) selectedClass.getContainingFile()).getPackageName()));
}
});
}
return null;
}
use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.
the class XBreakpointGroupingByClassRule method getGroup.
@Override
public XBreakpointClassGroup getGroup(@NotNull B b, @NotNull Collection<XBreakpointClassGroup> groups) {
if (b instanceof XBreakpoint) {
Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint((XBreakpoint) b);
if (javaBreakpoint == null) {
return null;
}
String className = javaBreakpoint.getShortClassName();
String packageName = javaBreakpoint.getPackageName();
if (className == null) {
return null;
}
for (XBreakpointClassGroup group : groups) {
if (group.getClassName().equals(className) && group.getPackageName().equals(packageName)) {
return group;
}
}
return new XBreakpointClassGroup(packageName, className);
}
return null;
}
use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.
the class DebuggerUIUtil method showXBreakpointEditorBalloon.
public static void showXBreakpointEditorBalloon(final Project project, @Nullable final Point point, final JComponent component, final boolean showAllOptions, final XBreakpoint breakpoint) {
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
final XLightBreakpointPropertiesPanel propertiesPanel = new XLightBreakpointPropertiesPanel(project, breakpointManager, (XBreakpointBase) breakpoint, showAllOptions);
final Ref<Balloon> balloonRef = Ref.create(null);
final Ref<Boolean> isLoading = Ref.create(Boolean.FALSE);
final Ref<Boolean> moreOptionsRequested = Ref.create(Boolean.FALSE);
propertiesPanel.setDelegate(() -> {
if (!isLoading.get()) {
propertiesPanel.saveProperties();
}
if (!balloonRef.isNull()) {
balloonRef.get().hide();
}
showXBreakpointEditorBalloon(project, point, component, true, breakpoint);
moreOptionsRequested.set(true);
});
isLoading.set(Boolean.TRUE);
propertiesPanel.loadProperties();
isLoading.set(Boolean.FALSE);
if (moreOptionsRequested.get()) {
return;
}
Runnable showMoreOptions = () -> {
propertiesPanel.saveProperties();
propertiesPanel.dispose();
BreakpointsDialogFactory.getInstance(project).showDialog(breakpoint);
};
final JComponent mainPanel = propertiesPanel.getMainPanel();
final Balloon balloon = showBreakpointEditor(project, mainPanel, point, component, showMoreOptions, breakpoint);
balloonRef.set(balloon);
final XBreakpointListener<XBreakpoint<?>> breakpointListener = new XBreakpointAdapter<XBreakpoint<?>>() {
@Override
public void breakpointRemoved(@NotNull XBreakpoint<?> removedBreakpoint) {
if (removedBreakpoint.equals(breakpoint)) {
balloon.hide();
}
}
};
balloon.addListener(new JBPopupListener.Adapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
propertiesPanel.saveProperties();
propertiesPanel.dispose();
breakpointManager.removeBreakpointListener(breakpointListener);
}
});
breakpointManager.addBreakpointListener(breakpointListener);
ApplicationManager.getApplication().invokeLater(() -> IdeFocusManager.findInstance().requestFocus(mainPanel, true));
}
use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.
the class XBreakpointManagerTest method testSerialize.
public void testSerialize() {
XLineBreakpoint<MyBreakpointProperties> breakpoint = addLineBreakpoint(myBreakpointManager, "myurl", 239, new MyBreakpointProperties("z1"));
breakpoint.setCondition("cond");
breakpoint.setLogExpression("log");
breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
breakpoint.setLogMessage(true);
addBreakpoint(myBreakpointManager, new MyBreakpointProperties("z2"));
reload();
List<XBreakpoint<?>> breakpoints = getAllBreakpoints();
assertEquals("Expected 3 breakpoints, actual: " + breakpoints, 3, breakpoints.size());
assertTrue(myBreakpointManager.isDefaultBreakpoint(breakpoints.get(0)));
assertEquals("default", assertInstanceOf(breakpoints.get(0).getProperties(), MyBreakpointProperties.class).myOption);
assertTrue(breakpoints.get(0).isEnabled());
XLineBreakpoint lineBreakpoint = assertInstanceOf(breakpoints.get(1), XLineBreakpoint.class);
assertEquals(239, lineBreakpoint.getLine());
assertEquals("myurl", lineBreakpoint.getFileUrl());
assertEquals("z1", assertInstanceOf(lineBreakpoint.getProperties(), MyBreakpointProperties.class).myOption);
assertEquals("cond", lineBreakpoint.getCondition());
assertEquals("log", lineBreakpoint.getLogExpression());
assertTrue(lineBreakpoint.isLogMessage());
assertEquals(SuspendPolicy.NONE, lineBreakpoint.getSuspendPolicy());
assertEquals("z2", assertInstanceOf(breakpoints.get(2).getProperties(), MyBreakpointProperties.class).myOption);
assertEquals(SuspendPolicy.ALL, breakpoints.get(2).getSuspendPolicy());
assertFalse(breakpoints.get(2).isLogMessage());
}
use of com.intellij.xdebugger.breakpoints.XBreakpoint 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