2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- // @dart = 2.9
6
-
7
5
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' ;
8
6
9
7
import '../utilities/objects.dart' ;
@@ -18,12 +16,12 @@ final ddcTemporaryVariableRegExp = RegExp(r'^(t[0-9]+\$?[0-9]*|__t[\$\w*]+)$');
18
16
///
19
17
/// See chromedevtools.github.io/devtools-protocol/tot/Debugger#type-CallFrame.
20
18
Future <List <Property >> visibleProperties ({
21
- Debugger debugger,
22
- WipCallFrame frame,
19
+ required Debugger debugger,
20
+ required WipCallFrame frame,
23
21
}) async {
24
22
final allProperties = < Property > [];
25
23
26
- if (frame.thisObject != null && frame.thisObject .type != 'undefined' ) {
24
+ if (frame.thisObject.type != 'undefined' ) {
27
25
allProperties.add (
28
26
Property ({
29
27
'name' : 'this' ,
@@ -39,11 +37,14 @@ Future<List<Property>> visibleProperties({
39
37
// Iterate to least specific scope last to help preserve order in the local
40
38
// variables view when stepping.
41
39
for (var scope in filterScopes (frame).reversed) {
42
- final properties = await debugger.getProperties (scope.object.objectId);
43
- allProperties.addAll (properties);
40
+ final objectId = scope.object.objectId;
41
+ if (objectId != null ) {
42
+ final properties = await debugger.getProperties (objectId);
43
+ allProperties.addAll (properties);
44
+ }
44
45
}
45
46
46
- if (frame.returnValue != null && frame.returnValue.type != 'undefined' ) {
47
+ if (frame.returnValue != null && frame.returnValue! .type != 'undefined' ) {
47
48
allProperties.add (
48
49
Property ({
49
50
'name' : 'return' ,
@@ -54,15 +55,19 @@ Future<List<Property>> visibleProperties({
54
55
55
56
allProperties.removeWhere ((property) {
56
57
final value = property.value;
58
+ if (value == null ) return true ;
59
+
60
+ final type = value.type;
61
+ final description = value.description ?? '' ;
62
+ final name = property.name ?? '' ;
57
63
58
64
// TODO(#786) Handle these correctly rather than just suppressing them.
59
65
// We should never see a raw JS class. The only case where this happens is a
60
66
// Dart generic function, where the type arguments get passed in as
61
67
// parameters. Hide those.
62
- return (value.type == 'function' &&
63
- value.description.startsWith ('class ' )) ||
64
- (ddcTemporaryVariableRegExp.hasMatch (property.name)) ||
65
- (value.type == 'object' && value.description == 'dart.LegacyType.new' );
68
+ return (type == 'function' && description.startsWith ('class ' )) ||
69
+ (ddcTemporaryVariableRegExp.hasMatch (name)) ||
70
+ (type == 'object' && description == 'dart.LegacyType.new' );
66
71
});
67
72
68
73
return allProperties;
0 commit comments