Search in sources :

Example 1 with DebuggerContextImpl

use of com.intellij.debugger.impl.DebuggerContextImpl in project smali by JesusFreke.

the class LazyValue method virtualMachine.

@Override
public VirtualMachine virtualMachine() {
    if (evaluationContext != null) {
        return ((VirtualMachineProxyImpl) evaluationContext.getDebugProcess().getVirtualMachineProxy()).getVirtualMachine();
    } else {
        final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
        final DebugProcessImpl process = debuggerContext.getDebugProcess();
        if (process != null) {
            return process.getVirtualMachineProxy().getVirtualMachine();
        }
    }
    return null;
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 2 with DebuggerContextImpl

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

the class ValueHint method createInspectTree.

public static InspectDebuggerTree createInspectTree(final NodeDescriptorImpl descriptor, Project project) {
    final InspectDebuggerTree tree = new InspectDebuggerTree(project);
    final AnAction setValueAction = ActionManager.getInstance().getAction(DebuggerActions.SET_VALUE);
    setValueAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), tree);
    Disposer.register(tree, new Disposable() {

        @Override
        public void dispose() {
            setValueAction.unregisterCustomShortcutSet(tree);
        }
    });
    tree.setInspectDescriptor(descriptor);
    DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(project).getContext();
    tree.rebuild(context);
    return tree;
}
Also used : Disposable(com.intellij.openapi.Disposable) CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) InspectDebuggerTree(com.intellij.debugger.ui.impl.InspectDebuggerTree) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 3 with DebuggerContextImpl

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

the class DebuggerTreeCreatorImpl method createDescriptorByNode.

@Override
public void createDescriptorByNode(Object node, final ResultConsumer<Pair<NodeDescriptorImpl, String>> resultConsumer) {
    if (node instanceof DebuggerTreeNodeImpl) {
        final DebuggerTreeNodeImpl debuggerTreeNode = (DebuggerTreeNodeImpl) node;
        final DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
        context.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(context) {

            @Override
            public void threadAction() {
                try {
                    final TextWithImports evaluationText = DebuggerTreeNodeExpression.createEvaluationText(debuggerTreeNode, context);
                    resultConsumer.onSuccess(Pair.create(debuggerTreeNode.getDescriptor(), evaluationText.getText()));
                } catch (EvaluateException e) {
                    resultConsumer.onFailure(e);
                }
            }
        });
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) TextWithImports(com.intellij.debugger.engine.evaluation.TextWithImports) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 4 with DebuggerContextImpl

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

the class BreakpointWithHighlighter method updateUI.

/**
   * updates the state of breakpoint and all the related UI widgets etc
   */
@Override
public final void updateUI() {
    if (!isVisible() || ApplicationManager.getApplication().isUnitTestMode()) {
        return;
    }
    DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
        if (!isValid()) {
            return;
        }
        DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
        DebugProcessImpl debugProcess = context.getDebugProcess();
        if (debugProcess == null || !debugProcess.isAttached()) {
            updateCaches(null);
            updateGutter();
        } else {
            debugProcess.getManagerThread().invoke(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    ApplicationManager.getApplication().runReadAction(() -> {
                        if (!myProject.isDisposed()) {
                            updateCaches(debugProcess);
                        }
                    });
                    DebuggerInvocationUtil.swingInvokeLater(myProject, BreakpointWithHighlighter.this::updateGutter);
                }
            });
        }
    });
}
Also used : DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 5 with DebuggerContextImpl

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

the class DefaultCodeFragmentFactory method createCodeFragment.

public JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, final Project project) {
    final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project);
    final String text = item.getText();
    final JavaCodeFragment fragment;
    if (CodeFragmentKind.EXPRESSION == item.getKind()) {
        final String expressionText = StringUtil.endsWithChar(text, ';') ? text.substring(0, text.length() - 1) : text;
        fragment = factory.createExpressionCodeFragment(expressionText, context, null, true);
    } else /*if (CodeFragmentKind.CODE_BLOCK == item.getKind())*/
    {
        fragment = factory.createCodeBlockCodeFragment(text, context, true);
    }
    if (item.getImports().length() > 0) {
        fragment.addImportsFromString(item.getImports());
    }
    fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
    //noinspection HardCodedStringLiteral
    fragment.putUserData(KEY, "DebuggerComboBoxEditor.IS_DEBUGGER_EDITOR");
    fragment.putCopyableUserData(JavaCompletionUtil.DYNAMIC_TYPE_EVALUATOR, (expression, parameters) -> {
        if (!RuntimeTypeEvaluator.isSubtypeable(expression)) {
            return null;
        }
        if (parameters.getInvocationCount() <= 1 && JavaCompletionUtil.mayHaveSideEffects(expression)) {
            final CompletionService service = CompletionService.getCompletionService();
            if (parameters.getInvocationCount() < 2) {
                service.setAdvertisementText("Invoke completion once more to see runtime type variants");
            }
            return null;
        }
        final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
        DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
        if (debuggerSession != null && debuggerContext.getSuspendContext() != null) {
            final Semaphore semaphore = new Semaphore();
            semaphore.down();
            final AtomicReference<PsiType> nameRef = new AtomicReference<>();
            final RuntimeTypeEvaluator worker = new RuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().getProgressIndicator()) {

                @Override
                protected void typeCalculationFinished(@Nullable PsiType type) {
                    nameRef.set(type);
                    semaphore.up();
                }
            };
            debuggerSession.getProcess().getManagerThread().invoke(worker);
            for (int i = 0; i < 50; i++) {
                ProgressManager.checkCanceled();
                if (semaphore.waitFor(20))
                    break;
            }
            return nameRef.get();
        }
        return null;
    });
    return fragment;
}
Also used : RuntimeTypeEvaluator(com.intellij.debugger.codeinsight.RuntimeTypeEvaluator) AtomicReference(java.util.concurrent.atomic.AtomicReference) Semaphore(com.intellij.util.concurrency.Semaphore) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) CompletionService(com.intellij.codeInsight.completion.CompletionService) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)42 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)20 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)12 Project (com.intellij.openapi.project.Project)12 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)11 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)11 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)10 JavaValue (com.intellij.debugger.engine.JavaValue)9 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)8 NotNull (org.jetbrains.annotations.NotNull)7 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)6 SourcePosition (com.intellij.debugger.SourcePosition)5 JavaValueModifier (com.intellij.debugger.engine.JavaValueModifier)5 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)5 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)5 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)4 ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)4 List (java.util.List)4 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)3 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)3