Search in sources :

Example 1 with DartVmServiceValue

use of com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceValue in project intellij-plugins by JetBrains.

the class DartVmServiceListener method evaluateExpression.

@Nullable
private String evaluateExpression(@NotNull final String isolateId, @Nullable final Frame vmTopFrame, @Nullable final XExpression xExpression) {
    final String evalText = xExpression == null ? null : xExpression.getExpression();
    if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText))
        return null;
    final Ref<String> evalResult = new Ref<>();
    final Semaphore semaphore = new Semaphore();
    semaphore.down();
    myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() {

        @Override
        public void evaluated(@NotNull final XValue result) {
            if (result instanceof DartVmServiceValue) {
                evalResult.set(getSimpleStringPresentation(((DartVmServiceValue) result).getInstanceRef()));
            }
            semaphore.up();
        }

        @Override
        public void errorOccurred(@NotNull final String errorMessage) {
            evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage);
            semaphore.up();
        }
    });
    semaphore.waitFor(1000);
    return evalResult.get();
}
Also used : DartVmServiceValue(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceValue) Ref(com.intellij.openapi.util.Ref) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) Semaphore(com.intellij.util.concurrency.Semaphore) XValue(com.intellij.xdebugger.frame.XValue) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Ref (com.intellij.openapi.util.Ref)1 Semaphore (com.intellij.util.concurrency.Semaphore)1 XDebuggerEvaluator (com.intellij.xdebugger.evaluation.XDebuggerEvaluator)1 XValue (com.intellij.xdebugger.frame.XValue)1 DartVmServiceValue (com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceValue)1 Nullable (org.jetbrains.annotations.Nullable)1