@@ -77,88 +77,12 @@ class ClassHelper extends Domain {
77
77
78
78
if (libraryUri == null || classId == null || className == null ) return null ;
79
79
80
- final rawName = className.split ('<' ).first;
81
80
final expression = '''
82
- (function() {
83
- ${globalLoadStrategy .loadLibrarySnippet (libraryUri )}
84
- var result = {};
85
- var clazz = library["$rawName "];
86
- var descriptor = {
87
- 'name': clazz.name,
88
- 'dartName': sdkUtils.typeName(clazz)
89
- };
90
-
91
- // TODO(grouma) - we display all inherited methods since we don't provide
92
- // the superClass information. This is technically not correct.
93
- var proto = clazz.prototype;
94
- var methodNames = [];
95
- for (; proto != null; proto = Object.getPrototypeOf(proto)) {
96
- var methods = Object.getOwnPropertyNames(proto);
97
- for (var i = 0; i < methods.length; i++) {
98
- if (methodNames.indexOf(methods[i]) == -1
99
- && methods[i] != 'constructor') {
100
- methodNames.push(methods[i]);
101
- }
102
- }
103
- if (proto.constructor.name == 'Object') break;
104
- }
105
-
106
- descriptor['methods'] = {};
107
- for (var name of methodNames) {
108
- descriptor['methods'][name] = {
109
- // TODO(jakemac): how can we get actual const info?
110
- "isConst": false,
111
- "isStatic": false,
112
- }
113
- }
114
-
115
- var fields = sdkUtils.getFields(clazz);
116
- var fieldNames = fields ? Object.keys(fields) : [];
117
- descriptor['fields'] = {};
118
- for (var name of fieldNames) {
119
- var field = fields[name];
120
- var libraryUri = Object.getOwnPropertySymbols(fields[name]["type"])
121
- .find(x => x.description == "libraryUri");
122
- descriptor['fields'][name] = {
123
- // TODO(jakemac): how can we get actual const info?
124
- "isConst": false,
125
- "isFinal": field.isFinal,
126
- "isStatic": false,
127
- "classRefName": fields[name]["type"]["name"],
128
- "classRefDartName": sdkUtils.typeName(fields[name]["type"]),
129
- "classRefLibraryId" : field["type"][libraryUri],
130
- }
131
- }
132
-
133
- // TODO(elliette): The following static member information is minimal and
134
- // should be replaced once DDC provides full symbol information (see
135
- // https://github.com/dart-lang/sdk/issues/40273):
136
-
137
- descriptor['staticFields'] = {};
138
- var staticFieldNames = sdkUtils.getStaticFields(clazz) ?? [];
139
- for (const name of staticFieldNames) {
140
- descriptor['staticFields'][name] = {
141
- "isStatic": true,
142
- // DDC only provides names of static members, we set isConst/isFinal
143
- // to false even though they could be true.
144
- "isConst": false,
145
- "isFinal": false,
146
- }
147
- }
148
-
149
- descriptor['staticMethods'] = {};
150
- var staticMethodNames = sdkUtils.getStaticMethods(clazz) ?? [];
151
- for (var name of staticMethodNames) {
152
- descriptor['methods'][name] = {
153
- // DDC only provides names of static members, we set isConst
154
- // to false even though it could be true.
155
- "isConst": false,
156
- "isStatic": true,
157
- }
158
- }
159
-
160
- return descriptor;
161
- })()
81
+ (function() {
82
+ const sdk = ${globalLoadStrategy .loadModuleSnippet }('dart_sdk');
83
+ const dart = sdk.dart;
84
+ return dart.getClassMetadata('$libraryUri ', '$className ');
85
+ })()
162
86
''' ;
163
87
164
88
RemoteObject result;
@@ -176,35 +100,34 @@ class ClassHelper extends Domain {
176
100
final methodRefs = < FuncRef > [];
177
101
final methodDescriptors =
178
102
classDescriptor['methods' ] as Map <String , dynamic >;
179
- final staticMethodDescriptors =
180
- classDescriptor['staticMethods' ] as Map <String , dynamic >;
181
- methodDescriptors.addAll (staticMethodDescriptors);
182
103
methodDescriptors.forEach ((name, descriptor) {
183
104
final methodId = 'methods|$classId |$name ' ;
184
105
methodRefs.add (
185
106
FuncRef (
186
107
id: methodId,
187
108
name: name,
188
109
owner: classRef,
189
- isConst: descriptor['isConst' ] as bool ,
190
- isStatic: descriptor['isStatic' ] as bool ,
191
- // TODO(annagrin): get information about getters and setters from symbols.
192
- // https://github.com/dart-lang/sdk/issues/46723
193
- implicit: false ,
110
+ isConst: descriptor['isConst' ] as bool ? ?? false ,
111
+ isStatic: descriptor['isStatic' ] as bool ? ?? false ,
112
+ implicit: descriptor['isImplicit' ] as bool ? ?? false ,
113
+ isAbstract: descriptor['isAbstract' ] as bool ? ?? false ,
114
+ isGetter: descriptor['isGetter' ] as bool ? ?? false ,
115
+ isSetter: descriptor['isSetter' ] as bool ? ?? false ,
194
116
),
195
117
);
196
118
});
197
119
final fieldRefs = < FieldRef > [];
120
+
198
121
final fieldDescriptors = classDescriptor['fields' ] as Map <String , dynamic >;
199
122
fieldDescriptors.forEach ((name, descriptor) {
200
123
final classMetaData = ClassMetaData (
201
- jsName: descriptor['classRefName' ],
202
124
runtimeKind: RuntimeObjectKind .type,
203
125
classRef: classRefFor (
204
- descriptor['classRefLibraryId ' ],
205
- descriptor['classRefDartName ' ],
126
+ descriptor['classLibraryId ' ],
127
+ descriptor['className ' ],
206
128
),
207
129
);
130
+
208
131
fieldRefs.add (
209
132
FieldRef (
210
133
name: name,
@@ -215,34 +138,19 @@ class ClassHelper extends Domain {
215
138
kind: classMetaData.kind,
216
139
classRef: classMetaData.classRef,
217
140
),
218
- isConst: descriptor['isConst' ] as bool ,
219
- isFinal: descriptor['isFinal' ] as bool ,
220
- isStatic: descriptor['isStatic' ] as bool ,
141
+ isConst: descriptor['isConst' ] as bool ? ?? false ,
142
+ isFinal: descriptor['isFinal' ] as bool ? ?? false ,
143
+ isStatic: descriptor['isStatic' ] as bool ? ?? false ,
221
144
id: createId (),
222
145
),
223
146
);
224
147
});
225
148
226
- final staticFieldDescriptors =
227
- classDescriptor['staticFields' ] as Map <String , dynamic >;
228
- staticFieldDescriptors.forEach ((name, descriptor) {
229
- fieldRefs.add (
230
- FieldRef (
231
- name: name,
232
- owner: classRef,
233
- declaredType: InstanceRef (
234
- identityHashCode: createId ().hashCode,
235
- id: createId (),
236
- kind: InstanceKind .kType,
237
- classRef: classRef,
238
- ),
239
- isConst: descriptor['isConst' ] as bool ,
240
- isFinal: descriptor['isFinal' ] as bool ,
241
- isStatic: descriptor['isStatic' ] as bool ,
242
- id: createId (),
243
- ),
244
- );
245
- });
149
+ final superClassLibraryId = classDescriptor['superClassLibraryId' ];
150
+ final superClassName = classDescriptor['superClassName' ];
151
+ final superClassRef = superClassName == null
152
+ ? null
153
+ : classRefFor (superClassLibraryId, superClassName);
246
154
247
155
// TODO: Implement the rest of these
248
156
// https://github.com/dart-lang/webdev/issues/176.
@@ -257,6 +165,7 @@ class ClassHelper extends Domain {
257
165
subclasses: [],
258
166
id: classId,
259
167
traceAllocations: false ,
168
+ superClass: superClassRef,
260
169
);
261
170
}
262
171
}
0 commit comments