Search in sources :

Example 11 with GetObjectConsumer

use of org.dartlang.vm.service.consumer.GetObjectConsumer in project flutter-intellij by flutter.

the class FlutterConsoleLogManager method getFullStringValue.

private String getFullStringValue(@NotNull VmService service, String isolateId, @Nullable InstanceRef ref) {
    if (ref == null)
        return null;
    if (!ref.getValueAsStringIsTruncated()) {
        return ref.getValueAsString();
    }
    final CountDownLatch latch = new CountDownLatch(1);
    final String[] result = new String[1];
    service.getObject(isolateId, ref.getId(), 0, ref.getLength(), new GetObjectConsumer() {

        @Override
        public void onError(RPCError error) {
            result[0] = formatTruncatedString(ref);
            latch.countDown();
        }

        @Override
        public void received(Obj response) {
            if (response instanceof Instance && ((Instance) response).getKind() == InstanceKind.String) {
                result[0] = stringValueFromStringRef((Instance) response);
            } else {
                result[0] = formatTruncatedString(ref);
            }
            latch.countDown();
        }

        @Override
        public void received(Sentinel response) {
            result[0] = formatTruncatedString(ref);
            latch.countDown();
        }
    });
    try {
        latch.await(1, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        return null;
    }
    return result[0];
}
Also used : GetObjectConsumer(org.dartlang.vm.service.consumer.GetObjectConsumer) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

GetObjectConsumer (org.dartlang.vm.service.consumer.GetObjectConsumer)11 JsonElement (com.google.gson.JsonElement)2 Project (com.intellij.openapi.project.Project)2 Semaphore (com.intellij.util.concurrency.Semaphore)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 OpenFileHyperlinkInfo (com.intellij.execution.filters.OpenFileHyperlinkInfo)1 Editor (com.intellij.openapi.editor.Editor)1 FileEditorLocation (com.intellij.openapi.fileEditor.FileEditorLocation)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 TextEditorLocation (com.intellij.openapi.fileEditor.TextEditorLocation)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 SmartList (com.intellij.util.SmartList)1 XValue (com.intellij.xdebugger.frame.XValue)1 XValueChildrenList (com.intellij.xdebugger.frame.XValueChildrenList)1 VmServiceWrapper (io.flutter.vmService.VmServiceWrapper)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1