Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide more temporary variables when debugging #2445

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- Respect the value of `pause_isolates_on_start` during page-refreshes. - [#2431](https://github.com/dart-lang/webdev/pull/2431)
- Fix issue where DAP clients wouldn't resume after a restart. - [#2441](https://github.com/dart-lang/webdev/pull/2441)
- Add implementation for the VM Service's `getFlagList` API. - [#2438](https://github.com/dart-lang/webdev/pull/2438)
- Hide more variables from the local scope when debugging. These variables were synthetically added by the compiler to
support late local variables and don't appear in the original source code. - [#2445](https://github.com/dart-lang/webdev/pull/2445)

## 24.0.0

Expand Down
10 changes: 9 additions & 1 deletion dwds/lib/src/debugging/dart_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
/// TODO(annagrin) - use an alternative way to identify
/// synthetic variables.
/// Issue: https://github.com/dart-lang/sdk/issues/44262
final ddcTemporaryVariableRegExp = RegExp(r'^t(\$[0-9]*)+\w*$');
final ddcTemporaryVariableRegExp = RegExp(
// Starts with t$
r'^t\$'
// followed by anything
r'.*'
// or,
r'|'
// anything that contains the sequence '$35'.
r'.*\$35.*');
final ddcTemporaryTypeVariableRegExp = RegExp(r'^__t[\$\w*]+$');

/// Temporary variable regex before SDK changes for patterns.
Expand Down
9 changes: 9 additions & 0 deletions dwds/test/variable_scope_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ void main() {
ddcTemporaryVariableRegExp.hasMatch(r't$36$350$354$35isSet'),
isTrue,
);
expect(
ddcTemporaryVariableRegExp.hasMatch(r't$36$35variable$35isSet'),
isTrue,
);
expect(
ddcTemporaryVariableRegExp.hasMatch(r'synthetic$35variable'),
isTrue,
);
expect(ddcTemporaryTypeVariableRegExp.hasMatch(r'__t$TL'), isTrue);
expect(ddcTemporaryTypeVariableRegExp.hasMatch(r'__t$StringN'), isTrue);
expect(
Expand All @@ -84,6 +92,7 @@ void main() {
expect(ddcTemporaryVariableRegExp.hasMatch(r't10'), isFalse);
expect(ddcTemporaryVariableRegExp.hasMatch(r't10foo'), isFalse);
expect(ddcTemporaryVariableRegExp.hasMatch(r'ten'), isFalse);
expect(ddcTemporaryVariableRegExp.hasMatch(r'my$3635variable'), isFalse);
});
});

Expand Down
Loading