@@ -26,13 +26,16 @@ enum ProjectKind {
26
26
unknown,
27
27
}
28
28
29
- /// Infers the [ProjectKind] of a given [Root ] .
29
+ /// Infers the [ProjectKind] of a given project at [rootUri ] .
30
30
///
31
31
/// Currently, this is done by checking for the existence of a `pubspec.yaml`
32
32
/// file and whether it contains a Flutter SDK dependency.
33
- Future <ProjectKind > inferProjectKind (Root root, FileSystem fileSystem) async {
33
+ Future <ProjectKind > inferProjectKind (
34
+ String rootUri,
35
+ FileSystem fileSystem,
36
+ ) async {
34
37
final pubspecFile = fileSystem
35
- .directory (Uri .parse (root.uri ))
38
+ .directory (Uri .parse (rootUri ))
36
39
.childFile ('pubspec.yaml' );
37
40
if (! await pubspecFile.exists ()) {
38
41
return ProjectKind .unknown;
@@ -73,7 +76,7 @@ Future<ProjectKind> inferProjectKind(Root root, FileSystem fileSystem) async {
73
76
/// root's 'paths'.
74
77
Future <CallToolResult > runCommandInRoots (
75
78
CallToolRequest request, {
76
- FutureOr <String > Function (Root , FileSystem , Sdk ) commandForRoot =
79
+ FutureOr <String > Function (String , FileSystem , Sdk ) commandForRoot =
77
80
defaultCommandForRoot,
78
81
List <String > arguments = const [],
79
82
required String commandDescription,
@@ -138,7 +141,7 @@ Future<CallToolResult> runCommandInRoots(
138
141
Future <CallToolResult > runCommandInRoot (
139
142
CallToolRequest request, {
140
143
Map <String , Object ?>? rootConfig,
141
- FutureOr <String > Function (Root , FileSystem , Sdk ) commandForRoot =
144
+ FutureOr <String > Function (String , FileSystem , Sdk ) commandForRoot =
142
145
defaultCommandForRoot,
143
146
List <String > arguments = const [],
144
147
required String commandDescription,
@@ -192,7 +195,7 @@ Future<CallToolResult> runCommandInRoot(
192
195
final projectRoot = fileSystem.directory (rootUri);
193
196
194
197
final commandWithPaths = < String > [
195
- await commandForRoot (root , fileSystem, sdk),
198
+ await commandForRoot (rootUriString , fileSystem, sdk),
196
199
...arguments,
197
200
];
198
201
final paths =
@@ -247,17 +250,17 @@ Future<CallToolResult> runCommandInRoot(
247
250
///
248
251
/// Throws an [ArgumentError] if there is no pubspec.
249
252
Future <String > defaultCommandForRoot (
250
- Root root ,
253
+ String rootUri ,
251
254
FileSystem fileSystem,
252
255
Sdk sdk,
253
- ) async => switch (await inferProjectKind (root , fileSystem)) {
256
+ ) async => switch (await inferProjectKind (rootUri , fileSystem)) {
254
257
ProjectKind .dart => sdk.dartExecutablePath,
255
258
ProjectKind .flutter => sdk.flutterExecutablePath,
256
259
ProjectKind .unknown =>
257
260
throw ArgumentError .value (
258
- root.uri ,
259
- 'root.uri ' ,
260
- 'Unknown project kind at root ${ root . uri } . All projects must have a '
261
+ rootUri ,
262
+ 'rootUri ' ,
263
+ 'Unknown project kind at root $rootUri . All projects must have a '
261
264
'pubspec.' ,
262
265
),
263
266
};
0 commit comments