[Focus] Add run key command to dump the focus tree (#123473)
[Focus] Add run key command to dump the focus tree
This commit is contained in:
@@ -97,6 +97,12 @@ class CommandHelp {
|
||||
'Detach (terminate "flutter run" but leave application running).',
|
||||
);
|
||||
|
||||
late final CommandHelpOption f = _makeOption(
|
||||
'f',
|
||||
'Dump focus tree to the console.',
|
||||
'debugDumpFocusTree',
|
||||
);
|
||||
|
||||
late final CommandHelpOption g = _makeOption(
|
||||
'g',
|
||||
'Run source code generators.'
|
||||
|
||||
@@ -752,6 +752,22 @@ abstract class ResidentHandlers {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> debugDumpFocusTree() async {
|
||||
if (!supportsServiceProtocol || !isRunningDebug) {
|
||||
return false;
|
||||
}
|
||||
for (final FlutterDevice? device in flutterDevices) {
|
||||
final List<FlutterView> views = await device!.vmService!.getFlutterViews();
|
||||
for (final FlutterView view in views) {
|
||||
final String data = await device.vmService!.flutterDebugDumpFocusTree(
|
||||
isolateId: view.uiIsolate!.id!,
|
||||
);
|
||||
logger.printStatus(data);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Dump the application's current semantics tree to the terminal.
|
||||
///
|
||||
/// If semantics are not enabled, nothing is returned.
|
||||
@@ -1521,6 +1537,7 @@ abstract class ResidentRunner extends ResidentHandlers {
|
||||
commandHelp.t.print();
|
||||
if (isRunningDebug) {
|
||||
commandHelp.L.print();
|
||||
commandHelp.f.print();
|
||||
commandHelp.S.print();
|
||||
commandHelp.U.print();
|
||||
commandHelp.i.print();
|
||||
@@ -1706,6 +1723,8 @@ class TerminalHandler {
|
||||
case 'D':
|
||||
await residentRunner.detach();
|
||||
return true;
|
||||
case 'f':
|
||||
return residentRunner.debugDumpFocusTree();
|
||||
case 'g':
|
||||
await residentRunner.runSourceGenerators();
|
||||
return true;
|
||||
|
||||
@@ -643,6 +643,16 @@ class FlutterVmService {
|
||||
return response?['data']?.toString() ?? '';
|
||||
}
|
||||
|
||||
Future<String> flutterDebugDumpFocusTree({
|
||||
required String isolateId,
|
||||
}) async {
|
||||
final Map<String, Object?>? response = await invokeFlutterExtensionRpcRaw(
|
||||
'ext.flutter.debugDumpFocusTree',
|
||||
isolateId: isolateId,
|
||||
);
|
||||
return response?['data']?.toString() ?? '';
|
||||
}
|
||||
|
||||
Future<String> flutterDebugDumpSemanticsTreeInTraversalOrder({
|
||||
required String isolateId,
|
||||
}) async {
|
||||
|
||||
Reference in New Issue
Block a user