diff --git a/packages/devtools_app/lib/src/standalone_ui/api/impl/vs_code_api.dart b/packages/devtools_app/lib/src/standalone_ui/api/impl/vs_code_api.dart index a00cbbb4ef9..4876ecdcaf6 100644 --- a/packages/devtools_app/lib/src/standalone_ui/api/impl/vs_code_api.dart +++ b/packages/devtools_app/lib/src/standalone_ui/api/impl/vs_code_api.dart @@ -167,6 +167,7 @@ class VsCodeDebugSessionImpl implements VsCodeDebugSession { required this.flutterMode, required this.flutterDeviceId, required this.debuggerType, + required this.projectRootPath, }); VsCodeDebugSessionImpl.fromJson(Map json) @@ -180,6 +181,8 @@ class VsCodeDebugSessionImpl implements VsCodeDebugSession { json[VsCodeDebugSession.jsonFlutterDeviceIdField] as String?, debuggerType: json[VsCodeDebugSession.jsonDebuggerTypeField] as String?, + projectRootPath: + json[VsCodeDebugSession.jsonProjectRootPathField] as String?, ); @override @@ -200,6 +203,9 @@ class VsCodeDebugSessionImpl implements VsCodeDebugSession { @override final String? debuggerType; + @override + final String? projectRootPath; + Map toJson() => { VsCodeDebugSession.jsonIdField: id, VsCodeDebugSession.jsonNameField: name, @@ -207,6 +213,7 @@ class VsCodeDebugSessionImpl implements VsCodeDebugSession { VsCodeDebugSession.jsonFlutterModeField: flutterMode, VsCodeDebugSession.jsonFlutterDeviceIdField: flutterDeviceId, VsCodeDebugSession.jsonDebuggerTypeField: debuggerType, + VsCodeDebugSession.jsonProjectRootPathField: projectRootPath, }; } diff --git a/packages/devtools_app/lib/src/standalone_ui/api/vs_code_api.dart b/packages/devtools_app/lib/src/standalone_ui/api/vs_code_api.dart index 75872af65cb..c7870421da0 100644 --- a/packages/devtools_app/lib/src/standalone_ui/api/vs_code_api.dart +++ b/packages/devtools_app/lib/src/standalone_ui/api/vs_code_api.dart @@ -151,12 +151,23 @@ abstract interface class VsCodeDebugSession { /// - WebTest (webdev test) String? get debuggerType; + /// The full path to the root of this project (the folder that contains the + /// `pubspec.yaml`). + /// + /// This path might not always be available, for example: + /// + /// - When the version of Dart-Code is from before this field was added + /// - When a debug session was an attach and we didn't know the source + /// - When the program being run is a lose file without any pubspec + String? get projectRootPath; + static const jsonIdField = 'id'; static const jsonNameField = 'name'; static const jsonVmServiceUriField = 'vmServiceUri'; static const jsonFlutterModeField = 'flutterMode'; static const jsonFlutterDeviceIdField = 'flutterDeviceId'; static const jsonDebuggerTypeField = 'debuggerType'; + static const jsonProjectRootPathField = 'projectRootPath'; } /// This class defines a device event sent by the Dart/Flutter extensions in VS diff --git a/packages/devtools_app/test/test_infra/test_data/dart_tooling_api/mock_api.dart b/packages/devtools_app/test/test_infra/test_data/dart_tooling_api/mock_api.dart index ac7504c1fd2..21b6fc77226 100644 --- a/packages/devtools_app/test/test_infra/test_data/dart_tooling_api/mock_api.dart +++ b/packages/devtools_app/test/test_infra/test_data/dart_tooling_api/mock_api.dart @@ -220,6 +220,7 @@ class MockDartToolingApi extends DartToolingApiImpl { flutterMode: mode, flutterDeviceId: deviceId, debuggerType: 'Flutter', + projectRootPath: null, ), ); _sendDebugSessionsChanged();