Index: pkg/analysis_server/lib/src/context_manager.dart |
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart |
index c76ac5e9b43cd9ce02feba13ef84b47dc072c209..b52f6ad93cea4704370cb076b3b846b12045b908 100644 |
--- a/pkg/analysis_server/lib/src/context_manager.dart |
+++ b/pkg/analysis_server/lib/src/context_manager.dart |
@@ -163,13 +163,39 @@ abstract class ContextManager { |
} |
/** |
+ * Return a list containing all of the contexts contained in the given |
+ * [analysisRoot]. |
+ */ |
+ List<AnalysisContext> contextsInAnalysisRoot(Folder analysisRoot) { |
+ List<AnalysisContext> contexts = <AnalysisContext>[]; |
+ _contexts.forEach((Folder contextFolder, _ContextInfo info) { |
+ if (analysisRoot.isOrContains(contextFolder.path)) { |
+ contexts.add(info.context); |
+ } |
+ }); |
+ return contexts; |
+ } |
+ |
+ /** |
* Rebuild the set of contexts from scratch based on the data last sent to |
- * setRoots(). |
+ * setRoots(). Only contexts contained in the given list of analysis [roots] |
+ * will be rebuilt, unless the list is `null`, in which case every context |
+ * will be rebuilt. |
*/ |
- void refresh() { |
+ void refresh(List<Resource> roots) { |
// Destroy old contexts |
List<Folder> contextFolders = _contexts.keys.toList(); |
- contextFolders.forEach(_destroyContext); |
+ if (roots == null) { |
+ contextFolders.forEach(_destroyContext); |
+ } else { |
+ roots.forEach((Resource resource) { |
+ contextFolders.forEach((Folder contextFolder) { |
+ if (resource is Folder && resource.isOrContains(contextFolder.path)) { |
+ _destroyContext(contextFolder); |
+ } |
+ }); |
+ }); |
+ } |
// Rebuild contexts based on the data last sent to setRoots(). |
setRoots(includedPaths, excludedPaths, packageRoots); |