Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 46e48ba

Browse files
authored
Use program during attach if provided (#118130)
1 parent 5bf6357 commit 46e48ba

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

packages/flutter_tools/lib/src/debug_adapters/flutter_adapter.dart

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
148148
customTool: args.customTool,
149149
customToolReplacesArgs: args.customToolReplacesArgs,
150150
userToolArgs: args.toolArgs,
151+
targetProgram: args.program,
151152
);
152153
}
153154

packages/flutter_tools/lib/src/debug_adapters/flutter_adapter_args.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class FlutterAttachRequestArguments
1717
this.customTool,
1818
this.customToolReplacesArgs,
1919
this.vmServiceUri,
20+
this.program,
2021
super.restart,
2122
super.name,
2223
super.cwd,
@@ -35,6 +36,7 @@ class FlutterAttachRequestArguments
3536
customTool = obj['customTool'] as String?,
3637
customToolReplacesArgs = obj['customToolReplacesArgs'] as int?,
3738
vmServiceUri = obj['vmServiceUri'] as String?,
39+
program = obj['program'] as String?,
3840
super.fromMap();
3941

4042
static FlutterAttachRequestArguments fromJson(Map<String, Object?> obj) =>
@@ -64,6 +66,9 @@ class FlutterAttachRequestArguments
6466
/// The VM Service URI of the running Flutter app to connect to.
6567
final String? vmServiceUri;
6668

69+
/// The program/Flutter app to be run.
70+
final String? program;
71+
6772
@override
6873
Map<String, Object?> toJson() => <String, Object?>{
6974
...super.toJson(),
@@ -151,7 +156,8 @@ class FlutterLaunchRequestArguments
151156
if (args != null) 'args': args,
152157
if (toolArgs != null) 'toolArgs': toolArgs,
153158
if (customTool != null) 'customTool': customTool,
154-
if (customToolReplacesArgs != null) 'customToolReplacesArgs': customToolReplacesArgs,
159+
if (customToolReplacesArgs != null)
160+
'customToolReplacesArgs': customToolReplacesArgs,
155161
};
156162

157163
static FlutterLaunchRequestArguments fromJson(Map<String, Object?> obj) =>

packages/flutter_tools/test/general.shard/dap/flutter_adapter_test.dart

+28
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,34 @@ void main() {
209209
expect(adapter.processArgs, containsAllInOrder(<String>['attach', '--machine']));
210210
});
211211

212+
test('runs "flutter attach" with program if passed in', () async {
213+
final MockFlutterDebugAdapter adapter = MockFlutterDebugAdapter(
214+
fileSystem: MemoryFileSystem.test(style: fsStyle),
215+
platform: platform,
216+
);
217+
final Completer<void> responseCompleter = Completer<void>();
218+
219+
final FlutterAttachRequestArguments args =
220+
FlutterAttachRequestArguments(
221+
cwd: '/project',
222+
program: 'program/main.dart',
223+
);
224+
225+
await adapter.configurationDoneRequest(MockRequest(), null, () {});
226+
await adapter.attachRequest(
227+
MockRequest(), args, responseCompleter.complete);
228+
await responseCompleter.future;
229+
230+
expect(
231+
adapter.processArgs,
232+
containsAllInOrder(<String>[
233+
'attach',
234+
'--machine',
235+
'--target',
236+
'program/main.dart'
237+
]));
238+
});
239+
212240
test('does not record the VMs PID for terminating', () async {
213241
final MockFlutterDebugAdapter adapter = MockFlutterDebugAdapter(
214242
fileSystem: MemoryFileSystem.test(style: fsStyle),

0 commit comments

Comments
 (0)