[dds/dap] Filter private getters from debug views

These will fail unless the current stack frame happens to be in the library that declares them, which results in a lot of exceptions being shown in variable views.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4296.

Change-Id: I5919e391f25a08920dcdf1bf648526d175af00f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274040
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Danny Tuppeny 2022-12-08 15:02:04 +00:00 committed by Commit Queue
parent cdd0694a92
commit c53f70509c
2 changed files with 13 additions and 23 deletions

View file

@ -592,7 +592,9 @@ class ProtocolConverter {
f.json?['_kind'] == 'GetterFunction' &&
!(f.isStatic ?? false) &&
!(f.isConst ?? false));
getterNames.addAll(instanceFields.map((f) => f.name!));
getterNames.addAll(instanceFields
.map((f) => f.name!)
.where((name) => !name.startsWith('_')));
}
classRef = classResponse.superClass;

View file

@ -123,13 +123,17 @@ void main(List<String> args) {
);
});
test('includes variable getters when evaluateGettersInDebugViews=true',
test('includes public getters when evaluateGettersInDebugViews=true',
() async {
final client = dap.client;
final testFile = dap.createTestFile('''
void main(List<String> args) {
final myVariable = DateTime(2000, 1, 1);
final myVariable = A();
print('Hello!'); $breakpointMarker
}
class A {
String get publicString => '';
String get _privateString => '';
}
''');
final breakpointLine = lineWith(testFile, breakpointMarker);
@ -145,28 +149,12 @@ void main(List<String> args) {
await client.expectLocalVariable(
stop.threadId!,
expectedName: 'myVariable',
expectedDisplayString: 'DateTime',
expectedDisplayString: 'A',
expectedVariables: '''
day: 1, eval: myVariable.day
hour: 0, eval: myVariable.hour
isUtc: false, eval: myVariable.isUtc
microsecond: 0, eval: myVariable.microsecond
millisecond: 0, eval: myVariable.millisecond
minute: 0, eval: myVariable.minute
month: 1, eval: myVariable.month
runtimeType: Type (DateTime), eval: myVariable.runtimeType
second: 0, eval: myVariable.second
timeZoneOffset: Duration, eval: myVariable.timeZoneOffset
weekday: 6, eval: myVariable.weekday
year: 2000, eval: myVariable.year
publicString: "", eval: myVariable.publicString
runtimeType: Type (A), eval: myVariable.runtimeType
''',
ignore: {
// Don't check fields that may very based on timezone as it'll make
// these tests fragile, and this isn't really what's being tested.
'timeZoneName',
'microsecondsSinceEpoch',
'millisecondsSinceEpoch',
},
ignorePrivate: false,
);
});