Search in sources :

Example 1 with EvaluationContext

use of com.intellij.debugger.engine.evaluation.EvaluationContext in project intellij-community by JetBrains.

the class BatchEvaluator method invoke.

public void invoke(ToStringCommand command) {
    LOG.assertTrue(DebuggerManager.getInstance(myDebugProcess.getProject()).isDebuggerManagerThread());
    final EvaluationContext evaluationContext = command.getEvaluationContext();
    final SuspendContext suspendContext = evaluationContext.getSuspendContext();
    if (!Registry.is("debugger.batch.evaluation") || !hasBatchEvaluator(evaluationContext)) {
        myDebugProcess.getManagerThread().invokeCommand(command);
    } else {
        List<ToStringCommand> toStringCommands = myBuffer.get(suspendContext);
        if (toStringCommands == null) {
            final List<ToStringCommand> commands = new ArrayList<>();
            toStringCommands = commands;
            myBuffer.put(suspendContext, commands);
            myDebugProcess.getManagerThread().invokeCommand(new SuspendContextCommand() {

                public SuspendContext getSuspendContext() {
                    return suspendContext;
                }

                public void action() {
                    myBuffer.remove(suspendContext);
                    if (!doEvaluateBatch(commands, evaluationContext)) {
                        commands.forEach(ToStringCommand::action);
                    }
                }

                public void commandCancelled() {
                    myBuffer.remove(suspendContext);
                }
            });
        }
        toStringCommands.add(command);
    }
}
Also used : SuspendContextCommand(com.intellij.debugger.engine.managerThread.SuspendContextCommand) ArrayList(java.util.ArrayList) EvaluationContext(com.intellij.debugger.engine.evaluation.EvaluationContext)

Example 2 with EvaluationContext

use of com.intellij.debugger.engine.evaluation.EvaluationContext in project intellij-community by JetBrains.

the class ImageObjectRenderer method getImageBytes.

private static Value getImageBytes(EvaluationContext evaluationContext, Value obj, String methodName) throws EvaluateException {
    DebugProcess process = evaluationContext.getDebugProcess();
    EvaluationContext copyContext = evaluationContext.createEvaluationContext(obj);
    ClassType helperClass = ClassLoadingUtils.getHelperClass(ImageSerializer.class.getName(), copyContext, process);
    if (helperClass != null) {
        List<Method> methods = helperClass.methodsByName(methodName);
        if (!methods.isEmpty()) {
            return process.invokeMethod(copyContext, helperClass, methods.get(0), Collections.singletonList(obj));
        }
    }
    return null;
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess) EvaluationContext(com.intellij.debugger.engine.evaluation.EvaluationContext) ImageSerializer(com.intellij.rt.debugger.ImageSerializer)

Example 3 with EvaluationContext

use of com.intellij.debugger.engine.evaluation.EvaluationContext in project android by JetBrains.

the class ArrayMapRendererBase method getArrayMapSize.

private int getArrayMapSize(Value arrayMapValue, EvaluationContext context) throws InvalidTypeException, EvaluateException {
    EvaluationContext evaluationContext = context.createEvaluationContext(arrayMapValue);
    Value v = mySizeEvaluator.evaluate(evaluationContext.getProject(), evaluationContext);
    if (v instanceof IntegerValue) {
        return ((IntegerValue) v).intValue();
    } else {
        throw new InvalidTypeException();
    }
}
Also used : EvaluationContext(com.intellij.debugger.engine.evaluation.EvaluationContext)

Example 4 with EvaluationContext

use of com.intellij.debugger.engine.evaluation.EvaluationContext in project intellij-community by JetBrains.

the class ExpressionChildrenRenderer method isExpandable.

public boolean isExpandable(Value value, final EvaluationContext context, NodeDescriptor parentDescriptor) {
    final EvaluationContext evaluationContext = context.createEvaluationContext(value);
    if (!StringUtil.isEmpty(myChildrenExpandable.getReferenceExpression().getText())) {
        try {
            Value expanded = myChildrenExpandable.getEvaluator(evaluationContext.getProject()).evaluate(evaluationContext);
            if (expanded instanceof BooleanValue) {
                return ((BooleanValue) expanded).booleanValue();
            }
        } catch (EvaluateException e) {
        // ignored
        }
    }
    try {
        Value children = evaluateChildren(evaluationContext, parentDescriptor);
        ChildrenRenderer defaultChildrenRenderer = DebugProcessImpl.getDefaultRenderer(value.type());
        return defaultChildrenRenderer.isExpandable(children, evaluationContext, parentDescriptor);
    } catch (EvaluateException e) {
        return true;
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) BooleanValue(com.sun.jdi.BooleanValue) BooleanValue(com.sun.jdi.BooleanValue) Value(com.sun.jdi.Value) EvaluationContext(com.intellij.debugger.engine.evaluation.EvaluationContext)

Example 5 with EvaluationContext

use of com.intellij.debugger.engine.evaluation.EvaluationContext in project intellij-community by JetBrains.

the class LabelRenderer method calcLabel.

public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener) throws EvaluateException {
    final Value value = descriptor.getValue();
    String result;
    final DebugProcess debugProcess = evaluationContext.getDebugProcess();
    if (value != null) {
        try {
            final ExpressionEvaluator evaluator = myLabelExpression.getEvaluator(debugProcess.getProject());
            if (!debugProcess.isAttached()) {
                throw EvaluateExceptionUtil.PROCESS_EXITED;
            }
            EvaluationContext thisEvaluationContext = evaluationContext.createEvaluationContext(value);
            Value labelValue = evaluator.evaluate(thisEvaluationContext);
            result = DebuggerUtils.getValueAsString(thisEvaluationContext, labelValue);
        } catch (final EvaluateException ex) {
            throw new EvaluateException(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + ex.getMessage(), ex);
        }
    } else {
        //noinspection HardCodedStringLiteral
        result = "null";
    }
    return result;
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) Value(com.sun.jdi.Value) EvaluationContext(com.intellij.debugger.engine.evaluation.EvaluationContext) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)

Aggregations

EvaluationContext (com.intellij.debugger.engine.evaluation.EvaluationContext)5 DebugProcess (com.intellij.debugger.engine.DebugProcess)2 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 Value (com.sun.jdi.Value)2 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)1 SuspendContextCommand (com.intellij.debugger.engine.managerThread.SuspendContextCommand)1 ImageSerializer (com.intellij.rt.debugger.ImageSerializer)1 BooleanValue (com.sun.jdi.BooleanValue)1 ArrayList (java.util.ArrayList)1