Search in sources :

Example 1 with XLineBreakpointImpl

use of com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl in project intellij-community by JetBrains.

the class XDebuggerTestUtil method assertBreakpointValidity.

public static <B extends XBreakpoint<?>> void assertBreakpointValidity(Project project, VirtualFile file, int line, boolean validity, String errorMessage, Class<? extends XBreakpointType<B, ?>> breakpointType) {
    XLineBreakpointType type = (XLineBreakpointType) XDebuggerUtil.getInstance().findBreakpointType(breakpointType);
    XBreakpointManager manager = XDebuggerManager.getInstance(project).getBreakpointManager();
    XLineBreakpointImpl breakpoint = (XLineBreakpointImpl) manager.findBreakpointAtLine(type, file, line);
    assertNotNull(breakpoint);
    assertEquals(validity ? AllIcons.Debugger.Db_verified_breakpoint : AllIcons.Debugger.Db_invalid_breakpoint, breakpoint.getIcon());
    assertEquals(errorMessage, breakpoint.getErrorMessage());
}
Also used : XLineBreakpointImpl(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl)

Example 2 with XLineBreakpointImpl

use of com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl in project intellij-community by JetBrains.

the class ToggleBreakpointEnabledAction method findLineBreakpoints.

@NotNull
private static Set<XLineBreakpoint> findLineBreakpoints(AnActionEvent e) {
    Project project = e.getProject();
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (project == null || editor == null)
        return Collections.emptySet();
    XBreakpointManagerImpl breakpointManager = (XBreakpointManagerImpl) XDebuggerManager.getInstance(project).getBreakpointManager();
    XLineBreakpointManager lineBreakpointManager = breakpointManager.getLineBreakpointManager();
    Document document = editor.getDocument();
    Collection<Range<Integer>> lineRanges = new ArrayList<>();
    for (Caret caret : editor.getCaretModel().getAllCarets()) {
        lineRanges.add(new Range<>(document.getLineNumber(caret.getSelectionStart()), document.getLineNumber(caret.getSelectionEnd())));
    }
    Collection<XLineBreakpointImpl> breakpoints = lineBreakpointManager.getDocumentBreakpoints(document);
    HashSet<XLineBreakpoint> res = new HashSet<>();
    for (XLineBreakpointImpl breakpoint : breakpoints) {
        int line = breakpoint.getLine();
        for (Range<Integer> range : lineRanges) {
            if (range.isWithin(line)) {
                res.add(breakpoint);
            }
        }
    }
    return res;
}
Also used : XLineBreakpointImpl(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl) XLineBreakpointManager(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointManager) Document(com.intellij.openapi.editor.Document) Range(com.intellij.util.Range) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl) Project(com.intellij.openapi.project.Project) Editor(com.intellij.openapi.editor.Editor) Caret(com.intellij.openapi.editor.Caret) HashSet(com.intellij.util.containers.HashSet) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with XLineBreakpointImpl

use of com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl in project intellij-community by JetBrains.

the class XDebuggerEditBreakpointActionHandler method isEnabled.

@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
    DataContext dataContext = event.getDataContext();
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (editor == null)
        return false;
    final Pair<GutterIconRenderer, Object> pair = XBreakpointUtil.findSelectedBreakpoint(project, editor);
    return pair.first != null && pair.second instanceof XLineBreakpointImpl;
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) XLineBreakpointImpl(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl) Editor(com.intellij.openapi.editor.Editor) GutterIconRenderer(com.intellij.openapi.editor.markup.GutterIconRenderer)

Example 4 with XLineBreakpointImpl

use of com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl 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)

Aggregations

XLineBreakpointImpl (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl)4 Editor (com.intellij.openapi.editor.Editor)2 DataContext (com.intellij.openapi.actionSystem.DataContext)1 Caret (com.intellij.openapi.editor.Caret)1 Document (com.intellij.openapi.editor.Document)1 GutterIconRenderer (com.intellij.openapi.editor.markup.GutterIconRenderer)1 Project (com.intellij.openapi.project.Project)1 Range (com.intellij.util.Range)1 HashSet (com.intellij.util.containers.HashSet)1 XBreakpointManager (com.intellij.xdebugger.breakpoints.XBreakpointManager)1 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)1 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 XBreakpointManagerImpl (com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)1 XLineBreakpointManager (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointManager)1 XsltBreakpointType (org.intellij.plugins.xsltDebugger.XsltBreakpointType)1 NotNull (org.jetbrains.annotations.NotNull)1