Unverified Commit 13f18d5a authored by Kenzie Schmoll's avatar Kenzie Schmoll Committed by GitHub

Make inspector details subtree depth configurable. (#39085)

* Make inspector details subtree depth configurable.
parent 17ebdcf9
...@@ -1089,9 +1089,19 @@ mixin WidgetInspectorService { ...@@ -1089,9 +1089,19 @@ mixin WidgetInspectorService {
name: 'getRootWidgetSummaryTree', name: 'getRootWidgetSummaryTree',
callback: _getRootWidgetSummaryTree, callback: _getRootWidgetSummaryTree,
); );
_registerServiceExtensionWithArg( registerServiceExtension(
name: 'getDetailsSubtree', name: 'getDetailsSubtree',
callback: _getDetailsSubtree, callback: (Map<String, String> parameters) async {
assert(parameters.containsKey('objectGroup'));
final String subtreeDepth = parameters['subtreeDepth'];
return <String, Object>{
'result': _getDetailsSubtree(
parameters['arg'],
parameters['objectGroup'],
subtreeDepth != null ? int.parse(subtreeDepth) : 2,
),
};
},
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getSelectedRenderObject', name: 'getSelectedRenderObject',
...@@ -1603,15 +1613,27 @@ mixin WidgetInspectorService { ...@@ -1603,15 +1613,27 @@ mixin WidgetInspectorService {
/// [DiagnosticsNode] object that `diagnosticsNodeId` references providing /// [DiagnosticsNode] object that `diagnosticsNodeId` references providing
/// information needed for the details subtree view. /// information needed for the details subtree view.
/// ///
/// The number of levels of the subtree that should be returned is specified
/// by the [subtreeDepth] parameter. This value defaults to 2 for backwards
/// compatibility.
///
/// See also: /// See also:
/// ///
/// * [getChildrenDetailsSubtree], a method to get children of a node /// * [getChildrenDetailsSubtree], a method to get children of a node
/// in the details subtree. /// in the details subtree.
String getDetailsSubtree(String id, String groupName) { String getDetailsSubtree(
return _safeJsonEncode(_getDetailsSubtree( id, groupName)); String id,
String groupName, {
int subtreeDepth = 2,
}) {
return _safeJsonEncode(_getDetailsSubtree( id, groupName, subtreeDepth));
} }
Map<String, Object> _getDetailsSubtree(String id, String groupName) { Map<String, Object> _getDetailsSubtree(
String id,
String groupName,
int subtreeDepth,
) {
final DiagnosticsNode root = toObject(id); final DiagnosticsNode root = toObject(id);
if (root == null) { if (root == null) {
return null; return null;
...@@ -1621,7 +1643,7 @@ mixin WidgetInspectorService { ...@@ -1621,7 +1643,7 @@ mixin WidgetInspectorService {
_SerializationDelegate( _SerializationDelegate(
groupName: groupName, groupName: groupName,
summaryTree: false, summaryTree: false,
subtreeDepth: 2, // TODO(jacobr): make subtreeDepth configurable. subtreeDepth: subtreeDepth,
includeProperties: true, includeProperties: true,
service: this, service: this,
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment