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 46ea3341e0115cfd28e9ac21e3e61095f2bb9b2a..bf7ee7307c22c2c3404a14abec42a980a405a63a 100644 |
--- a/pkg/analysis_server/lib/src/analysis_server.dart |
+++ b/pkg/analysis_server/lib/src/analysis_server.dart |
@@ -561,6 +561,19 @@ class AnalysisServer { |
return null; |
} |
+ /** |
+ * Return the analysis driver to which the file with the given [path] is |
+ * added if 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.isAddedFile(path), |
+ orElse: () => drivers.first); |
+ } |
+ return null; |
+ } |
+ |
CompilationUnitElement getCompilationUnitElement(String file) { |
ContextSourcePair pair = getContextSourcePair(file); |
if (pair == null) { |