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);
}
}
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;
}
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();
}
}
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;
}
}
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;
}
Aggregations