final EvaluateContext evaluateContext =
(EvaluateContext) contextImpl.getAdapter(EvaluateContext.class);
if (evaluateContext == null) {
listener.watchEvaluationFinished(new BadWatchExpressionResult(
new DebugException(new Status(Status.ERROR,
ChromiumDebugUIPlugin.PLUGIN_ID,"Bad debug context")), //$NON-NLS-1$
expression));
return;
}
evaluateContext.getJsEvaluateContext().evaluateAsync(
expression, null,
new JsEvaluateContext.EvaluateCallback() {
@Override
public void success(ResultOrException result) {
ValueBase valueBase = result.accept(new ResultOrException.Visitor<ValueBase>() {
@Override public ValueBase visitResult(JsValue value) {
return Value.create(evaluateContext, value,
ExpressionTracker.createExpressionNode(expression));
}
@Override
public ValueBase visitException(JsValue exception) {
return new ValueBase.ErrorMessageValue(evaluateContext, "<abnormal return>",
exception);
}
});
listener.watchEvaluationFinished(new GoodWatchExpressionResult(valueBase, expression));
}
@Override
public void failure(Exception cause) {
String message = cause.getMessage();
listener.watchEvaluationFinished(new BadWatchExpressionResult(new DebugException(
createErrorStatus(message == null
? Messages.JsWatchExpressionDelegate_ErrorEvaluatingExpression
: message, null)), expression));
return;
}