Skip to content

Add a way to fetch values for getters for an object through the VM Service(/DDS?) #46723

Open
@DanTup

Description

@DanTup

In VS Code's debug adapter and the new SDK DAP implementation, there is a setting that allows showing values of getters in debug tooltips/watch window/etc.. This works by walking up the class hierarchy getting all of the names of any getters at each level and then sending evaluate requests for each.

This code seems fragile and involves looking at an internal field to identify the getters (f.json?['_kind'] == 'GetterFunction'). It would be better to have a more official way to do this (and perhaps in a single request).

/// Collect a list of all getter names for [classRef] and its super classes.
///
/// This is used to show/evaluate getters in debug views like hovers and
/// variables/watch panes.
Future<Set<String>> _getterNamesForClassHierarchy(
ThreadInfo thread,
vm.ClassRef? classRef,
) async {
final getterNames = <String>{};
final service = _adapter.vmService;
while (service != null && classRef != null) {
final classResponse =
await service.getObject(thread.isolate.id!, classRef.id!);
if (classResponse is! vm.Class) {
break;
}
final functions = classResponse.functions;
if (functions != null) {
final instanceFields = functions.where((f) =>
// TODO(dantup): Update this to use something better that bkonyi is
// adding to the protocol.
f.json?['_kind'] == 'GetterFunction' &&
!(f.isStatic ?? false) &&
!(f.isConst ?? false));
getterNames.addAll(instanceFields.map((f) => f.name!));
}
classRef = classResponse.superClass;
}
return getterNames;
}

@bkonyi (I think @jacob314 may also have been interested in this?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triagedIssue has been triaged by sub teamvm-serviceThe VM Service Protocol, both the specification and its implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions