Skip to content

Commit 9ceec72

Browse files
committed
Hide more temporary variables when debugging
Some variables created by DDC that are not present in the original source code were being shown by the debugger in the local scope. Update the regular expression used to detect temporary variable names. It has been simplified to: if the variable starts with 't$' or contains '$35' then it should be hidden. DDC names it's temporary variables to start with the characters `t$`. Hiding all of these does hide some valid variable names that could appear in the original source, but that is the status quo and not being changed here. In addition some names that are created by the CFE and added to the program contain an illegal character '#' which DDC replaces as '$35'. Variables with this sequence in the name can't appear in the original source so we hide them as well. This should hide variables synthetically added to support late local variables.
1 parent a97c2a1 commit 9ceec72

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

dwds/lib/src/debugging/dart_scope.dart

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
1212
/// TODO(annagrin) - use an alternative way to identify
1313
/// synthetic variables.
1414
/// Issue: https://github.com/dart-lang/sdk/issues/44262
15-
final ddcTemporaryVariableRegExp = RegExp(r'^t(\$[0-9]*)+\w*$');
15+
final ddcTemporaryVariableRegExp = RegExp(
16+
// Starts with t$
17+
r'^t\$'
18+
// followed by anything
19+
r'.*'
20+
// or,
21+
r'|'
22+
// anything that contains the sequence '$35'.
23+
r'.*\$35.*');
1624
final ddcTemporaryTypeVariableRegExp = RegExp(r'^__t[\$\w*]+$');
1725

1826
/// Temporary variable regex before SDK changes for patterns.

dwds/test/variable_scope_test.dart

+9
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ void main() {
7171
ddcTemporaryVariableRegExp.hasMatch(r't$36$350$354$35isSet'),
7272
isTrue,
7373
);
74+
expect(
75+
ddcTemporaryVariableRegExp.hasMatch(r't$36$35variable$35isSet'),
76+
isTrue,
77+
);
78+
expect(
79+
ddcTemporaryVariableRegExp.hasMatch(r'synthetic$35variable'),
80+
isTrue,
81+
);
7482
expect(ddcTemporaryTypeVariableRegExp.hasMatch(r'__t$TL'), isTrue);
7583
expect(ddcTemporaryTypeVariableRegExp.hasMatch(r'__t$StringN'), isTrue);
7684
expect(
@@ -84,6 +92,7 @@ void main() {
8492
expect(ddcTemporaryVariableRegExp.hasMatch(r't10'), isFalse);
8593
expect(ddcTemporaryVariableRegExp.hasMatch(r't10foo'), isFalse);
8694
expect(ddcTemporaryVariableRegExp.hasMatch(r'ten'), isFalse);
95+
expect(ddcTemporaryVariableRegExp.hasMatch(r'my$3635variable'), isFalse);
8796
});
8897
});
8998

0 commit comments

Comments
 (0)