Search in sources :

Example 11 with SuspendContextCommandImpl

use of com.intellij.debugger.engine.events.SuspendContextCommandImpl in project intellij-community by JetBrains.

the class DebuggerManagerThreadImpl method invokeCommand.

@Override
public void invokeCommand(final DebuggerCommand command) {
    if (command instanceof SuspendContextCommand) {
        SuspendContextCommand suspendContextCommand = (SuspendContextCommand) command;
        schedule(new SuspendContextCommandImpl((SuspendContextImpl) suspendContextCommand.getSuspendContext()) {

            @Override
            public void contextAction() throws Exception {
                command.action();
            }

            @Override
            protected void commandCancelled() {
                command.commandCancelled();
            }
        });
    } else {
        schedule(new DebuggerCommandImpl() {

            @Override
            protected void action() throws Exception {
                command.action();
            }

            @Override
            protected void commandCancelled() {
                command.commandCancelled();
            }
        });
    }
}
Also used : SuspendContextCommand(com.intellij.debugger.engine.managerThread.SuspendContextCommand) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) VMDisconnectedException(com.sun.jdi.VMDisconnectedException)

Example 12 with SuspendContextCommandImpl

use of com.intellij.debugger.engine.events.SuspendContextCommandImpl in project intellij-community by JetBrains.

the class JavaValueModifier method set.

protected void set(@NotNull final String expression, final XModificationCallback callback, final DebuggerContextImpl debuggerContext, final SetValueRunnable setValueRunnable) {
    final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, debuggerContext.getProject());
    final EvaluationContextImpl evaluationContext = myJavaValue.getEvaluationContext();
    SuspendContextCommandImpl askSetAction = new DebuggerContextCommandImpl(debuggerContext) {

        public Priority getPriority() {
            return Priority.HIGH;
        }

        public void threadAction(@NotNull SuspendContextImpl suspendContext) {
            ExpressionEvaluator evaluator;
            try {
                Project project = evaluationContext.getProject();
                SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
                PsiElement context = ContextUtil.getContextElement(evaluationContext, position);
                evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, new EvaluatingComputable<ExpressionEvaluator>() {

                    public ExpressionEvaluator compute() throws EvaluateException {
                        return EvaluatorBuilderImpl.build(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression), context, position, project);
                    }
                });
                setValue(expression, evaluator, evaluationContext, new SetValueRunnable() {

                    public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException, IncompatibleThreadStateException {
                        if (!progressWindow.isCanceled()) {
                            setValueRunnable.setValue(evaluationContext, newValue);
                        //node.calcValue();
                        }
                    }

                    public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, EvaluateException, IncompatibleThreadStateException, InvalidTypeException {
                        return setValueRunnable.loadClass(evaluationContext, className);
                    }
                });
                callback.valueModified();
            } catch (EvaluateException e) {
                callback.errorOccurred(e.getMessage());
            }
        //String initialString = "";
        //if (descriptor instanceof ValueDescriptorImpl) {
        //  Value currentValue = ((ValueDescriptorImpl) descriptor).getValue();
        //  if (currentValue instanceof StringReference) {
        //    initialString = DebuggerUtilsEx.getValueOrErrorAsString(debuggerContext.createEvaluationContext(), currentValue);
        //    initialString = initialString == null ? "" : "\"" + DebuggerUtilsEx.translateStringValue(initialString) + "\"";
        //  }
        //  else if (currentValue instanceof PrimitiveValue) {
        //    ValueLabelRenderer renderer = ((ValueDescriptorImpl) descriptor).getRenderer(debuggerContext.getDebugProcess());
        //    initialString = getDisplayableString((PrimitiveValue) currentValue, renderer instanceof NodeRenderer && HexRenderer.UNIQUE_ID.equals(renderer.getUniqueId()));
        //  }
        //
        //  final String initialString1 = initialString;
        //  final Project project = debuggerContext.getProject();
        //  DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
        //    public void run() {
        //      showEditor(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, initialString1), node, debuggerContext, setValueRunnable);
        //    }
        //  });
        //}
        }
    };
    progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
    evaluationContext.getDebugProcess().getManagerThread().startProgress(askSetAction, progressWindow);
}
Also used : ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) NotNull(org.jetbrains.annotations.NotNull) EvaluatingComputable(com.intellij.debugger.EvaluatingComputable) Project(com.intellij.openapi.project.Project) SourcePosition(com.intellij.debugger.SourcePosition) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl) PsiElement(com.intellij.psi.PsiElement)

Example 13 with SuspendContextCommandImpl

use of com.intellij.debugger.engine.events.SuspendContextCommandImpl in project intellij-community by JetBrains.

the class ValueDescriptorImpl method getValue.

@Override
public Value getValue() {
    // to keep temporary objects
    if (Patches.IBM_JDK_DISABLE_COLLECTION_BUG) {
        final EvaluationContextImpl evalContext = myStoredEvaluationContext;
        if (evalContext != null && !evalContext.getSuspendContext().isResumed() && myValue instanceof ObjectReference && VirtualMachineProxyImpl.isCollected((ObjectReference) myValue)) {
            final Semaphore semaphore = new Semaphore();
            semaphore.down();
            evalContext.getDebugProcess().getManagerThread().invoke(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {

                @Override
                public void contextAction() throws Exception {
                    // re-setting the context will cause value recalculation
                    try {
                        setContext(myStoredEvaluationContext);
                    } finally {
                        semaphore.up();
                    }
                }

                @Override
                protected void commandCancelled() {
                    semaphore.up();
                }
            });
            semaphore.waitFor();
        }
    }
    assertValueReady();
    return myValue;
}
Also used : EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) Semaphore(com.intellij.util.concurrency.Semaphore) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException)

Example 14 with SuspendContextCommandImpl

use of com.intellij.debugger.engine.events.SuspendContextCommandImpl in project intellij-community by JetBrains.

the class IconObjectRenderer method calcValueIcon.

@Override
public Icon calcValueIcon(final ValueDescriptor descriptor, final EvaluationContext evaluationContext, final DescriptorLabelListener listener) throws EvaluateException {
    EvaluationContextImpl evalContext = ((EvaluationContextImpl) evaluationContext);
    DebugProcessImpl debugProcess = evalContext.getDebugProcess();
    if (!Registry.is("debugger.auto.fetch.icons") || DebuggerUtilsImpl.isRemote(debugProcess))
        return null;
    debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {

        @Override
        public void contextAction() throws Exception {
            String getterName = AllIcons.Debugger.Value.getIconHeight() <= 16 ? "iconToBytesPreviewNormal" : "iconToBytesPreviewRetina";
            descriptor.setValueIcon(ImageObjectRenderer.getIcon(evaluationContext, descriptor.getValue(), getterName));
            listener.labelChanged();
        }
    });
    return null;
}
Also used : EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException)

Aggregations

SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)14 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)9 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)3 NotNull (org.jetbrains.annotations.NotNull)3 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)2 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)2 ExecutionException (com.intellij.execution.ExecutionException)2 Project (com.intellij.openapi.project.Project)2 PsiElement (com.intellij.psi.PsiElement)2 CompoundRuntimeException (com.intellij.util.lang.CompoundRuntimeException)2 VMDisconnectedException (com.sun.jdi.VMDisconnectedException)2 EvaluatingComputable (com.intellij.debugger.EvaluatingComputable)1 NoDataException (com.intellij.debugger.NoDataException)1 SourcePosition (com.intellij.debugger.SourcePosition)1 JavaValue (com.intellij.debugger.engine.JavaValue)1 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)1 TextWithImportsImpl (com.intellij.debugger.engine.evaluation.TextWithImportsImpl)1 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)1 SuspendContextCommand (com.intellij.debugger.engine.managerThread.SuspendContextCommand)1 LocatableEventRequestor (com.intellij.debugger.engine.requests.LocatableEventRequestor)1