Skip to content

Display inherited fields #1307

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
merged 2 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dwds/lib/src/debugging/instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ class InstanceHelper extends Domain {
//
// For maps and lists it's more complicated. Treat the actual SDK versions
// of these as special.
// TODO(alanknight): Handle superclass fields.
final fieldNameExpression = '''function() {
const sdk = ${globalLoadStrategy.loadModuleSnippet}("dart_sdk");
const sdk_utils = sdk.dart;
Expand All @@ -302,7 +301,9 @@ class InstanceHelper extends Domain {
const privateFields = sdk_utils.getOwnPropertySymbols(fields);
const nonSymbolNames = privateFields.map(sym => sym.description);
const publicFieldNames = sdk_utils.getOwnPropertyNames(fields);
return nonSymbolNames.concat(publicFieldNames).join(',');
const symbolNames = Object.getOwnPropertySymbols(this)
.map(sym => sym.description.split('.').slice(-1)[0]);
return nonSymbolNames.concat(publicFieldNames).concat(symbolNames).join(',');
}
''';
var allNames = (await inspector
Expand Down
1 change: 1 addition & 0 deletions dwds/test/inspector_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void main() {
properties.map((p) => p.name).where((x) => x != '__proto__').toList();
var expected = [
'_privateField',
'abstractField',
'closure',
'count',
'message',
Expand Down
1 change: 1 addition & 0 deletions dwds/test/instance_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void main() {
instance.fields.map((boundField) => boundField.decl.name).toList();
expect(fieldNames, [
'_privateField',
'abstractField',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the private inherited fields show as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. See:
image

'closure',
'count',
'message',
Expand Down
7 changes: 5 additions & 2 deletions example/web/scopes_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.

/// An example with more complicated scope

import 'dart:async';
import 'dart:collection';

Expand Down Expand Up @@ -75,7 +74,11 @@ String libraryFunction(String arg) {
return concat;
}

class MyTestClass<T> {
abstract class MyAbstractClass {
String abstractField = 'abstract-field-value';
}

class MyTestClass<T> extends MyAbstractClass {
final String message;

String notFinal;
Expand Down