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

Unified Diff: pkg/analysis_server/lib/src/services/completion/completion_core.dart

Issue 1531383002: move ReplacementRange into dart specific contributor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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/services/completion/dart/completion_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/completion_core.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/completion_core.dart b/pkg/analysis_server/lib/src/services/completion/completion_core.dart
index b65f4bf7c99550f1b21eff1c8b93667f6b0d4562..7048a6e99891650a582d61ae82a8bb11cf750756 100644
--- a/pkg/analysis_server/lib/src/services/completion/completion_core.dart
+++ b/pkg/analysis_server/lib/src/services/completion/completion_core.dart
@@ -23,6 +23,22 @@ class CompletionRequestImpl implements CompletionRequest {
@override
final int offset;
+ /**
+ * The offset of the start of the text to be replaced.
+ * This will be different than the offset used to request the completion
+ * suggestions if there was a portion of an identifier before the original
+ * offset. In particular, the replacementOffset will be the offset of the
+ * beginning of said identifier.
+ */
+ int replacementOffset;
+
+ /**
+ * The length of the text to be replaced if the remainder of the identifier
+ * containing the cursor is to be replaced when the suggestion is applied
+ * (that is, the number of characters in the existing identifier).
+ */
+ int replacementLength;
+
@override
final ResourceProvider resourceProvider;
@@ -33,5 +49,19 @@ class CompletionRequestImpl implements CompletionRequest {
* Initialize a newly created completion request based on the given arguments.
*/
CompletionRequestImpl(this.context, this.resourceProvider, this.searchEngine,
- this.source, this.offset);
+ this.source, this.offset) {
+ replacementOffset = offset;
+ replacementLength = 0;
+ }
+
+ /**
+ * Return the original text from the [replacementOffset] to the [offset]
+ * that can be used to filter the suggestions on the server side.
+ */
+ String get filterText {
+ return context
+ .getContents(source)
+ .data
+ .substring(replacementOffset, offset);
+ }
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698