Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 1042923002: Issue 22617. Add/remove overlay-only sources to their containing contexts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/update_content_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bad954c6c7ac1dccaaf732881d9474235c815967..fc1957cd7f3710d4afa6c054b38430fa0b40e142 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -1038,10 +1038,24 @@ class AnalysisServer {
throw new AnalysisException('Illegal change type');
}
overlayState.setContents(source, newContents);
+ // 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) {
+ List<Source> sources = context.getSourcesWithFullName(file);
+ ChangeSet changeSet = new ChangeSet();
+ sources.forEach(changeSet.removedSource);
+ context.applyChanges(changeSet);
+ schedulePerformAnalysisOperation(context);
+ }
+ return;
+ }
// Update all contexts.
+ bool anyContextUpdated = false;
for (InternalAnalysisContext context in folderMap.values) {
List<Source> sources = context.getSourcesWithFullName(file);
sources.forEach((Source source) {
+ anyContextUpdated = true;
if (context.handleContentsChanged(
source, oldContents, newContents, true)) {
schedulePerformAnalysisOperation(context);
@@ -1067,6 +1081,16 @@ class AnalysisServer {
}
});
}
+ // The source is not analyzed by any context, add to the containing one.
+ if (!anyContextUpdated) {
+ AnalysisContext context = contextSource.context;
+ if (context != null && source != null) {
+ ChangeSet changeSet = new ChangeSet();
+ changeSet.addedSource(source);
+ context.applyChanges(changeSet);
+ schedulePerformAnalysisOperation(context);
+ }
+ }
});
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/update_content_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698