| 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);
|
| + }
|
| + }
|
| });
|
| }
|
|
|
|
|