Search in sources :

Example 21 with SourcePosition

use of com.intellij.debugger.SourcePosition in project smali by JesusFreke.

the class SmaliPositionManagerTest method testGetSourcePosition.

public void testGetSourcePosition() throws NoDataException {
    myFixture.addFileToProject("my/pkg/blah.smali", testClass);
    SmaliPositionManager positionManager = new SmaliPositionManager(new MockDebugProcess());
    SourcePosition sourcePosition = positionManager.getSourcePosition("my.pkg.blah", "getRandomParentType", "(I)I", 0);
    Assert.assertEquals(Opcode.CONST_4, ((SmaliInstruction) sourcePosition.getElementAt()).getOpcode());
    Assert.assertEquals(0, ((SmaliInstruction) sourcePosition.getElementAt()).getOffset());
    sourcePosition = positionManager.getSourcePosition("my.pkg.blah", "getRandomParentType", "(I)I", 10);
    Assert.assertEquals(Opcode.INVOKE_VIRTUAL, ((SmaliInstruction) sourcePosition.getElementAt()).getOpcode());
    Assert.assertEquals(20, ((SmaliInstruction) sourcePosition.getElementAt()).getOffset());
}
Also used : SourcePosition(com.intellij.debugger.SourcePosition) SmaliPositionManager(org.jf.smalidea.debugging.SmaliPositionManager)

Example 22 with SourcePosition

use of com.intellij.debugger.SourcePosition in project smali by JesusFreke.

the class SmaliMethodTest method checkSourcePosition.

private void checkSourcePosition(SmaliMethod smaliMethod, int codeOffset, Opcode opcode) {
    SourcePosition sourcePosition = smaliMethod.getSourcePositionForCodeOffset(codeOffset);
    Assert.assertNotNull(sourcePosition);
    SmaliInstruction instruction = (SmaliInstruction) sourcePosition.getElementAt();
    Assert.assertEquals(opcode, instruction.getOpcode());
    Assert.assertEquals(codeOffset, instruction.getOffset());
}
Also used : SourcePosition(com.intellij.debugger.SourcePosition)

Example 23 with SourcePosition

use of com.intellij.debugger.SourcePosition in project intellij-community by JetBrains.

the class EditSourceAction method update.

public void update(AnActionEvent e) {
    final Project project = e.getProject();
    final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebuggerTreeNodeImpl node = getSelectedNode(e.getDataContext());
    final Presentation presentation = e.getPresentation();
    if (debuggerContext.getDebugProcess() != null) {
        presentation.setEnabled(true);
        debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {

            public void threadAction() {
                final SourcePosition position = getSourcePosition(node, debuggerContext);
                if (position == null) {
                    DebuggerInvocationUtil.swingInvokeLater(project, () -> presentation.setEnabled(false));
                }
            }
        });
    } else {
        presentation.setEnabled(false);
    }
    e.getPresentation().setText(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getTemplatePresentation().getText());
}
Also used : Project(com.intellij.openapi.project.Project) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) SourcePosition(com.intellij.debugger.SourcePosition) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) Presentation(com.intellij.openapi.actionSystem.Presentation) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 24 with SourcePosition

use of com.intellij.debugger.SourcePosition in project intellij-community by JetBrains.

the class EditSourceAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    final DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
    if (selectedNode != null) {
        final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
        DebugProcessImpl process = debuggerContext.getDebugProcess();
        if (process != null) {
            process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {

                public void threadAction() {
                    final SourcePosition sourcePosition = getSourcePosition(selectedNode, debuggerContext);
                    if (sourcePosition != null) {
                        sourcePosition.navigate(true);
                    }
                }
            });
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) SourcePosition(com.intellij.debugger.SourcePosition) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 25 with SourcePosition

use of com.intellij.debugger.SourcePosition in project intellij-community by JetBrains.

the class GotoFrameSourceAction method doAction.

protected static void doAction(DataContext dataContext) {
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null)
        return;
    StackFrameDescriptorImpl stackFrameDescriptor = getStackFrameDescriptor(dataContext);
    if (stackFrameDescriptor != null) {
        //DebuggerContextUtil.setStackFrame(getContextManager(dataContext), stackFrameDescriptor.getFrameProxy());
        SourcePosition sourcePosition = stackFrameDescriptor.getSourcePosition();
        if (sourcePosition != null) {
            sourcePosition.navigate(true);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) StackFrameDescriptorImpl(com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl) SourcePosition(com.intellij.debugger.SourcePosition)

Aggregations

SourcePosition (com.intellij.debugger.SourcePosition)36 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)11 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 XSourcePosition (com.intellij.xdebugger.XSourcePosition)7 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)6 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)6 Document (com.intellij.openapi.editor.Document)6 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)5 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)4 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)4 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)4 Location (com.sun.jdi.Location)4 NotNull (org.jetbrains.annotations.NotNull)4 PsiElement (com.intellij.psi.PsiElement)3 DebuggerBundle (com.intellij.debugger.DebuggerBundle)2 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)2 NoDataException (com.intellij.debugger.NoDataException)2