Chromium Code Reviews| 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 285e82ff8cbfd104ffe69cedcd6e1667301da125..62beafe4b3bdf819f7401bf281090258051127a8 100644 |
| --- a/pkg/analysis_server/lib/src/analysis_server.dart |
| +++ b/pkg/analysis_server/lib/src/analysis_server.dart |
| @@ -56,13 +56,20 @@ class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { |
| @override |
| void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| AnalysisContext context = analysisServer.folderMap[contextFolder]; |
| - context.applyChanges(changeSet); |
| - analysisServer.schedulePerformAnalysisOperation(context); |
| + if (context != null) { |
|
Paul Berry
2014/07/23 15:06:51
This check shouldn't be necessary. The caller wil
scheglov
2014/07/24 16:54:04
We need this in case if "folder removed" watch eve
Paul Berry
2014/07/24 17:32:04
I believe this won't ever happen in production cod
|
| + context.applyChanges(changeSet); |
| + analysisServer.schedulePerformAnalysisOperation(context); |
| + } |
| } |
| @override |
| void removeContext(Folder folder) { |
| - analysisServer.folderMap.remove(folder); |
| + AnalysisContext context = analysisServer.folderMap.remove(folder); |
| + if (context != null) { |
|
Paul Berry
2014/07/23 15:06:51
Similar situation with this check.
scheglov
2014/07/24 16:54:03
OK
I think we can trust watcher that it won't tel
|
| + analysisServer.sendContextAnalysisCancelledNotifications( |
| + context, |
| + 'Context was removed'); |
| + } |
| } |
| @override |
| @@ -572,11 +579,16 @@ class AnalysisServer { |
| } |
| /** |
| - * Returns all the [AnalysisErrorInfo] for [file]. |
| - * It does not wait for all errors to be computed, and returns just the |
| - * current state. |
| + * Return an analysis error info containing the array of all of the errors and |
| + * the line info associated with [file]. |
| + * |
| + * Returns `null` if [file] does not belong to any [AnalysisContext]. |
| * |
| - * May return `null`. |
| + * The array of errors will be empty if [file] does not exist or if there are |
| + * no errors in [file]. The errors contained in the array can be incomplete. |
| + * |
| + * This method does not wait for all errors to be computed, and returns just |
| + * the current state. |
| */ |
| AnalysisErrorInfo getErrors(String file) { |
| // prepare AnalysisContext |
| @@ -643,12 +655,6 @@ class AnalysisServer { |
| * |
| * 2. We should complete the future as soon as the file is analyzed (not wait |
| * until the context is completely finished) |
| - * |
| - * 3. Since contexts can be created and deleted asynchronously as a result of |
| - * changes to the filesystem, there's a danger that the future might never |
| - * get completed. We should add a mechanism to make sure that we return an |
| - * error for any getErrors request that is unsatisfiable due to its context |
| - * being deleted. |
| */ |
| Future onFileAnalysisComplete(String file) { |
| // prepare AnalysisContext |
| @@ -672,13 +678,24 @@ class AnalysisServer { |
| * done. |
| */ |
| void sendContextAnalysisDoneNotifications(AnalysisContext context) { |
| - Completer completer = contextAnalysisDoneCompleters[context]; |
| + Completer completer = contextAnalysisDoneCompleters.remove(context); |
| if (completer != null) { |
| completer.complete(); |
| } |
| } |
| /** |
| + * This method is called when analysis of the given [AnalysisContext] is |
| + * cancelled. |
| + */ |
| + void sendContextAnalysisCancelledNotifications(AnalysisContext context, String message) { |
| + Completer completer = contextAnalysisDoneCompleters.remove(context); |
| + if (completer != null) { |
| + completer.completeError(message); |
| + } |
| + } |
| + |
| + /** |
| * Return the [CompilationUnit] of the Dart file with the given [path]. |
| * Return `null` if the file is not a part of any context. |
| */ |