Skip to content

Commit

Permalink
Filter out internal type properties from the new DDC type system (#2348)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Jan 19, 2024
1 parent f32fdc4 commit 0c4d9e5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 21 deletions.
2 changes: 2 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions dwds/lib/src/debugging/dart_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<Property>> visibleProperties({
Future<List<Property>> visibleVariables({
required AppInspectorInterface inspector,
required WipCallFrame frame,
}) async {
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class Debugger extends Domain {
Future<List<BoundVariable>> 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),
);
Expand Down
9 changes: 9 additions & 0 deletions dwds/lib/src/debugging/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,18 @@ class AppInspector implements AppInspectorInterface {
);
return jsProperties
.map<Property>((each) => Property(each as Map<String, dynamic>))
.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,
Expand Down
5 changes: 0 additions & 5 deletions dwds/test/inspector_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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',
Expand Down
13 changes: 0 additions & 13 deletions dwds/test/variable_scope_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
Expand All @@ -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',
]);
});
Expand Down
1 change: 1 addition & 0 deletions fixtures/_test/example/scopes/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class MyTestClass<T> 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) {
Expand Down

0 comments on commit 0c4d9e5

Please sign in to comment.