Unverified Commit 4356d3b6 authored by Kenzie Davisson's avatar Kenzie Davisson Committed by GitHub

Create an enum for widget inspector service extensions for use by tools (#111405)

parent 2d5e181b
...@@ -29,6 +29,7 @@ import 'binding.dart'; ...@@ -29,6 +29,7 @@ import 'binding.dart';
import 'debug.dart'; import 'debug.dart';
import 'framework.dart'; import 'framework.dart';
import 'gesture_detector.dart'; import 'gesture_detector.dart';
import 'service_extensions.dart';
/// Signature for the builder callback used by /// Signature for the builder callback used by
/// [WidgetInspector.selectButtonBuilder]. /// [WidgetInspector.selectButtonBuilder].
...@@ -1007,7 +1008,7 @@ mixin WidgetInspectorService { ...@@ -1007,7 +1008,7 @@ mixin WidgetInspectorService {
SchedulerBinding.instance.addPersistentFrameCallback(_onFrameStart); SchedulerBinding.instance.addPersistentFrameCallback(_onFrameStart);
_registerBoolServiceExtension( _registerBoolServiceExtension(
name: 'structuredErrors', name: WidgetInspectorServiceExtensions.structuredErrors.name,
getter: () async => FlutterError.presentError == _reportStructuredError, getter: () async => FlutterError.presentError == _reportStructuredError,
setter: (bool value) { setter: (bool value) {
FlutterError.presentError = value ? _reportStructuredError : defaultExceptionHandler; FlutterError.presentError = value ? _reportStructuredError : defaultExceptionHandler;
...@@ -1016,7 +1017,7 @@ mixin WidgetInspectorService { ...@@ -1016,7 +1017,7 @@ mixin WidgetInspectorService {
); );
_registerBoolServiceExtension( _registerBoolServiceExtension(
name: 'show', name: WidgetInspectorServiceExtensions.show.name,
getter: () async => WidgetsApp.debugShowWidgetInspectorOverride, getter: () async => WidgetsApp.debugShowWidgetInspectorOverride,
setter: (bool value) { setter: (bool value) {
if (WidgetsApp.debugShowWidgetInspectorOverride == value) { if (WidgetsApp.debugShowWidgetInspectorOverride == value) {
...@@ -1031,7 +1032,7 @@ mixin WidgetInspectorService { ...@@ -1031,7 +1032,7 @@ mixin WidgetInspectorService {
// Service extensions that are only supported if widget creation locations // Service extensions that are only supported if widget creation locations
// are tracked. // are tracked.
_registerBoolServiceExtension( _registerBoolServiceExtension(
name: 'trackRebuildDirtyWidgets', name: WidgetInspectorServiceExtensions.trackRebuildDirtyWidgets.name,
getter: () async => _trackRebuildDirtyWidgets, getter: () async => _trackRebuildDirtyWidgets,
setter: (bool value) async { setter: (bool value) async {
if (value == _trackRebuildDirtyWidgets) { if (value == _trackRebuildDirtyWidgets) {
...@@ -1054,7 +1055,7 @@ mixin WidgetInspectorService { ...@@ -1054,7 +1055,7 @@ mixin WidgetInspectorService {
); );
_registerBoolServiceExtension( _registerBoolServiceExtension(
name: 'trackRepaintWidgets', name: WidgetInspectorServiceExtensions.trackRepaintWidgets.name,
getter: () async => _trackRepaintWidgets, getter: () async => _trackRepaintWidgets,
setter: (bool value) async { setter: (bool value) async {
if (value == _trackRepaintWidgets) { if (value == _trackRepaintWidgets) {
...@@ -1081,92 +1082,92 @@ mixin WidgetInspectorService { ...@@ -1081,92 +1082,92 @@ mixin WidgetInspectorService {
} }
_registerSignalServiceExtension( _registerSignalServiceExtension(
name: 'disposeAllGroups', name: WidgetInspectorServiceExtensions.disposeAllGroups.name,
callback: () async { callback: () async {
disposeAllGroups(); disposeAllGroups();
return null; return null;
}, },
); );
_registerObjectGroupServiceExtension( _registerObjectGroupServiceExtension(
name: 'disposeGroup', name: WidgetInspectorServiceExtensions.disposeGroup.name,
callback: (String name) async { callback: (String name) async {
disposeGroup(name); disposeGroup(name);
return null; return null;
}, },
); );
_registerSignalServiceExtension( _registerSignalServiceExtension(
name: 'isWidgetTreeReady', name: WidgetInspectorServiceExtensions.isWidgetTreeReady.name,
callback: isWidgetTreeReady, callback: isWidgetTreeReady,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'disposeId', name: WidgetInspectorServiceExtensions.disposeId.name,
callback: (String? objectId, String objectGroup) async { callback: (String? objectId, String objectGroup) async {
disposeId(objectId, objectGroup); disposeId(objectId, objectGroup);
return null; return null;
}, },
); );
_registerServiceExtensionVarArgs( _registerServiceExtensionVarArgs(
name: 'setPubRootDirectories', name: WidgetInspectorServiceExtensions.setPubRootDirectories.name,
callback: (List<String> args) async { callback: (List<String> args) async {
setPubRootDirectories(args); setPubRootDirectories(args);
return null; return null;
}, },
); );
_registerServiceExtensionVarArgs( _registerServiceExtensionVarArgs(
name: 'addPubRootDirectories', name: WidgetInspectorServiceExtensions.addPubRootDirectories.name,
callback: (List<String> args) async { callback: (List<String> args) async {
addPubRootDirectories(args); addPubRootDirectories(args);
return null; return null;
}, },
); );
_registerServiceExtensionVarArgs( _registerServiceExtensionVarArgs(
name: 'removePubRootDirectories', name: WidgetInspectorServiceExtensions.removePubRootDirectories.name,
callback: (List<String> args) async { callback: (List<String> args) async {
removePubRootDirectories(args); removePubRootDirectories(args);
return null; return null;
}, },
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'setSelectionById', name: WidgetInspectorServiceExtensions.setSelectionById.name,
callback: setSelectionById, callback: setSelectionById,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getParentChain', name: WidgetInspectorServiceExtensions.getParentChain.name,
callback: _getParentChain, callback: _getParentChain,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getProperties', name: WidgetInspectorServiceExtensions.getProperties.name,
callback: _getProperties, callback: _getProperties,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getChildren', name: WidgetInspectorServiceExtensions.getChildren.name,
callback: _getChildren, callback: _getChildren,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getChildrenSummaryTree', name: WidgetInspectorServiceExtensions.getChildrenSummaryTree.name,
callback: _getChildrenSummaryTree, callback: _getChildrenSummaryTree,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getChildrenDetailsSubtree', name: WidgetInspectorServiceExtensions.getChildrenDetailsSubtree.name,
callback: _getChildrenDetailsSubtree, callback: _getChildrenDetailsSubtree,
); );
_registerObjectGroupServiceExtension( _registerObjectGroupServiceExtension(
name: 'getRootWidget', name: WidgetInspectorServiceExtensions.getRootWidget.name,
callback: _getRootWidget, callback: _getRootWidget,
); );
_registerObjectGroupServiceExtension( _registerObjectGroupServiceExtension(
name: 'getRootRenderObject', name: WidgetInspectorServiceExtensions.getRootRenderObject.name,
callback: _getRootRenderObject, callback: _getRootRenderObject,
); );
_registerObjectGroupServiceExtension( _registerObjectGroupServiceExtension(
name: 'getRootWidgetSummaryTree', name: WidgetInspectorServiceExtensions.getRootWidgetSummaryTree.name,
callback: _getRootWidgetSummaryTree, callback: _getRootWidgetSummaryTree,
); );
registerServiceExtension( registerServiceExtension(
name: 'getDetailsSubtree', name: WidgetInspectorServiceExtensions.getDetailsSubtree.name,
callback: (Map<String, String> parameters) async { callback: (Map<String, String> parameters) async {
assert(parameters.containsKey('objectGroup')); assert(parameters.containsKey('objectGroup'));
final String? subtreeDepth = parameters['subtreeDepth']; final String? subtreeDepth = parameters['subtreeDepth'];
...@@ -1180,24 +1181,24 @@ mixin WidgetInspectorService { ...@@ -1180,24 +1181,24 @@ mixin WidgetInspectorService {
}, },
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getSelectedRenderObject', name: WidgetInspectorServiceExtensions.getSelectedRenderObject.name,
callback: _getSelectedRenderObject, callback: _getSelectedRenderObject,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getSelectedWidget', name: WidgetInspectorServiceExtensions.getSelectedWidget.name,
callback: _getSelectedWidget, callback: _getSelectedWidget,
); );
_registerServiceExtensionWithArg( _registerServiceExtensionWithArg(
name: 'getSelectedSummaryWidget', name: WidgetInspectorServiceExtensions.getSelectedSummaryWidget.name,
callback: _getSelectedSummaryWidget, callback: _getSelectedSummaryWidget,
); );
_registerSignalServiceExtension( _registerSignalServiceExtension(
name: 'isWidgetCreationTracked', name: WidgetInspectorServiceExtensions.isWidgetCreationTracked.name,
callback: isWidgetCreationTracked, callback: isWidgetCreationTracked,
); );
registerServiceExtension( registerServiceExtension(
name: 'screenshot', name: WidgetInspectorServiceExtensions.screenshot.name,
callback: (Map<String, String> parameters) async { callback: (Map<String, String> parameters) async {
assert(parameters.containsKey('id')); assert(parameters.containsKey('id'));
assert(parameters.containsKey('width')); assert(parameters.containsKey('width'));
......
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