use of com.intellij.xdebugger.impl.breakpoints.XLineBreakpointManager 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;
}
Aggregations