@@ -77,88 +77,12 @@ class ClassHelper extends Domain {
7777
7878 if (libraryUri == null || classId == null || className == null ) return null ;
7979
80- final rawName = className.split ('<' ).first;
8180 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+ })()
16286 ''' ;
16387
16488 RemoteObject result;
@@ -176,35 +100,34 @@ class ClassHelper extends Domain {
176100 final methodRefs = < FuncRef > [];
177101 final methodDescriptors =
178102 classDescriptor['methods' ] as Map <String , dynamic >;
179- final staticMethodDescriptors =
180- classDescriptor['staticMethods' ] as Map <String , dynamic >;
181- methodDescriptors.addAll (staticMethodDescriptors);
182103 methodDescriptors.forEach ((name, descriptor) {
183104 final methodId = 'methods|$classId |$name ' ;
184105 methodRefs.add (
185106 FuncRef (
186107 id: methodId,
187108 name: name,
188109 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 ,
194116 ),
195117 );
196118 });
197119 final fieldRefs = < FieldRef > [];
120+
198121 final fieldDescriptors = classDescriptor['fields' ] as Map <String , dynamic >;
199122 fieldDescriptors.forEach ((name, descriptor) {
200123 final classMetaData = ClassMetaData (
201- jsName: descriptor['classRefName' ],
202124 runtimeKind: RuntimeObjectKind .type,
203125 classRef: classRefFor (
204- descriptor['classRefLibraryId ' ],
205- descriptor['classRefDartName ' ],
126+ descriptor['classLibraryId ' ],
127+ descriptor['className ' ],
206128 ),
207129 );
130+
208131 fieldRefs.add (
209132 FieldRef (
210133 name: name,
@@ -215,34 +138,19 @@ class ClassHelper extends Domain {
215138 kind: classMetaData.kind,
216139 classRef: classMetaData.classRef,
217140 ),
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 ,
221144 id: createId (),
222145 ),
223146 );
224147 });
225148
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);
246154
247155 // TODO: Implement the rest of these
248156 // https://github.com/dart-lang/webdev/issues/176.
@@ -257,6 +165,7 @@ class ClassHelper extends Domain {
257165 subclasses: [],
258166 id: classId,
259167 traceAllocations: false ,
168+ superClass: superClassRef,
260169 );
261170 }
262171}
0 commit comments