Index: pkg/analysis_server/lib/src/provisional/completion/completion_core.dart |
diff --git a/pkg/analysis_server/lib/src/provisional/completion/completion_core.dart b/pkg/analysis_server/lib/src/provisional/completion/completion_core.dart |
index 9a585dd35a39cbc8c1d9817ea5964c443d5bbc40..1aa1c9f182d5179c609b940309ac583e4e18772b 100644 |
--- a/pkg/analysis_server/lib/src/provisional/completion/completion_core.dart |
+++ b/pkg/analysis_server/lib/src/provisional/completion/completion_core.dart |
@@ -26,6 +26,14 @@ const EMPTY_LIST = const <CompletionSuggestion>[]; |
typedef CompletionContributor CompletionContributorFactory(); |
/** |
+ * [AbortCompletion] is thrown when the current completion request |
+ * should be aborted because either |
+ * the source changed since the request was made, or |
+ * a new completion request was received. |
+ */ |
+class AbortCompletion {} |
+ |
+/** |
* An object used to produce completions at a specific location within a file. |
* |
* Clients may implement this class when implementing plugins. |
@@ -33,7 +41,8 @@ typedef CompletionContributor CompletionContributorFactory(); |
abstract class CompletionContributor { |
/** |
* Return a [Future] that completes with a list of suggestions |
- * for the given completion [request]. |
+ * for the given completion [request]. This will |
+ * throw [AbortCompletion] if the completion request has been aborted. |
*/ |
Future<List<CompletionSuggestion>> computeSuggestions( |
CompletionRequest request); |
@@ -70,4 +79,9 @@ abstract class CompletionRequest { |
* Return the source in which the completion is being requested. |
*/ |
Source get source; |
+ |
+ /** |
+ * Throw [AbortCompletion] if the completion request has been aborted. |
+ */ |
+ void checkAborted(); |
} |