Search in sources :

Example 21 with XSourcePosition

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());
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Example 22 with XSourcePosition

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);
        }
    }
}
Also used : Editor(com.intellij.openapi.editor.Editor) XSourcePosition(com.intellij.xdebugger.XSourcePosition) HashSet(com.intellij.util.containers.HashSet)

Example 23 with XSourcePosition

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);
    }
}
Also used : XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Example 24 with XSourcePosition

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;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) PsiMethod(com.intellij.psi.PsiMethod) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) PsiCompiledElement(com.intellij.psi.PsiCompiledElement) TextRange(com.intellij.openapi.util.TextRange) XSourcePosition(com.intellij.xdebugger.XSourcePosition) Editor(com.intellij.openapi.editor.Editor)

Example 25 with XSourcePosition

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;
    }
}
Also used : PsiFile(com.intellij.psi.PsiFile) XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Aggregations

XSourcePosition (com.intellij.xdebugger.XSourcePosition)40 VirtualFile (com.intellij.openapi.vfs.VirtualFile)20 Project (com.intellij.openapi.project.Project)9 Nullable (org.jetbrains.annotations.Nullable)8 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)6 PsiFile (com.intellij.psi.PsiFile)5 NotNull (org.jetbrains.annotations.NotNull)5 Document (com.intellij.openapi.editor.Document)4 XDebugSession (com.intellij.xdebugger.XDebugSession)4 PsiElement (com.intellij.psi.PsiElement)3 XStackFrame (com.intellij.xdebugger.frame.XStackFrame)3 Editor (com.intellij.openapi.editor.Editor)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)2 Ref (com.intellij.openapi.util.Ref)2 TextRange (com.intellij.openapi.util.TextRange)2 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)2 XDebuggerEvaluator (com.intellij.xdebugger.evaluation.XDebuggerEvaluator)2 XValue (com.intellij.xdebugger.frame.XValue)2 VMPausedException (org.intellij.plugins.xsltDebugger.VMPausedException)2