From 0c4d9e52255ddcf7d08138efab7ca3b89bc0e37d Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:35:23 -0800 Subject: [PATCH] Filter out internal type properties from the new DDC type system (#2348) --- dwds/CHANGELOG.md | 2 ++ dwds/lib/src/debugging/dart_scope.dart | 4 ++-- dwds/lib/src/debugging/debugger.dart | 2 +- dwds/lib/src/debugging/inspector.dart | 9 +++++++++ dwds/test/inspector_test.dart | 5 ----- dwds/test/variable_scope_test.dart | 13 ------------- fixtures/_test/example/scopes/main.dart | 1 + 7 files changed, 15 insertions(+), 21 deletions(-) diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 3fb766c54..568c44881 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,5 +1,7 @@ ## 23.3.0-wip +- Filter out internal type properties from the new DDC type system. - [#2348](https://github.com/dart-lang/webdev/pull/2348) + ## 23.2.0 - Send untruncated `dart:developer` logs to debugging clients. - [#2333](https://github.com/dart-lang/webdev/pull/2333) diff --git a/dwds/lib/src/debugging/dart_scope.dart b/dwds/lib/src/debugging/dart_scope.dart index 341af8904..2b64b0ac3 100644 --- a/dwds/lib/src/debugging/dart_scope.dart +++ b/dwds/lib/src/debugging/dart_scope.dart @@ -20,11 +20,11 @@ final ddcTemporaryTypeVariableRegExp = RegExp(r'^__t[\$\w*]+$'); final previousDdcTemporaryVariableRegExp = RegExp(r'^(t[0-9]+\$?[0-9]*|__t[\$\w*]+)$'); -/// Find the visible Dart properties from a JS Scope Chain, coming from the +/// Find the visible Dart variables from a JS Scope Chain, coming from the /// scopeChain attribute of a Chrome CallFrame corresponding to [frame]. /// /// See chromedevtools.github.io/devtools-protocol/tot/Debugger#type-CallFrame. -Future> visibleProperties({ +Future> visibleVariables({ required AppInspectorInterface inspector, required WipCallFrame frame, }) async { diff --git a/dwds/lib/src/debugging/debugger.dart b/dwds/lib/src/debugging/debugger.dart index cdb4a1456..b5af29092 100644 --- a/dwds/lib/src/debugging/debugger.dart +++ b/dwds/lib/src/debugging/debugger.dart @@ -405,7 +405,7 @@ class Debugger extends Domain { Future> variablesFor(WipCallFrame frame) async { // TODO(alanknight): Can these be moved to dart_scope.dart? final properties = - await visibleProperties(inspector: inspector, frame: frame); + await visibleVariables(inspector: inspector, frame: frame); final boundVariables = await Future.wait( properties.map(_boundVariable), ); diff --git a/dwds/lib/src/debugging/inspector.dart b/dwds/lib/src/debugging/inspector.dart index 660ee0dac..588051396 100644 --- a/dwds/lib/src/debugging/inspector.dart +++ b/dwds/lib/src/debugging/inspector.dart @@ -601,9 +601,18 @@ class AppInspector implements AppInspectorInterface { ); return jsProperties .map((each) => Property(each as Map)) + .where(_isVisibleProperty) .toList(); } + bool _isVisibleProperty(Property property) { + // Filter out any RTI objects from the new DDC type system. See: + // https://github.com/dart-lang/webdev/issues/2316 + final isRtiObject = + property.value?.className?.startsWith('dart_rti.Rti') ?? false; + return !isRtiObject; + } + /// Calculate the number of available elements in the range. static int _calculateRangeCount({ int? count, diff --git a/dwds/test/inspector_test.dart b/dwds/test/inspector_test.dart index b17fca8de..e84cd64ad 100644 --- a/dwds/test/inspector_test.dart +++ b/dwds/test/inspector_test.dart @@ -11,7 +11,6 @@ import 'package:dwds/src/debugging/inspector.dart'; import 'package:dwds/src/utilities/conversions.dart'; import 'package:test/test.dart'; import 'package:test_common/test_sdk_configuration.dart'; -import 'package:test_common/utilities.dart'; import 'package:vm_service/vm_service.dart'; import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; @@ -161,10 +160,6 @@ void main() { final names = properties.map((p) => p.name).where((x) => x != '__proto__').toList(); final expected = [ - if (dartSdkIsAtLeast( - newDdcTypeSystemVersion, - )) - '\$ti', '_privateField', 'abstractField', 'closure', diff --git a/dwds/test/variable_scope_test.dart b/dwds/test/variable_scope_test.dart index ac6ff9b1b..9036ec744 100644 --- a/dwds/test/variable_scope_test.dart +++ b/dwds/test/variable_scope_test.dart @@ -9,7 +9,6 @@ import 'package:dwds/src/services/chrome_proxy_service.dart'; import 'package:test/test.dart'; import 'package:test_common/logging.dart'; import 'package:test_common/test_sdk_configuration.dart'; -import 'package:test_common/utilities.dart'; import 'package:vm_service/vm_service.dart'; import 'fixtures/context.dart'; @@ -208,12 +207,6 @@ void main() { expect( variableNames, [ - // TODO(https://github.com/dart-lang/webdev/issues/2316): Make sure T - // doesn't show up here. - if (dartSdkIsAtLeast( - newDdcTypeSystemVersion, - )) - 'T', 'closureLocalInsideMethod', 'local', 'parameter', @@ -229,12 +222,6 @@ void main() { final variableNames = variables.keys.toList()..sort(); expect(variableNames, [ - // TODO(https://github.com/dart-lang/webdev/issues/2316): Make sure T - // doesn't show up here. - if (dartSdkIsAtLeast( - newDdcTypeSystemVersion, - )) - 'T', 'this', ]); }); diff --git a/fixtures/_test/example/scopes/main.dart b/fixtures/_test/example/scopes/main.dart index ea7338a16..6474febd0 100644 --- a/fixtures/_test/example/scopes/main.dart +++ b/fixtures/_test/example/scopes/main.dart @@ -93,6 +93,7 @@ class MyTestClass extends MyAbstractClass { String hello() => message; String Function(String) methodWithVariables() { + print('Test class is of type $T'); var local = '$message + something'; print(local); return (String parameter) {