Index: pkg/analyzer_plugin/lib/src/utilities/completion.dart |
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion.dart b/pkg/analyzer_plugin/lib/src/utilities/completion.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..341b289cd43ee32e298b08dbceb0154c71f3517b |
--- /dev/null |
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion.dart |
@@ -0,0 +1,72 @@ |
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+import 'package:analyzer/dart/analysis/results.dart'; |
+import 'package:analyzer/file_system/file_system.dart'; |
+import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
+import 'package:analyzer_plugin/utilities/completion.dart'; |
+ |
+/** |
+ * An object that can collect completion suggestions. |
+ */ |
+class CompletionCollectorImpl implements CompletionCollector { |
+ @override |
+ int length; |
+ |
+ @override |
+ int offset; |
+ |
+ /** |
+ * A list of the completion suggestions that have been collected. |
+ */ |
+ List<CompletionSuggestion> suggestions; |
+ |
+ /** |
+ * Initialize a newly created completion collector. |
+ */ |
+ CompletionCollectorImpl(); |
+ |
+ @override |
+ void addSuggestion(CompletionSuggestion suggestion) { |
+ suggestions.add(suggestion); |
+ } |
+} |
+ |
+/** |
+ * Information about the completion request that was made. |
+ */ |
+class CompletionRequestImpl implements CompletionRequest { |
+ @override |
+ final int offset; |
+ |
+ @override |
+ final ResourceProvider resourceProvider; |
+ |
+ @override |
+ final ResolveResult result; |
mfairhurst
2017/05/31 21:49:34
I mentioned this elsewhere in an email, this `resu
Brian Wilkerson
2017/05/31 22:51:47
Actually, you need this field because it's needed
mfairhurst
2017/05/31 23:17:36
Strictly speaking, I don't think either use this f
|
+ |
+ /** |
+ * A flag indicating whether completion has been aborted. |
+ */ |
+ bool _aborted = false; |
+ |
+ /** |
+ * Initialize a newly created request. |
+ */ |
+ CompletionRequestImpl(this.resourceProvider, this.result, this.offset); |
+ |
+ /** |
+ * Abort the current completion request. |
+ */ |
+ void abort() { |
+ _aborted = true; |
+ } |
+ |
+ @override |
+ void checkAborted() { |
+ if (_aborted) { |
+ throw new AbortCompletion(); |
+ } |
+ } |
+} |