Search in sources :

Example 11 with XSourcePosition

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

the class XVariablesViewBase method buildTreeAndRestoreState.

protected void buildTreeAndRestoreState(@NotNull final XStackFrame stackFrame) {
    XSourcePosition position = stackFrame.getSourcePosition();
    XDebuggerTree tree = getTree();
    tree.setSourcePosition(position);
    createNewRootNode(stackFrame);
    final Project project = tree.getProject();
    project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo());
    clearInlays(tree);
    Object newEqualityObject = stackFrame.getEqualityObject();
    if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) && myTreeState != null) {
        disposeTreeRestorer();
        myTreeRestorer = myTreeState.restoreState(tree);
    }
    if (position != null && Registry.is("debugger.valueTooltipAutoShowOnSelection")) {
        registerInlineEvaluator(stackFrame, position, project);
    }
}
Also used : Project(com.intellij.openapi.project.Project) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree)

Example 12 with XSourcePosition

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

the class JavaBreakpointFiltersPanel method loadFrom.

@Override
public void loadFrom(@NotNull B breakpoint) {
    myCatchFiltersPanel.setVisible(false);
    JavaBreakpointProperties properties = breakpoint.getProperties();
    if (properties != null) {
        if (properties.getCOUNT_FILTER() > 0) {
            myPassCountField.setText(Integer.toString(properties.getCOUNT_FILTER()));
        } else {
            myPassCountField.setText("");
        }
        myPassCountCheckbox.setSelected(properties.isCOUNT_FILTER_ENABLED());
        myInstanceFiltersCheckBox.setSelected(properties.isINSTANCE_FILTERS_ENABLED());
        myInstanceFilters = properties.getInstanceFilters();
        updateInstanceFilterEditor(true);
        myClassFiltersCheckBox.setSelected(properties.isCLASS_FILTERS_ENABLED());
        myClassFiltersField.setClassFilters(properties.getClassFilters(), properties.getClassExclusionFilters());
        if (properties instanceof JavaExceptionBreakpointProperties) {
            myCatchFiltersPanel.setVisible(true);
            JavaExceptionBreakpointProperties exceptionBreakpointProperties = (JavaExceptionBreakpointProperties) properties;
            myCatchCheckBox.setSelected(exceptionBreakpointProperties.isCatchFiltersEnabled());
            myCatchClassFilters.setClassFilters(exceptionBreakpointProperties.getCatchClassFilters(), exceptionBreakpointProperties.getCatchClassExclusionFilters());
        }
        XSourcePosition position = breakpoint.getSourcePosition();
    // TODO: need to calculate psi class
    //myBreakpointPsiClass = breakpoint.getPsiClass();
    }
    updateCheckboxes();
}
Also used : JavaExceptionBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties) JavaBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties) XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Example 13 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project kotlin by JetBrains.

the class KotlinBreakpointFiltersPanel method loadFrom.

@Override
public void loadFrom(@NotNull B breakpoint) {
    JavaBreakpointProperties properties = breakpoint.getProperties();
    if (properties != null) {
        if (properties.getCOUNT_FILTER() > 0) {
            myPassCountField.setText(Integer.toString(properties.getCOUNT_FILTER()));
        } else {
            myPassCountField.setText("");
        }
        myPassCountCheckbox.setSelected(properties.isCOUNT_FILTER_ENABLED());
        myInstanceFiltersCheckBox.setSelected(properties.isINSTANCE_FILTERS_ENABLED());
        myInstanceFiltersField.setEnabled(properties.isINSTANCE_FILTERS_ENABLED());
        myInstanceFiltersField.getTextField().setEditable(properties.isINSTANCE_FILTERS_ENABLED());
        myInstanceFilters = properties.getInstanceFilters();
        updateInstanceFilterEditor(true);
        myClassFiltersCheckBox.setSelected(properties.isCLASS_FILTERS_ENABLED());
        myClassFiltersField.setEnabled(properties.isCLASS_FILTERS_ENABLED());
        myClassFiltersField.getTextField().setEditable(properties.isCLASS_FILTERS_ENABLED());
        myClassFilters = properties.getClassFilters();
        myClassExclusionFilters = properties.getClassExclusionFilters();
        updateClassFilterEditor(true);
        XSourcePosition position = breakpoint.getSourcePosition();
    // TODO: need to calculate psi class
    //myBreakpointPsiClass = breakpoint.getPsiClass();
    }
    updateCheckboxes();
}
Also used : JavaBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties) XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Example 14 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project flutter-intellij by flutter.

the class PositionMapperTest method shouldGetPositionInFileUnderRemoteBaseUri.

@Test
public void shouldGetPositionInFileUnderRemoteBaseUri() throws Exception {
    tmp.writeFile("root/pubspec.yaml", "");
    tmp.ensureDir("root/lib");
    final VirtualFile main = tmp.writeFile("root/lib/main.dart", "");
    final VirtualFile hello = tmp.writeFile("root/lib/hello.dart", "");
    final PositionMapper mapper = setUpMapper(main, "remote:root");
    scripts.addScript("1", "2", "remote:root/lib/hello.dart", ImmutableList.of(new Line(10, 123, 1)));
    final XSourcePosition pos = mapper.getSourcePosition("1", makeScriptRef("2", "remote:root/lib/hello.dart"), 123);
    assertNotNull(pos);
    assertEquals(pos.getFile(), hello);
    // zero-based
    assertEquals(pos.getLine(), 9);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XSourcePosition(com.intellij.xdebugger.XSourcePosition) Test(org.junit.Test)

Example 15 with XSourcePosition

use of com.intellij.xdebugger.XSourcePosition in project Perl5-IDEA by Camelcade.

the class PerlXNamedValue method computeMySourcePosition.

protected boolean computeMySourcePosition(@Nullable XNavigatable navigatable, @Nullable final XInlineDebuggerDataCallback callback) {
    String name = myPerlValueDescriptor.getName();
    if (StringUtil.isEmpty(name) || name.length() < 2) {
        return false;
    }
    final PerlVariableType variableType = PerlVariableType.bySigil(name.charAt(0));
    if (variableType == null || variableType == PerlVariableType.CODE) {
        return false;
    }
    final String variableName = name.substring(1);
    final XSourcePosition sourcePosition = myStackFrame.getSourcePosition();
    if (sourcePosition == null) {
        return false;
    }
    final Project project = myStackFrame.getPerlExecutionStack().getSuspendContext().getDebugSession().getProject();
    final VirtualFile virtualFile = sourcePosition.getFile();
    PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
    if (!(psiFile instanceof PerlFileImpl)) {
        return false;
    }
    PsiElement element = psiFile.findElementAt(sourcePosition.getOffset());
    if (element == null) {
        return false;
    }
    if (navigatable != null) {
        PerlVariableDeclarationSearcher variableProcessor = new PerlVariableDeclarationSearcher(variableName, variableType, element);
        PerlResolveUtil.treeWalkUp(element, variableProcessor);
        PerlVariableDeclarationElement result = variableProcessor.getResult();
        if (result == null) {
            return false;
        }
        navigatable.setSourcePosition(XSourcePositionImpl.createByElement(result));
    } else if (callback != null) {
        final Document document = psiFile.getViewProvider().getDocument();
        if (document == null) {
            return false;
        }
        final boolean[] found = new boolean[] { false };
        PerlVariableDeclarationSearcher variableProcessor = new PerlVariableDeclarationSearcher(variableName, variableType, element) {

            @Override
            public boolean execute(@NotNull PsiElement possibleElement, @NotNull ResolveState state) {
                boolean result = super.execute(possibleElement, state);
                if (!result) {
                    registerElement(getResult());
                } else if (possibleElement instanceof PerlVariable && ((PerlVariable) possibleElement).getActualType() == variableType && StringUtil.equals(variableName, ((PerlVariable) possibleElement).getName())) {
                    registerElement(possibleElement);
                }
                return result;
            }

            private void registerElement(@Nullable PsiElement targetElement) {
                if (targetElement == null) {
                    return;
                }
                found[0] = true;
                try {
                    if (mySourcePositionMethod != null) {
                        mySourcePositionMethod.invoke(callback, XSourcePositionImpl.createByElement(targetElement));
                    } else if (myLegacyMethod != null) {
                        myLegacyMethod.invoke(callback, virtualFile, document, document.getLineNumber(targetElement.getTextOffset()));
                    } else {
                        found[0] = false;
                    }
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        };
        PerlResolveUtil.treeWalkUp(element, variableProcessor);
        return found[0];
    }
    return true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PerlVariableDeclarationElement(com.perl5.lang.perl.psi.PerlVariableDeclarationElement) PerlFileImpl(com.perl5.lang.perl.psi.impl.PerlFileImpl) PerlVariableType(com.perl5.lang.perl.psi.utils.PerlVariableType) PerlVariableDeclarationSearcher(com.perl5.lang.perl.psi.references.scopes.PerlVariableDeclarationSearcher) Document(com.intellij.openapi.editor.Document) InvocationTargetException(java.lang.reflect.InvocationTargetException) ResolveState(com.intellij.psi.ResolveState) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) PerlVariable(com.perl5.lang.perl.psi.PerlVariable) XSourcePosition(com.intellij.xdebugger.XSourcePosition) PsiElement(com.intellij.psi.PsiElement)

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