use of com.intellij.xdebugger.breakpoints.XBreakpointManager in project intellij-community by JetBrains.
the class XToggleLineBreakpointActionHandler method isEnabled.
@Override
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
XLineBreakpointType<?>[] breakpointTypes = XDebuggerUtil.getInstance().getLineBreakpointTypes();
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
for (XSourcePosition position : XDebuggerUtilImpl.getAllCaretsPositions(project, event.getDataContext())) {
for (XLineBreakpointType<?> breakpointType : breakpointTypes) {
final VirtualFile file = position.getFile();
final int line = position.getLine();
if (breakpointType.canPutAt(file, line, project) || breakpointManager.findBreakpointAtLine(breakpointType, file, line) != null) {
return true;
}
}
}
return false;
}
use of com.intellij.xdebugger.breakpoints.XBreakpointManager 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.XBreakpointManager in project intellij-community by JetBrains.
the class XLineBreakpointImpl method createBreakpointDraggableObject.
@Override
protected GutterDraggableObject createBreakpointDraggableObject() {
return new GutterDraggableObject() {
@Override
public boolean copy(int line, VirtualFile file) {
if (canMoveTo(line, file)) {
setFileUrl(file.getUrl());
setLine(line, true);
return true;
}
return false;
}
public void remove() {
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(getProject()).getBreakpointManager();
ApplicationManager.getApplication().runWriteAction(() -> breakpointManager.removeBreakpoint(XLineBreakpointImpl.this));
}
@Override
public Cursor getCursor(int line) {
return canMoveTo(line, getFile()) ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop;
}
};
}
use of com.intellij.xdebugger.breakpoints.XBreakpointManager in project intellij-community by JetBrains.
the class ContextTest method testXDebugger.
public void testXDebugger() throws Exception {
final WorkingContextManager manager = getContextManager();
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(getProject()).getBreakpointManager();
final XsltBreakpointType type = XBreakpointType.EXTENSION_POINT_NAME.findExtension(XsltBreakpointType.class);
ApplicationManager.getApplication().runWriteAction(() -> {
XLineBreakpointImpl<XBreakpointProperties> breakpoint = (XLineBreakpointImpl<XBreakpointProperties>) breakpointManager.addLineBreakpoint(type, "foo", 0, null);
final String name = "foo";
manager.saveContext(name, null);
breakpointManager.removeBreakpoint(breakpoint);
});
manager.loadContext("foo");
Collection<? extends XLineBreakpoint<XBreakpointProperties>> breakpoints = breakpointManager.getBreakpoints(type);
assertEquals(1, breakpoints.size());
manager.clearContext();
}
use of com.intellij.xdebugger.breakpoints.XBreakpointManager in project android by JetBrains.
the class ConnectDebuggerTask method logUnsupportedBreakpoints.
private void logUnsupportedBreakpoints(@NotNull AndroidVersion version, @NotNull final ConsolePrinter printer) {
final Set<XBreakpointType<?, ?>> allBpTypes = Sets.newHashSet();
for (AndroidDebugger androidDebugger : AndroidDebugger.EP_NAME.getExtensions()) {
allBpTypes.addAll(androidDebugger.getSupportedBreakpointTypes(myProject, version));
}
allBpTypes.removeAll(myDebugger.getSupportedBreakpointTypes(myProject, version));
if (allBpTypes.isEmpty()) {
return;
}
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
XBreakpointManager bpManager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
// Try to find breakpoints which are using unsupported breakpoint types.
for (XBreakpointType<?, ?> bpType : allBpTypes) {
Collection bps = bpManager.getBreakpoints(bpType);
if (!bps.isEmpty()) {
String warnMsg = String.format("The currently selected %1$s debugger doesn't support breakpoints of type '%2$s'. As a result, these breakpoints will " + "not be hit.\nThe debugger selection can be modified in the run configuration dialog.", myDebugger.getDisplayName(), bpType.getTitle());
printer.stderr(warnMsg);
Logger.getInstance(ConnectDebuggerTask.class).info(warnMsg);
return;
}
}
}
});
}
Aggregations