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

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

Issue 417433003: Send responses for any pending 'analysis.getErrors' requests during context removal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 6 years, 5 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/lib/src/domain_analysis.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 285e82ff8cbfd104ffe69cedcd6e1667301da125..995de16eb9e90f5fd32886a1cd4f71cd05f3037d 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -56,13 +56,18 @@ 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) {
+ context.applyChanges(changeSet);
+ analysisServer.schedulePerformAnalysisOperation(context);
+ }
}
@override
void removeContext(Folder folder) {
- analysisServer.folderMap.remove(folder);
+ AnalysisContext context = analysisServer.folderMap.remove(folder);
+ analysisServer.sendContextAnalysisCancelledNotifications(
+ context,
+ 'Context was removed');
}
@override
@@ -572,11 +577,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].
+ *
+ * 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.
*
- * May return `null`.
+ * 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 +653,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 +676,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.
*/
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698