Skip to content

Commit

Permalink
Addressed CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Gringauze committed Jan 24, 2024
2 parents 82bb2a8 + e382db3 commit f739fb5
Show file tree
Hide file tree
Showing 25 changed files with 712 additions and 285 deletions.
9 changes: 7 additions & 2 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
## 23.2.0-wip
## 23.3.0-wip

- Filter out internal type properties from the new DDC type system. - [#2348](https://github.com/dart-lang/webdev/pull/2348)
- Migrate injected client code to `package:web`. - [#2306](https://github.com/dart-lang/webdev/pull/2306)

## 23.2.0

- Send untruncated `dart:developer` logs to debugging clients. - [#2333](https://github.com/dart-lang/webdev/pull/2333)
- Enabling tests that run with the DDC module system and exposing `utilities/ddc_names.dart` - [#2295](https://github.com/dart-lang/webdev/pull/2295)
- Migrate injected client code to `package:web`. - [#2306](https://github.com/dart-lang/webdev/pull/2306)
- Fix errors on displaying getters. - [#2343](https://github.com/dart-lang/webdev/pull/2343)

## 23.1.1

Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension_mv3/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mv3_extension
publish_to: none
version: 2.1.1
version: 2.1.2
homepage: https://github.com/dart-lang/webdev
description: >-
A Chrome extension for Dart debugging.
Expand Down
4 changes: 4 additions & 0 deletions dwds/debug_extension_mv3/web/cider_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ enum CiderMessageType {
error,
inspectorUrlResponse,
inspectorUrlRequest,
ping,
pong,
startDebugResponse,
startDebugRequest,
stopDebugResponse,
Expand Down Expand Up @@ -123,6 +125,8 @@ Future<void> _handleMessageFromCider(dynamic message, Port _) async {
await _stopDebugging(appId: messageBody);
} else if (messageType == CiderMessageType.inspectorUrlRequest.name) {
await _sendInspectorUrl(appId: messageBody);
} else if (messageType == CiderMessageType.ping.name) {
sendMessageToCider(messageType: CiderMessageType.pong);
}
}

Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension_mv3/web/manifest_mv3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Dart Debug Extension",
"version": "2.1.1",
"version": "2.1.2",
"manifest_version": 3,
"devtools_page": "static_assets/devtools.html",
"action": {
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
78 changes: 37 additions & 41 deletions dwds/lib/src/debugging/instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,29 +238,49 @@ class InstanceHelper extends Domain {
final objectId = remoteObject.objectId;
if (objectId == null) return null;

final fields = await _getInstanceFields(
metaData,
remoteObject,
offset: offset,
count: count,
);

final result = Instance(
kind: InstanceKind.kPlainInstance,
id: objectId,
identityHashCode: remoteObject.objectId.hashCode,
classRef: metaData.classRef,
fields: fields,
);
return result;
}

Future<List<BoundField>> _getInstanceFields(
ClassMetaData metaData,
RemoteObject remoteObject, {
int? offset,
int? count,
}) async {
final objectId = remoteObject.objectId;
if (objectId == null) throw StateError('Object id is null for instance');

final properties = await inspector.getProperties(
objectId,
offset: offset,
count: count,
length: metaData.length,
);

final dartProperties = await _dartFieldsFor(properties, remoteObject);
var boundFields = await Future.wait(
final boundFields = await Future.wait(
dartProperties
.map<Future<BoundField>>((p) => _fieldFor(p, metaData.classRef)),
);
boundFields = boundFields

return boundFields
.where((bv) => inspector.isDisplayableObject(bv.value))
.toList()
..sort(_compareBoundFields);
final result = Instance(
kind: InstanceKind.kPlainInstance,
id: objectId,
identityHashCode: remoteObject.objectId.hashCode,
classRef: metaData.classRef,
fields: boundFields,
);
return result;
}

int _compareBoundFields(BoundField a, BoundField b) {
Expand Down Expand Up @@ -700,7 +720,13 @@ class InstanceHelper extends Domain {
final objectId = remoteObject.objectId;
if (objectId == null) return null;

final fields = await _typeFields(metaData.classRef, remoteObject);
final fields = await _getInstanceFields(
metaData,
remoteObject,
offset: offset,
count: count,
);

return Instance(
identityHashCode: objectId.hashCode,
kind: InstanceKind.kType,
Expand All @@ -714,36 +740,6 @@ class InstanceHelper extends Domain {
);
}

/// The field types for a Dart RecordType.
///
/// Returns a range of [count] field types, if available, starting from
/// the [offset].
///
/// If [offset] is `null`, assumes 0 offset.
/// If [count] is `null`, return all field types starting from the offset.
Future<List<BoundField>> _typeFields(
ClassRef classRef,
RemoteObject type,
) async {
// Present the type as an instance of `core.Type` class and
// hide the internal implementation.
final expression = _jsRuntimeFunctionCall('getTypeFields(this)');

final result = await inspector.jsCallFunctionOn(type, expression, []);
final hashCodeObject = await inspector.loadField(result, 'hashCode');
final runtimeTypeObject = await inspector.loadField(result, 'runtimeType');

final properties = [
Property({'name': 'hashCode', 'value': hashCodeObject}),
Property({'name': 'runtimeType', 'value': runtimeTypeObject}),
];

final boundFields = await Future.wait(
properties.map<Future<BoundField>>((p) => _fieldFor(p, classRef)),
);
return boundFields;
}

/// Return the available count of elements in the requested range.
/// Return `null` if the range includes the whole object.
/// [count] is the range length requested by the `getObject` call.
Expand Down
1 change: 1 addition & 0 deletions dwds/lib/src/debugging/metadata/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class MetadataProvider {
'dart:_js_primitives',
'dart:_metadata',
'dart:_native_typed_data',
'dart:_rti',
'dart:async',
'dart:collection',
'dart:convert',
Expand Down
Loading

0 comments on commit f739fb5

Please sign in to comment.