Skip to content

Commit 0c4d9e5

Browse files
authored
Filter out internal type properties from the new DDC type system (#2348)
1 parent f32fdc4 commit 0c4d9e5

File tree

7 files changed

+15
-21
lines changed

7 files changed

+15
-21
lines changed

dwds/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## 23.3.0-wip
22

3+
- Filter out internal type properties from the new DDC type system. - [#2348](https://github.com/dart-lang/webdev/pull/2348)
4+
35
## 23.2.0
46

57
- Send untruncated `dart:developer` logs to debugging clients. - [#2333](https://github.com/dart-lang/webdev/pull/2333)

dwds/lib/src/debugging/dart_scope.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ final ddcTemporaryTypeVariableRegExp = RegExp(r'^__t[\$\w*]+$');
2020
final previousDdcTemporaryVariableRegExp =
2121
RegExp(r'^(t[0-9]+\$?[0-9]*|__t[\$\w*]+)$');
2222

23-
/// Find the visible Dart properties from a JS Scope Chain, coming from the
23+
/// Find the visible Dart variables from a JS Scope Chain, coming from the
2424
/// scopeChain attribute of a Chrome CallFrame corresponding to [frame].
2525
///
2626
/// See chromedevtools.github.io/devtools-protocol/tot/Debugger#type-CallFrame.
27-
Future<List<Property>> visibleProperties({
27+
Future<List<Property>> visibleVariables({
2828
required AppInspectorInterface inspector,
2929
required WipCallFrame frame,
3030
}) async {

dwds/lib/src/debugging/debugger.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class Debugger extends Domain {
405405
Future<List<BoundVariable>> variablesFor(WipCallFrame frame) async {
406406
// TODO(alanknight): Can these be moved to dart_scope.dart?
407407
final properties =
408-
await visibleProperties(inspector: inspector, frame: frame);
408+
await visibleVariables(inspector: inspector, frame: frame);
409409
final boundVariables = await Future.wait(
410410
properties.map(_boundVariable),
411411
);

dwds/lib/src/debugging/inspector.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,18 @@ class AppInspector implements AppInspectorInterface {
601601
);
602602
return jsProperties
603603
.map<Property>((each) => Property(each as Map<String, dynamic>))
604+
.where(_isVisibleProperty)
604605
.toList();
605606
}
606607

608+
bool _isVisibleProperty(Property property) {
609+
// Filter out any RTI objects from the new DDC type system. See:
610+
// https://github.com/dart-lang/webdev/issues/2316
611+
final isRtiObject =
612+
property.value?.className?.startsWith('dart_rti.Rti') ?? false;
613+
return !isRtiObject;
614+
}
615+
607616
/// Calculate the number of available elements in the range.
608617
static int _calculateRangeCount({
609618
int? count,

dwds/test/inspector_test.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'package:dwds/src/debugging/inspector.dart';
1111
import 'package:dwds/src/utilities/conversions.dart';
1212
import 'package:test/test.dart';
1313
import 'package:test_common/test_sdk_configuration.dart';
14-
import 'package:test_common/utilities.dart';
1514
import 'package:vm_service/vm_service.dart';
1615
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
1716

@@ -161,10 +160,6 @@ void main() {
161160
final names =
162161
properties.map((p) => p.name).where((x) => x != '__proto__').toList();
163162
final expected = [
164-
if (dartSdkIsAtLeast(
165-
newDdcTypeSystemVersion,
166-
))
167-
'\$ti',
168163
'_privateField',
169164
'abstractField',
170165
'closure',

dwds/test/variable_scope_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:dwds/src/services/chrome_proxy_service.dart';
99
import 'package:test/test.dart';
1010
import 'package:test_common/logging.dart';
1111
import 'package:test_common/test_sdk_configuration.dart';
12-
import 'package:test_common/utilities.dart';
1312
import 'package:vm_service/vm_service.dart';
1413

1514
import 'fixtures/context.dart';
@@ -208,12 +207,6 @@ void main() {
208207
expect(
209208
variableNames,
210209
[
211-
// TODO(https://github.com/dart-lang/webdev/issues/2316): Make sure T
212-
// doesn't show up here.
213-
if (dartSdkIsAtLeast(
214-
newDdcTypeSystemVersion,
215-
))
216-
'T',
217210
'closureLocalInsideMethod',
218211
'local',
219212
'parameter',
@@ -229,12 +222,6 @@ void main() {
229222

230223
final variableNames = variables.keys.toList()..sort();
231224
expect(variableNames, [
232-
// TODO(https://github.com/dart-lang/webdev/issues/2316): Make sure T
233-
// doesn't show up here.
234-
if (dartSdkIsAtLeast(
235-
newDdcTypeSystemVersion,
236-
))
237-
'T',
238225
'this',
239226
]);
240227
});

fixtures/_test/example/scopes/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class MyTestClass<T> extends MyAbstractClass {
9393
String hello() => message;
9494

9595
String Function(String) methodWithVariables() {
96+
print('Test class is of type $T');
9697
var local = '$message + something';
9798
print(local);
9899
return (String parameter) {

0 commit comments

Comments
 (0)