Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 2533533002: Prefer a driver to which the file is added. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 2e7eb0903a42effba0128c3414c683920729fedb..e28b17ba1f197b4b2595e3edce3875742ce9a00f 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -588,14 +588,21 @@ class AnalysisServer {
}
/**
- * Return the analysis driver to which the file with the given [path] is
- * added if exists, otherwise the first driver, otherwise `null`.
+ * Return an analysis driver to which the file with the given [path] is
+ * added if exists, otherwise a driver in which the file was analyzed if
Brian Wilkerson 2016/11/28 16:43:32 "if exists" --> "if one exists" (two places)
+ * exists, otherwise the first driver, otherwise `null`.
*/
nd.AnalysisDriver getAnalysisDriver(String path) {
Iterable<nd.AnalysisDriver> drivers = driverMap.values;
if (drivers.isNotEmpty) {
- return drivers.firstWhere((driver) => driver.knownFiles.contains(path),
- orElse: () => drivers.first);
+ nd.AnalysisDriver driver = drivers.firstWhere(
+ (driver) => driver.addedFiles.contains(path),
+ orElse: () => null);
+ driver ??= drivers.firstWhere(
+ (driver) => driver.knownFiles.contains(path),
+ orElse: () => null);
+ driver ??= drivers.first;
+ return driver;
}
return null;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698