Skip to content

Migrate some files from debugging directory to null safety #1668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
29 changes: 17 additions & 12 deletions dwds/lib/src/debugging/dart_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

import '../utilities/objects.dart';
Expand All @@ -18,12 +16,12 @@ final ddcTemporaryVariableRegExp = RegExp(r'^(t[0-9]+\$?[0-9]*|__t[\$\w*]+)$');
///
/// See chromedevtools.github.io/devtools-protocol/tot/Debugger#type-CallFrame.
Future<List<Property>> visibleProperties({
Debugger debugger,
WipCallFrame frame,
required Debugger debugger,
required WipCallFrame frame,
}) async {
final allProperties = <Property>[];

if (frame.thisObject != null && frame.thisObject.type != 'undefined') {
if (frame.thisObject.type != 'undefined') {
allProperties.add(
Property({
'name': 'this',
Expand All @@ -39,11 +37,14 @@ Future<List<Property>> visibleProperties({
// Iterate to least specific scope last to help preserve order in the local
// variables view when stepping.
for (var scope in filterScopes(frame).reversed) {
final properties = await debugger.getProperties(scope.object.objectId);
allProperties.addAll(properties);
final objectId = scope.object.objectId;
if (objectId != null) {
final properties = await debugger.getProperties(objectId);
allProperties.addAll(properties);
}
}

if (frame.returnValue != null && frame.returnValue.type != 'undefined') {
if (frame.returnValue != null && frame.returnValue!.type != 'undefined') {
allProperties.add(
Property({
'name': 'return',
Expand All @@ -54,15 +55,19 @@ Future<List<Property>> visibleProperties({

allProperties.removeWhere((property) {
final value = property.value;
if (value == null) return true;

final type = value.type;
final description = value.description ?? '';
final name = property.name ?? '';

// TODO(#786) Handle these correctly rather than just suppressing them.
// We should never see a raw JS class. The only case where this happens is a
// Dart generic function, where the type arguments get passed in as
// parameters. Hide those.
return (value.type == 'function' &&
value.description.startsWith('class ')) ||
(ddcTemporaryVariableRegExp.hasMatch(property.name)) ||
(value.type == 'object' && value.description == 'dart.LegacyType.new');
return (type == 'function' && description.startsWith('class ')) ||
(ddcTemporaryVariableRegExp.hasMatch(name)) ||
(type == 'object' && description == 'dart.LegacyType.new');
});

return allProperties;
Expand Down
Loading