use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class XDebuggerSmartStepIntoHandler method perform.
@Override
protected void perform(@NotNull XDebugSession session, DataContext dataContext) {
XSmartStepIntoHandler<?> handler = session.getDebugProcess().getSmartStepIntoHandler();
XSourcePosition position = session.getTopFramePosition();
if (position == null || handler == null)
return;
FileEditor editor = FileEditorManager.getInstance(session.getProject()).getSelectedEditor(position.getFile());
if (editor instanceof TextEditor) {
doSmartStepInto(handler, position, session, ((TextEditor) editor).getEditor());
}
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class XToggleLineBreakpointActionHandler method perform.
@Override
public void perform(@NotNull final Project project, final AnActionEvent event) {
Editor editor = event.getData(CommonDataKeys.EDITOR);
// do not toggle more than once on the same line
Set<Integer> processedLines = new HashSet<>();
for (XSourcePosition position : XDebuggerUtilImpl.getAllCaretsPositions(project, event.getDataContext())) {
if (processedLines.add(position.getLine())) {
XBreakpointUtil.toggleLineBreakpoint(project, position, editor, myTemporary, true, true);
}
}
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class XStackFrame method customizePresentation.
/**
* Customize presentation of the stack frame in frames list
* @param component component
*/
public void customizePresentation(@NotNull ColoredTextContainer component) {
XSourcePosition position = getSourcePosition();
if (position != null) {
component.append(position.getFile().getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
component.append(":" + (position.getLine() + 1), SimpleTextAttributes.REGULAR_ATTRIBUTES);
component.setIcon(AllIcons.Debugger.StackFrame);
} else {
component.append(XDebuggerBundle.message("invalid.frame"), SimpleTextAttributes.ERROR_ATTRIBUTES);
}
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class DebuggerContextUtil method findNearest.
public static SourcePosition findNearest(@NotNull DebuggerContextImpl context, @NotNull PsiElement psi, @NotNull PsiFile file) {
if (psi instanceof PsiCompiledElement) {
// it makes no sense to compute text range of compiled element
return null;
}
final DebuggerSession session = context.getDebuggerSession();
if (session != null) {
try {
final XDebugSession debugSession = session.getXDebugSession();
if (debugSession != null) {
final XSourcePosition position = debugSession.getCurrentPosition();
Editor editor = ((FileEditorManagerImpl) FileEditorManager.getInstance(file.getProject())).getSelectedTextEditor(true);
//final Editor editor = fileEditor instanceof TextEditorImpl ? ((TextEditorImpl)fileEditor).getEditor() : null;
if (editor != null && position != null && position.getFile().equals(file.getOriginalFile().getVirtualFile())) {
PsiMethod method = PsiTreeUtil.getParentOfType(PositionUtil.getContextElement(context), PsiMethod.class, false);
final Collection<TextRange> ranges = IdentifierHighlighterPass.getUsages(psi, method != null ? method : file, false);
final int breakPointLine = position.getLine();
int bestLine = -1;
int bestOffset = -1;
for (TextRange range : ranges) {
final int line = editor.offsetToLogicalPosition(range.getStartOffset()).line;
if (line > bestLine && line < breakPointLine) {
bestLine = line;
bestOffset = range.getStartOffset();
} else if (line == breakPointLine) {
bestOffset = range.getStartOffset();
break;
}
}
if (bestOffset > -1) {
return SourcePosition.createFromOffset(file, bestOffset);
}
}
}
} catch (Exception ignore) {
}
}
return null;
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class BreakpointWithHighlighter method reload.
@Override
public void reload() {
ApplicationManager.getApplication().assertReadAccessAllowed();
XSourcePosition position = myXBreakpoint.getSourcePosition();
PsiFile psiFile = getPsiFile();
if (position != null && psiFile != null) {
mySourcePosition = SourcePosition.createFromLine(psiFile, position.getLine());
reload(psiFile);
} else {
mySourcePosition = null;
}
}
Aggregations