Chromium Code Reviews| 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; |
| } |