Search in sources :

Example 26 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.

the class BreakpointWithHighlighter method getPsiFile.

@Nullable
public PsiFile getPsiFile() {
    ApplicationManager.getApplication().assertReadAccessAllowed();
    XSourcePosition position = myXBreakpoint.getSourcePosition();
    if (position != null) {
        VirtualFile file = position.getFile();
        if (file.isValid()) {
            return PsiManager.getInstance(myProject).findFile(file);
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XSourcePosition(com.intellij.xdebugger.XSourcePosition) Nullable(org.jetbrains.annotations.Nullable)

Example 27 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.

the class XsltBreakpointHandler method registerBreakpoint.

@Override
public void registerBreakpoint(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
    final XSourcePosition sourcePosition = breakpoint.getSourcePosition();
    if (sourcePosition == null || !sourcePosition.getFile().exists() || !sourcePosition.getFile().isValid()) {
        // ???
        return;
    }
    final VirtualFile file = sourcePosition.getFile();
    final Project project = myXsltDebugProcess.getSession().getProject();
    final String fileURL = getFileURL(file);
    final int lineNumber = getActualLineNumber(breakpoint, project);
    if (lineNumber == -1) {
        final XDebugSession session = myXsltDebugProcess.getSession();
        session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, "Unsupported breakpoint position");
        return;
    }
    try {
        final BreakpointManager manager = myXsltDebugProcess.getBreakpointManager();
        Breakpoint bp;
        if ((bp = manager.getBreakpoint(fileURL, lineNumber)) != null) {
            bp.setEnabled(true);
        } else {
            manager.setBreakpoint(fileURL, lineNumber);
        }
    } catch (DebuggerStoppedException ignore) {
    } catch (VMPausedException e) {
        final XDebugSession session = myXsltDebugProcess.getSession();
        session.reportMessage("Target VM is not responding. Breakpoint can not be set", MessageType.ERROR);
        session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, "Target VM is not responding. Breakpoint can not be set");
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XSourcePosition(com.intellij.xdebugger.XSourcePosition) VMPausedException(org.intellij.plugins.xsltDebugger.VMPausedException) BreakpointManager(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Example 28 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.

the class XsltBreakpointHandler method unregisterBreakpoint.

@Override
public void unregisterBreakpoint(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint, final boolean temporary) {
    final XSourcePosition sourcePosition = breakpoint.getSourcePosition();
    if (sourcePosition == null || !sourcePosition.getFile().exists() || !sourcePosition.getFile().isValid()) {
        // ???
        return;
    }
    final VirtualFile file = sourcePosition.getFile();
    final Project project = myXsltDebugProcess.getSession().getProject();
    final String fileURL = getFileURL(file);
    final int lineNumber = getActualLineNumber(breakpoint, project);
    try {
        final BreakpointManager manager = myXsltDebugProcess.getBreakpointManager();
        if (temporary) {
            final Breakpoint bp = manager.getBreakpoint(fileURL, lineNumber);
            if (bp != null) {
                bp.setEnabled(false);
            }
        } else {
            manager.removeBreakpoint(fileURL, lineNumber);
        }
    } catch (DebuggerStoppedException ignore) {
    } catch (VMPausedException e) {
        myXsltDebugProcess.getSession().reportMessage("Target VM is not responding. Breakpoint can not be removed", MessageType.ERROR);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XSourcePosition(com.intellij.xdebugger.XSourcePosition) VMPausedException(org.intellij.plugins.xsltDebugger.VMPausedException) BreakpointManager(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Example 29 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.

the class XValueNodeImpl method updateInlineDebuggerData.

public void updateInlineDebuggerData() {
    try {
        XDebugSession session = XDebugView.getSession(getTree());
        final XSourcePosition debuggerPosition = session == null ? null : session.getCurrentPosition();
        if (debuggerPosition == null) {
            return;
        }
        final XInlineDebuggerDataCallback callback = new XInlineDebuggerDataCallback() {

            @Override
            public void computed(XSourcePosition position) {
                if (isObsolete() || position == null)
                    return;
                VirtualFile file = position.getFile();
                // filter out values from other files
                if (!Comparing.equal(debuggerPosition.getFile(), file)) {
                    return;
                }
                final Document document = FileDocumentManager.getInstance().getDocument(file);
                if (document == null)
                    return;
                XVariablesView.InlineVariablesInfo data = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
                if (data == null) {
                    return;
                }
                if (!showAsInlay(file, position, debuggerPosition)) {
                    data.put(file, position, XValueNodeImpl.this, document.getModificationStamp());
                    myTree.updateEditor();
                }
            }
        };
        if (getValueContainer().computeInlineDebuggerData(callback) == ThreeState.UNSURE) {
            getValueContainer().computeSourcePosition(callback::computed);
        }
    } catch (Exception ignore) {
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XDebugSession(com.intellij.xdebugger.XDebugSession) XVariablesView(com.intellij.xdebugger.impl.frame.XVariablesView) XSourcePosition(com.intellij.xdebugger.XSourcePosition) Document(com.intellij.openapi.editor.Document)

Example 30 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.

the class XsltSourcePosition method create.

@Nullable
public static XSourcePosition create(Debugger.Locatable location) {
    final VirtualFile file;
    try {
        file = VfsUtil.findFileByURL(new URI(location.getURI()).toURL());
    } catch (Exception e) {
        // TODO log
        return null;
    }
    final int line = location.getLineNumber() - 1;
    final XSourcePosition position = XDebuggerUtil.getInstance().createPosition(file, line);
    return line >= 0 && position != null ? new XsltSourcePosition(location, position) : null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XSourcePosition(com.intellij.xdebugger.XSourcePosition) URI(java.net.URI) Nullable(org.jetbrains.annotations.Nullable)

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