Skip to content

Don't show non-instantiated variables #2061

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

Merged
merged 5 commits into from
Mar 31, 2023
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/lib/src/debugging/dart_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Future<List<Property>> visibleProperties({
if (value == null) return true;

final type = value.type;
if (type == 'undefined') return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think correct behavior according to the vm_service protocol is to have sentinel instead of an InstanceRef, but that would require more work and can be postponed to later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice! We can track in #2056


final description = value.description ?? '';
final name = property.name ?? '';

Expand Down
25 changes: 25 additions & 0 deletions dwds/test/instances/patterns_inspection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,31 @@ Future<void> _runTests({
}
});
});

test('before instantiation of pattern-matching variables', () async {
await onBreakPoint('testPattern2Case1', (event) async {
final frame = event.topFrame!;

expect(
await getFrameVariables(frame),
{'dog': matchPrimitiveInstance(kind: 'String', value: 'Prismo')},
);
});
});

test('after instantiation of pattern-matching variables', () async {
await onBreakPoint('testPattern2Case2', (event) async {
final frame = event.topFrame!;

expect(await getFrameVariables(frame), {
'dog': matchPrimitiveInstance(kind: 'String', value: 'Prismo'),
'cats': matchListInstance(type: 'List<String>'),
'firstCat':
matchPrimitiveInstance(kind: 'String', value: 'Garfield'),
'secondCat': matchPrimitiveInstance(kind: 'String', value: 'Tom'),
});
});
});
}, // TODO(annagrin): Remove when dart 3.0 is stable.
skip: semver.Version.parse(Platform.version.split(' ')[0]) <
semver.Version.parse('3.0.0-351.0.dev'),
Expand Down
9 changes: 9 additions & 0 deletions fixtures/_experimentSound/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void main() {
testPattern(['a', 1]);
testPattern([3.14, 'b']);
testPattern([0, 1]);
testPattern2();
});

document.body!.appendText('Program is running!');
Expand Down Expand Up @@ -64,3 +65,11 @@ String testPattern(Object obj) {
return 'default'; // Breakpoint: testPatternDefault
}
}

String testPattern2() {
final dog = 'Prismo';
final cats = ['Garfield', 'Tom']; // Breakpoint: testPattern2Case1
final [firstCat, secondCat] = cats;
print(firstCat); // Breakpoint: testPattern2Case2
return '$dog, $firstCat, $secondCat';
}