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

Commit 2d14d9a

Browse files
danrubelcommit-bot@chromium.org
authored andcommitted
Improve how dartfix finds the analysis server pkg root
Change-Id: Iead97b14a2eede8628ea286fedcccbafb4f3c2b7 Reviewed-on: https://dart-review.googlesource.com/c/80943 Reviewed-by: Devon Carew <devoncarew@google.com> Commit-Queue: Dan Rubel <danrubel@google.com>
1 parent a342cec commit 2d14d9a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/analyzer_cli/lib/src/fix/server.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ class Server {
9797

9898
/**
9999
* Find the root directory of the analysis_server package by proceeding
100-
* upward to the 'test' dir, and then going up one more directory.
100+
* upward until finding the Dart SDK repository root then returning
101+
* the analysis_server package root within the repository.
102+
* Return `null` if it cannot be found.
101103
*/
102104
static String findRoot([String pathname]) {
103105
pathname ??= Platform.script.toFilePath(windows: Platform.isWindows);
@@ -106,12 +108,10 @@ class Server {
106108
if (parent.length >= pathname.length) {
107109
return null;
108110
}
109-
String name = basename(pathname);
110-
if (['benchmark', 'test'].contains(name)) {
111-
return parent;
112-
}
113-
if (name == 'pkg') {
114-
return join(pathname, 'analysis_server');
111+
String root = normalize(join(parent, 'pkg', 'analysis_server'));
112+
String server = join(root, 'bin', 'server.dart');
113+
if (new File(server).existsSync()) {
114+
return root;
115115
}
116116
pathname = parent;
117117
}

0 commit comments

Comments
 (0)