[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>
diff --git a/pkg/dds/lib/src/dap/protocol_converter.dart b/pkg/dds/lib/src/dap/protocol_converter.dart
index ab7574b..b34eb01 100644
--- a/pkg/dds/lib/src/dap/protocol_converter.dart
+++ b/pkg/dds/lib/src/dap/protocol_converter.dart
@@ -592,7 +592,9 @@
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;
diff --git a/pkg/dds/test/dap/integration/debug_variables_test.dart b/pkg/dds/test/dap/integration/debug_variables_test.dart
index 25894eb..939b46c 100644
--- a/pkg/dds/test/dap/integration/debug_variables_test.dart
+++ b/pkg/dds/test/dap/integration/debug_variables_test.dart
@@ -123,14 +123,18 @@
);
});
- 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 @@
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,
);
});