@@ -128,6 +128,14 @@ class InstanceHelper extends Domain {
128128 } else if (metaData.isRecord) {
129129 return await _recordInstanceFor (classRef, remoteObject,
130130 offset: offset, count: count, length: metaData.length);
131+ } else if (metaData.isSet) {
132+ return await _setInstanceFor (
133+ classRef,
134+ remoteObject,
135+ offset: offset,
136+ count: count,
137+ length: metaData.length,
138+ );
131139 } else if (metaData.isNativeError) {
132140 return await _plainInstanceFor (classRefForNativeJsError, remoteObject,
133141 offset: offset, count: count, length: metaData.length);
@@ -376,7 +384,7 @@ class InstanceHelper extends Domain {
376384 ///
377385 /// If [offset] is `null` , assumes 0 offset.
378386 /// If [count] is `null` , return all fields starting from the offset.
379- Future <List <BoundField >> _recordFields (RemoteObject map ,
387+ Future <List <BoundField >> _recordFields (RemoteObject record ,
380388 {int ? offset, int ? count}) async {
381389 // We do this in in awkward way because we want the keys and values, but we
382390 // can't return things by value or some Dart objects will come back as
@@ -398,7 +406,7 @@ class InstanceHelper extends Domain {
398406 };
399407 }
400408 ''' ;
401- final result = await inspector.jsCallFunctionOn (map , expression, []);
409+ final result = await inspector.jsCallFunctionOn (record , expression, []);
402410 final positionalCountObject =
403411 await inspector.loadField (result, 'positionalCount' );
404412 if (positionalCountObject == null || positionalCountObject.value is ! int ) {
@@ -494,6 +502,51 @@ class InstanceHelper extends Domain {
494502 ..fields = fields;
495503 }
496504
505+ Future <Instance ?> _setInstanceFor (
506+ ClassRef classRef,
507+ RemoteObject remoteObject, {
508+ int ? offset,
509+ int ? count,
510+ int ? length,
511+ }) async {
512+ final objectId = remoteObject.objectId;
513+ if (objectId == null ) return null ;
514+
515+ final expression = '''
516+ function() {
517+ const sdkUtils = ${globalLoadStrategy .loadModuleSnippet }('dart_sdk').dart;
518+ const jsSet = sdkUtils.dloadRepl(this, "_map");
519+ const entries = [...jsSet.values()];
520+ return {
521+ entries: entries
522+ };
523+ }
524+ ''' ;
525+
526+ final result =
527+ await inspector.jsCallFunctionOn (remoteObject, expression, []);
528+ final entriesObject = await inspector.loadField (result, 'entries' );
529+ final entriesInstance =
530+ await instanceFor (entriesObject, offset: offset, count: count);
531+ final elements = entriesInstance? .elements ?? [];
532+
533+ final setInstance = Instance (
534+ identityHashCode: remoteObject.objectId.hashCode,
535+ kind: InstanceKind .kSet,
536+ id: objectId,
537+ classRef: classRef)
538+ ..length = length
539+ ..elements = elements;
540+ if (offset != null && offset > 0 ) {
541+ setInstance.offset = offset;
542+ }
543+ if (length != null && elements.length < length) {
544+ setInstance.count = elements.length;
545+ }
546+
547+ return setInstance;
548+ }
549+
497550 /// Return the available count of elements in the requested range.
498551 /// Return `null` if the range includes the whole object.
499552 /// [count] is the range length requested by the `getObject` call.
@@ -633,6 +686,14 @@ class InstanceHelper extends Domain {
633686 classRef: metaData.classRef)
634687 ..length = metaData.length;
635688 }
689+ if (metaData.isSet) {
690+ return InstanceRef (
691+ kind: InstanceKind .kSet,
692+ id: objectId,
693+ identityHashCode: remoteObject.objectId.hashCode,
694+ classRef: metaData.classRef)
695+ ..length = metaData.length;
696+ }
636697 if (metaData.isNativeError) {
637698 return InstanceRef (
638699 kind: InstanceKind .kPlainInstance,
0 commit comments