public boolean canMoveTo(@Nullable final SourcePosition position) { if (position == null || !position.getFile().isValid()) { return false; } final PsiFile psiFile = position.getFile(); final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(psiFile); if (document == null) { return false; } final int spOffset = position.getOffset(); if (spOffset < 0) { return false; } final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager(); return breakpointManager.findBreakpoint(document, spOffset, getCategory()) == null; }
@Override @Nullable public String getShortClassName() { final SourcePosition pos = getSourcePosition(); if (pos != null) { if (pos.getFile() instanceof JspFile) { return getClassName(); } } return super.getShortClassName(); }
@Nullable public Document getDocument() { final RangeHighlighter highlighter = getHighlighter(); if (highlighter != null) { return highlighter.getDocument(); } final SourcePosition position = getSourcePosition(); if (position != null) { final PsiFile file = position.getFile(); return PsiDocumentManager.getInstance(getProject()).getDocument(file); } return null; }
public boolean moveTo(@NotNull SourcePosition position) { if (!canMoveTo(position)) { return false; } final PsiFile psiFile = position.getFile(); final PsiFile oldFile = getSourcePosition().getFile(); final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(psiFile); final Document oldDocument = PsiDocumentManager.getInstance(getProject()).getDocument(oldFile); if (document == null || oldDocument == null) { return false; } final RangeHighlighter newHighlighter = createHighlighter(myProject, document, position.getLine()); if (newHighlighter == null) { return false; } final RangeHighlighter oldHighlighter = myHighlighter; myHighlighter = newHighlighter; reload(); if (!isValid()) { myHighlighter.dispose(); myHighlighter = oldHighlighter; reload(); return false; } if (oldHighlighter != null) { oldHighlighter.dispose(); } DebuggerManagerEx.getInstanceEx(getProject()) .getBreakpointManager() .fireBreakpointChanged(this); updateUI(); return true; }