@@ -13,11 +13,14 @@ const _dartCoreLibrary = 'dart:core';
13
13
const _dartInterceptorsLibrary = 'dart:_interceptors' ;
14
14
15
15
/// A hard-coded ClassRef for the Closure class.
16
- final classRefForClosure = classRefFor (_dartCoreLibrary, 'Closure' );
16
+ final classRefForClosure = classRefFor (_dartCoreLibrary, InstanceKind .kClosure );
17
17
18
18
/// A hard-coded ClassRef for the String class.
19
19
final classRefForString = classRefFor (_dartCoreLibrary, InstanceKind .kString);
20
20
21
+ /// A hard-coded ClassRef for the Record class.
22
+ final classRefForRecord = classRefFor (_dartCoreLibrary, InstanceKind .kRecord);
23
+
21
24
/// A hard-coded ClassRef for a (non-existent) class called Unknown.
22
25
final classRefForUnknown = classRefFor (_dartCoreLibrary, 'Unknown' );
23
26
@@ -62,15 +65,22 @@ LibraryRef libraryRefFor(String libraryId) => LibraryRef(
62
65
63
66
/// Returns a [ClassRef] for the provided library ID and class name.
64
67
ClassRef classRefFor (String libraryId, String ? name) => ClassRef (
65
- id: 'classes|$ libraryId |$ name ' ,
68
+ id: classIdFor ( libraryId, name) ,
66
69
name: name,
67
70
library: libraryRefFor (libraryId),
68
71
);
69
72
73
+ String classIdFor (String libraryId, String ? name) => 'classes|$libraryId |$name ' ;
74
+
70
75
/// Meta data for a remote Dart class in Chrome.
71
76
class ClassMetaData {
72
77
static final _logger = Logger ('ClassMetadata' );
73
78
79
+ /// Class id.
80
+ ///
81
+ /// Takes the form of 'libraryId:name'.
82
+ final String id;
83
+
74
84
/// The name of the JS constructor for the object.
75
85
///
76
86
/// This may be a constructor for a Dart, but it's still a JS name. For
@@ -85,8 +95,8 @@ class ClassMetaData {
85
95
/// For example, 'int', 'List<String>', 'Null'
86
96
final String ? dartName;
87
97
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 ;
90
100
91
101
factory ClassMetaData ({
92
102
Object ? jsName,
@@ -97,10 +107,18 @@ class ClassMetaData {
97
107
bool isRecord = false ,
98
108
bool isNativeError = false ,
99
109
}) {
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
+
100
117
return ClassMetaData ._(
101
- jsName as String ? ,
102
- libraryId as String ? ?? _dartCoreLibrary,
103
- dartName as String ? ,
118
+ id,
119
+ classRef,
120
+ jName,
121
+ dName,
104
122
int .tryParse ('$length ' ),
105
123
isFunction,
106
124
isRecord,
@@ -109,20 +127,16 @@ class ClassMetaData {
109
127
}
110
128
111
129
ClassMetaData ._(
130
+ this .id,
131
+ this .classRef,
112
132
this .jsName,
113
- this .libraryId,
114
133
this .dartName,
115
134
this .length,
116
135
this .isFunction,
117
136
this .isRecord,
118
137
this .isNativeError,
119
138
);
120
139
121
- /// Returns the ID of the class.
122
- ///
123
- /// Takes the form of 'libraryId:name'.
124
- String get id => '$libraryId :$jsName ' ;
125
-
126
140
/// Returns the [ClassMetaData] for the Chrome [remoteObject] .
127
141
///
128
142
/// Returns null if the [remoteObject] is not a Dart class.
@@ -189,9 +203,6 @@ class ClassMetaData {
189
203
}
190
204
}
191
205
192
- /// Return a [ClassRef] appropriate to this metadata.
193
- ClassRef get classRef => classRefFor (libraryId, dartName);
194
-
195
206
/// True if this class refers to system maps, which are treated specially.
196
207
///
197
208
/// Classes that implement Map or inherit from MapBase are still treated as
0 commit comments