in dwds/lib/src/debugging/instance.dart [349:426]
Future<InstanceRef> _instanceRefForRemote(RemoteObject remoteObject) async {
// If we have a null result, treat it as a reference to null.
if (remoteObject == null) {
return kNullInstanceRef;
}
switch (remoteObject.type) {
case 'string':
var stringValue = remoteObject.value as String;
// TODO: Support truncation for long strings.
// TODO(#777): dartIdFor() will return an ID containing the entire
// string, even if we're truncating the string value here.
return InstanceRef(
identityHashCode: dartIdFor(remoteObject.value).hashCode,
id: dartIdFor(remoteObject.value),
classRef: classRefForString,
kind: InstanceKind.kString)
..valueAsString = stringValue
..length = stringValue.length;
case 'number':
return _primitiveInstanceRef(InstanceKind.kDouble, remoteObject);
case 'boolean':
return _primitiveInstanceRef(InstanceKind.kBool, remoteObject);
case 'undefined':
return _primitiveInstanceRef(InstanceKind.kNull, remoteObject);
case 'object':
if (remoteObject.objectId == null) {
return _primitiveInstanceRef(InstanceKind.kNull, remoteObject);
}
var metaData = await ClassMetaData.metaDataFor(
inspector.remoteDebugger, remoteObject, inspector);
if (metaData == null) return null;
if (metaData.isSystemList) {
return InstanceRef(
kind: InstanceKind.kList,
id: remoteObject.objectId,
identityHashCode: remoteObject.objectId.hashCode,
classRef: metaData.classRef)
..length = metaData.length;
}
if (metaData.isSystemMap) {
return InstanceRef(
kind: InstanceKind.kMap,
id: remoteObject.objectId,
identityHashCode: remoteObject.objectId.hashCode,
classRef: metaData.classRef)
..length = metaData.length;
}
return InstanceRef(
kind: InstanceKind.kPlainInstance,
id: remoteObject.objectId,
identityHashCode: remoteObject.objectId.hashCode,
classRef: metaData.classRef);
case 'function':
var functionMetaData = await FunctionMetaData.metaDataFor(
inspector.remoteDebugger, remoteObject);
return InstanceRef(
kind: InstanceKind.kClosure,
id: remoteObject.objectId,
identityHashCode: remoteObject.objectId.hashCode,
classRef: classRefForClosure)
// TODO(grouma) - fill this in properly.
..closureFunction = FuncRef(
name: functionMetaData.name,
id: createId(),
// TODO(alanknight): The right ClassRef
owner: classRefForUnknown,
isConst: false,
isStatic: false,
// TODO(annagrin): get information about getters and setters from symbols.
// https://github.com/dart-lang/sdk/issues/46723
implicit: false)
..closureContext = (ContextRef(length: 0, id: createId()));
default:
// Return null for an unsupported type. This is likely a JS construct.
return null;
}
}