Skip to content

Commit 2684428

Browse files
author
Anna Gringauze
authored
Migrate some files from debugging directory to null safety (#1668)
* Migrate modules and locations to null safety * Remove circular dependencies * Remove circular dependencies and unused code * Simplified expression evaluation code * Cleanup * Fix failing tests * Move more helpers from Domain to ChromeProxyService * Build * Migrate some files in debugger directory to null safety * Minor fixes * Cleanup * Addressed CR comments * Addressed CR comments
1 parent 0fda9d3 commit 2684428

File tree

9 files changed

+251
-189
lines changed

9 files changed

+251
-189
lines changed

dwds/lib/src/debugging/dart_scope.dart

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
86

97
import '../utilities/objects.dart';
@@ -18,12 +16,12 @@ final ddcTemporaryVariableRegExp = RegExp(r'^(t[0-9]+\$?[0-9]*|__t[\$\w*]+)$');
1816
///
1917
/// See chromedevtools.github.io/devtools-protocol/tot/Debugger#type-CallFrame.
2018
Future<List<Property>> visibleProperties({
21-
Debugger debugger,
22-
WipCallFrame frame,
19+
required Debugger debugger,
20+
required WipCallFrame frame,
2321
}) async {
2422
final allProperties = <Property>[];
2523

26-
if (frame.thisObject != null && frame.thisObject.type != 'undefined') {
24+
if (frame.thisObject.type != 'undefined') {
2725
allProperties.add(
2826
Property({
2927
'name': 'this',
@@ -39,11 +37,14 @@ Future<List<Property>> visibleProperties({
3937
// Iterate to least specific scope last to help preserve order in the local
4038
// variables view when stepping.
4139
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+
}
4445
}
4546

46-
if (frame.returnValue != null && frame.returnValue.type != 'undefined') {
47+
if (frame.returnValue != null && frame.returnValue!.type != 'undefined') {
4748
allProperties.add(
4849
Property({
4950
'name': 'return',
@@ -54,15 +55,19 @@ Future<List<Property>> visibleProperties({
5455

5556
allProperties.removeWhere((property) {
5657
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 ?? '';
5763

5864
// TODO(#786) Handle these correctly rather than just suppressing them.
5965
// We should never see a raw JS class. The only case where this happens is a
6066
// Dart generic function, where the type arguments get passed in as
6167
// 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');
6671
});
6772

6873
return allProperties;

0 commit comments

Comments
 (0)