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..62a6ce76a5a1a4451d5457224f1f459461d3d2e8 100644 |
--- a/pkg/analysis_server/lib/src/context_manager.dart |
+++ b/pkg/analysis_server/lib/src/context_manager.dart |
@@ -164,12 +164,24 @@ abstract class ContextManager { |
/** |
* 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); |