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 cb66929cd6f14b9e61dcc1ec00503244ca61fd01..2544c836bce4e3e1b599aec2d123f26f64e843c4 100644 |
--- a/pkg/analysis_server/lib/src/analysis_server.dart |
+++ b/pkg/analysis_server/lib/src/analysis_server.dart |
@@ -156,12 +156,6 @@ class AnalysisServer { |
final InstrumentationService instrumentationService; |
/** |
- * A table mapping [Folder]s to the [AnalysisContext]s associated with them. |
- */ |
- final Map<Folder, AnalysisContext> folderMap = |
- new HashMap<Folder, AnalysisContext>(); |
- |
- /** |
* A queue of the operations to perform in this server. |
*/ |
ServerOperationQueue operationQueue; |
@@ -355,6 +349,19 @@ class AnalysisServer { |
} |
/** |
+ * Return the [AnalysisContext]s that are being used to analyze the analysis |
+ * roots. |
+ */ |
+ Iterable<AnalysisContext> get analysisContexts => |
+ contextManager.analysisContexts; |
+ |
+ /** |
+ * Return a table mapping [Folder]s to the [AnalysisContext]s associated with |
+ * them. |
+ */ |
+ Map<Folder, AnalysisContext> get folderMap => contextManager.folderMap; |
+ |
+ /** |
* The [Future] that completes when analysis is complete. |
*/ |
Future get onAnalysisComplete { |
@@ -465,7 +472,7 @@ class AnalysisServer { |
* explicitly or implicitly. Return `null` if there is no such context. |
*/ |
AnalysisContext getAnalysisContextForSource(Source source) { |
- for (AnalysisContext context in folderMap.values) { |
+ for (AnalysisContext context in analysisContexts) { |
SourceKind kind = context.getKindOf(source); |
if (kind != SourceKind.UNKNOWN) { |
return context; |
@@ -474,14 +481,6 @@ class AnalysisServer { |
return null; |
} |
- /** |
- * Return the [AnalysisContext]s that are being used to analyze the analysis |
- * roots. |
- */ |
- Iterable<AnalysisContext> getAnalysisContexts() { |
- return folderMap.values; |
- } |
- |
CompilationUnitElement getCompilationUnitElement(String file) { |
ContextSourcePair pair = getContextSourcePair(file); |
if (pair == null) { |
@@ -557,7 +556,7 @@ class AnalysisServer { |
} |
} |
// try to find a context that analysed the file |
- for (AnalysisContext context in folderMap.values) { |
+ for (AnalysisContext context in analysisContexts) { |
Source source = ContextManagerImpl.createSourceInContext(context, file); |
SourceKind kind = context.getKindOf(source); |
if (kind != SourceKind.UNKNOWN) { |
@@ -565,7 +564,7 @@ class AnalysisServer { |
} |
} |
// try to find a context for which the file is a priority source |
- for (InternalAnalysisContext context in folderMap.values) { |
+ for (InternalAnalysisContext context in analysisContexts) { |
List<Source> sources = context.getSourcesWithFullName(path); |
if (sources.isNotEmpty) { |
Source source = sources.first; |
@@ -1117,7 +1116,7 @@ class AnalysisServer { |
if (preferredContext == null) { |
Resource resource = resourceProvider.getResource(file); |
if (resource is File && resource.exists) { |
- for (AnalysisContext context in folderMap.values) { |
+ for (AnalysisContext context in analysisContexts) { |
Uri uri = context.sourceFactory.restoreUri(source); |
if (uri.scheme != 'file') { |
preferredContext = context; |
@@ -1134,7 +1133,7 @@ class AnalysisServer { |
sourceMap.putIfAbsent(preferredContext, () => <Source>[]).add(source); |
contextFound = true; |
} |
- for (AnalysisContext context in folderMap.values) { |
+ for (AnalysisContext context in analysisContexts) { |
if (context != preferredContext && |
context.getKindOf(source) != SourceKind.UNKNOWN) { |
sourceMap.putIfAbsent(context, () => <Source>[]).add(source); |
@@ -1248,7 +1247,7 @@ class AnalysisServer { |
// If the source does not exist, then it was an overlay-only one. |
// Remove it from contexts. |
if (newContents == null && !source.exists()) { |
- for (InternalAnalysisContext context in folderMap.values) { |
+ for (InternalAnalysisContext context in analysisContexts) { |
List<Source> sources = context.getSourcesWithFullName(file); |
ChangeSet changeSet = new ChangeSet(); |
sources.forEach(changeSet.removedSource); |
@@ -1259,7 +1258,7 @@ class AnalysisServer { |
} |
// Update all contexts. |
bool anyContextUpdated = false; |
- for (InternalAnalysisContext context in folderMap.values) { |
+ for (InternalAnalysisContext context in analysisContexts) { |
List<Source> sources = context.getSourcesWithFullName(file); |
sources.forEach((Source source) { |
anyContextUpdated = true; |
@@ -1316,7 +1315,7 @@ class AnalysisServer { |
// |
// Update existing contexts. |
// |
- folderMap.forEach((Folder folder, AnalysisContext context) { |
+ for (AnalysisContext context in analysisContexts) { |
AnalysisOptionsImpl options = |
new AnalysisOptionsImpl.from(context.analysisOptions); |
optionUpdaters.forEach((OptionUpdater optionUpdater) { |
@@ -1325,7 +1324,8 @@ class AnalysisServer { |
context.analysisOptions = options; |
// TODO(brianwilkerson) As far as I can tell, this doesn't cause analysis |
// to be scheduled for this context. |
- }); |
+ } |
+ ; |
Paul Berry
2016/02/29 21:46:31
Stray `;`
Brian Wilkerson
2016/02/29 22:04:13
Done
|
// |
// Update the defaults used to create new contexts. |
// |