Search in sources :

Example 1 with XBreakpointManager

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager) XLineBreakpointType(com.intellij.xdebugger.breakpoints.XLineBreakpointType) XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Example 2 with XBreakpointManager

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));
}
Also used : XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XLightBreakpointPropertiesPanel(com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel) NotNull(org.jetbrains.annotations.NotNull) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) XBreakpointAdapter(com.intellij.xdebugger.breakpoints.XBreakpointAdapter)

Example 3 with XBreakpointManager

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;
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager)

Example 4 with XBreakpointManager

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();
}
Also used : XBreakpointProperties(com.intellij.xdebugger.breakpoints.XBreakpointProperties) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager) XLineBreakpointImpl(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl) XsltBreakpointType(org.intellij.plugins.xsltDebugger.XsltBreakpointType)

Example 5 with XBreakpointManager

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;
                }
            }
        }
    });
}
Also used : AndroidDebugger(com.android.tools.idea.run.editor.AndroidDebugger) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager) XBreakpointType(com.intellij.xdebugger.breakpoints.XBreakpointType)

Aggregations

XBreakpointManager (com.intellij.xdebugger.breakpoints.XBreakpointManager)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 AndroidDebugger (com.android.tools.idea.run.editor.AndroidDebugger)1 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)1 XBreakpointAdapter (com.intellij.xdebugger.breakpoints.XBreakpointAdapter)1 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)1 XBreakpointType (com.intellij.xdebugger.breakpoints.XBreakpointType)1 XLineBreakpointType (com.intellij.xdebugger.breakpoints.XLineBreakpointType)1 XLineBreakpointImpl (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl)1 XLightBreakpointPropertiesPanel (com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 XsltBreakpointType (org.intellij.plugins.xsltDebugger.XsltBreakpointType)1 NotNull (org.jetbrains.annotations.NotNull)1