use of org.dartlang.vm.service.consumer.GetObjectConsumer in project intellij-plugins by JetBrains.
the class DartVmServiceValue method computeCollectionChildren.
private void computeCollectionChildren(@NotNull final XCompositeNode node) {
final int offset = myCollectionChildrenAlreadyShown.get();
final int count = Math.min(myInstanceRef.getLength() - offset, XCompositeNode.MAX_CHILDREN_TO_SHOW);
myDebugProcess.getVmServiceWrapper().getCollectionObject(myIsolateId, myInstanceRef.getId(), offset, count, new GetObjectConsumer() {
@Override
public void received(Obj instance) {
if (isListKind(myInstanceRef.getKind())) {
addListChildren(node, ((Instance) instance).getElements());
} else if (myInstanceRef.getKind() == InstanceKind.Map) {
addMapChildren(node, ((Instance) instance).getAssociations());
} else {
assert false : myInstanceRef.getKind();
}
myCollectionChildrenAlreadyShown.set(myCollectionChildrenAlreadyShown.get() + count);
if (offset + count < myInstanceRef.getLength()) {
node.tooManyChildren(myInstanceRef.getLength() - offset - count);
}
}
@Override
public void received(Sentinel sentinel) {
node.setErrorMessage(sentinel.getValueAsString());
}
@Override
public void onError(RPCError error) {
node.setErrorMessage(error.getMessage());
}
});
}
use of org.dartlang.vm.service.consumer.GetObjectConsumer in project flutter-intellij by flutter.
the class ScriptManager method getScriptSync.
private Script getScriptSync(@NotNull final ScriptRef scriptRef) {
final Ref<Script> resultRef = Ref.create();
final Semaphore semaphore = new Semaphore();
semaphore.down();
vmService.getObject(isolateRef.getId(), scriptRef.getId(), new GetObjectConsumer() {
@Override
public void received(Obj script) {
resultRef.set((Script) script);
semaphore.up();
}
@Override
public void received(Sentinel response) {
semaphore.up();
}
@Override
public void onError(RPCError error) {
semaphore.up();
}
});
semaphore.waitFor(RESPONSE_WAIT_TIMEOUT);
return resultRef.get();
}
use of org.dartlang.vm.service.consumer.GetObjectConsumer in project flutter-intellij by flutter.
the class CanonicalBreakpoint method getScriptSync.
@Nullable
public Script getScriptSync(@NotNull final String isolateId, @NotNull final String scriptId) {
assertSyncRequestAllowed();
final Semaphore semaphore = new Semaphore();
semaphore.down();
final Ref<Script> resultRef = Ref.create();
addRequest(() -> myVmService.getObject(isolateId, scriptId, new GetObjectConsumer() {
@Override
public void received(Obj script) {
resultRef.set((Script) script);
semaphore.up();
}
@Override
public void received(Sentinel response) {
semaphore.up();
}
@Override
public void onError(RPCError error) {
semaphore.up();
}
}));
semaphore.waitFor(RESPONSE_WAIT_TIMEOUT);
return resultRef.get();
}
use of org.dartlang.vm.service.consumer.GetObjectConsumer in project flutter-intellij by flutter.
the class DartStaticFieldsGroup method computeChildren.
@Override
public void computeChildren(@NotNull final XCompositeNode node) {
final AtomicInteger counter = new AtomicInteger(myFieldRefs.size());
final XValueChildrenList list = new XValueChildrenList(myFieldRefs.size());
for (final FieldRef fieldRef : myFieldRefs) {
myDebugProcess.getVmServiceWrapper().getObject(myIsolateId, fieldRef.getId(), new GetObjectConsumer() {
@Override
public void received(Obj field) {
final InstanceRef instanceRef = ((Field) field).getStaticValue();
// static field may be not initialized yet, in this case this instanceRef is in fact a Sentinel
if ("@Instance".equals(instanceRef.getType())) {
list.add(new DartVmServiceValue(myDebugProcess, myIsolateId, ((Field) field).getName(), instanceRef, null, fieldRef, false));
} else if ("Sentinel".equals(instanceRef.getType())) {
list.add(new XNamedValue(((Field) field).getName()) {
@Override
public void computeSourcePosition(@NotNull XNavigatable navigatable) {
DartVmServiceValue.doComputeSourcePosition(myDebugProcess, navigatable, myIsolateId, fieldRef);
}
@Override
public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
final JsonElement valueAsString = instanceRef.getJson().get("valueAsString");
final String value = valueAsString == null ? "not initialized" : valueAsString.getAsString();
node.setPresentation(AllIcons.Nodes.Field, null, value, false);
}
});
}
if (counter.decrementAndGet() == 0) {
if (list.size() == 0) {
node.setErrorMessage("Static fields not initialized yet");
} else {
node.addChildren(list, true);
}
}
}
@Override
public void received(Sentinel sentinel) {
node.setErrorMessage(sentinel.getValueAsString());
}
@Override
public void onError(RPCError error) {
node.setErrorMessage(error.getMessage());
}
});
}
}
use of org.dartlang.vm.service.consumer.GetObjectConsumer in project flutter-intellij by flutter.
the class DartVmServiceStackFrame method addStaticFieldsIfPresentAndThenAllVars.
private void addStaticFieldsIfPresentAndThenAllVars(@NotNull final XCompositeNode node, @Nullable final BoundVariable thisVar, @NotNull final ElementList<BoundVariable> vars) {
if (thisVar == null) {
addVars(node, vars);
return;
}
final Object thisVarValue = thisVar.getValue();
if (!(thisVarValue instanceof InstanceRef)) {
addVars(node, vars);
return;
}
// InstanceRef
final ClassRef classRef = ((InstanceRef) thisVarValue).getClassRef();
myDebugProcess.getVmServiceWrapper().getObject(myIsolateId, classRef.getId(), new GetObjectConsumer() {
@Override
public void received(Obj classObj) {
final SmartList<FieldRef> staticFields = new SmartList<>();
for (FieldRef fieldRef : ((ClassObj) classObj).getFields()) {
if (fieldRef.isStatic()) {
staticFields.add(fieldRef);
}
}
if (!staticFields.isEmpty()) {
final XValueChildrenList list = new XValueChildrenList();
list.addTopGroup(new DartStaticFieldsGroup(myDebugProcess, myIsolateId, ((ClassObj) classObj).getName(), staticFields));
node.addChildren(list, false);
}
addVars(node, vars);
}
@Override
public void received(Sentinel sentinel) {
node.setErrorMessage(sentinel.getValueAsString());
}
@Override
public void onError(RPCError error) {
node.setErrorMessage(error.getMessage());
}
});
}
Aggregations