@@ -13,11 +13,14 @@ const _dartCoreLibrary = 'dart:core';
1313const _dartInterceptorsLibrary = 'dart:_interceptors' ;
1414
1515/// A hard-coded ClassRef for the Closure class.
16- final classRefForClosure = classRefFor (_dartCoreLibrary, 'Closure' );
16+ final classRefForClosure = classRefFor (_dartCoreLibrary, InstanceKind .kClosure );
1717
1818/// A hard-coded ClassRef for the String class.
1919final classRefForString = classRefFor (_dartCoreLibrary, InstanceKind .kString);
2020
21+ /// A hard-coded ClassRef for the Record class.
22+ final classRefForRecord = classRefFor (_dartCoreLibrary, InstanceKind .kRecord);
23+
2124/// A hard-coded ClassRef for a (non-existent) class called Unknown.
2225final classRefForUnknown = classRefFor (_dartCoreLibrary, 'Unknown' );
2326
@@ -62,15 +65,22 @@ LibraryRef libraryRefFor(String libraryId) => LibraryRef(
6265
6366/// Returns a [ClassRef] for the provided library ID and class name.
6467ClassRef classRefFor (String libraryId, String ? name) => ClassRef (
65- id: 'classes|$ libraryId |$ name ' ,
68+ id: classIdFor ( libraryId, name) ,
6669 name: name,
6770 library: libraryRefFor (libraryId),
6871 );
6972
73+ String classIdFor (String libraryId, String ? name) => 'classes|$libraryId |$name ' ;
74+
7075/// Meta data for a remote Dart class in Chrome.
7176class ClassMetaData {
7277 static final _logger = Logger ('ClassMetadata' );
7378
79+ /// Class id.
80+ ///
81+ /// Takes the form of 'libraryId:name'.
82+ final String id;
83+
7484 /// The name of the JS constructor for the object.
7585 ///
7686 /// This may be a constructor for a Dart, but it's still a JS name. For
@@ -85,8 +95,8 @@ class ClassMetaData {
8595 /// For example, 'int', 'List<String>', 'Null'
8696 final String ? dartName;
8797
88- /// The library identifier, which is the URI of the library .
89- final String libraryId ;
98+ /// Class ref for the class metadata .
99+ final ClassRef classRef ;
90100
91101 factory ClassMetaData ({
92102 Object ? jsName,
@@ -97,10 +107,18 @@ class ClassMetaData {
97107 bool isRecord = false ,
98108 bool isNativeError = false ,
99109 }) {
110+ final jName = jsName as String ? ;
111+ final dName = dartName as String ? ;
112+ final library = libraryId as String ? ?? _dartCoreLibrary;
113+ final id = '$library :$jName ' ;
114+
115+ final classRef = isRecord ? classRefForRecord : classRefFor (library, dName);
116+
100117 return ClassMetaData ._(
101- jsName as String ? ,
102- libraryId as String ? ?? _dartCoreLibrary,
103- dartName as String ? ,
118+ id,
119+ classRef,
120+ jName,
121+ dName,
104122 int .tryParse ('$length ' ),
105123 isFunction,
106124 isRecord,
@@ -109,20 +127,16 @@ class ClassMetaData {
109127 }
110128
111129 ClassMetaData ._(
130+ this .id,
131+ this .classRef,
112132 this .jsName,
113- this .libraryId,
114133 this .dartName,
115134 this .length,
116135 this .isFunction,
117136 this .isRecord,
118137 this .isNativeError,
119138 );
120139
121- /// Returns the ID of the class.
122- ///
123- /// Takes the form of 'libraryId:name'.
124- String get id => '$libraryId :$jsName ' ;
125-
126140 /// Returns the [ClassMetaData] for the Chrome [remoteObject] .
127141 ///
128142 /// Returns null if the [remoteObject] is not a Dart class.
@@ -189,9 +203,6 @@ class ClassMetaData {
189203 }
190204 }
191205
192- /// Return a [ClassRef] appropriate to this metadata.
193- ClassRef get classRef => classRefFor (libraryId, dartName);
194-
195206 /// True if this class refers to system maps, which are treated specially.
196207 ///
197208 /// Classes that implement Map or inherit from MapBase are still treated as
0 commit comments