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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/completion/DartCompletionProposal.java

Issue 172763003: Issue 16153. Auto-complete for import statements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Extract helper and use marker constant Created 6 years, 10 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
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/completion/DartCompletionProposal.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/completion/DartCompletionProposal.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/completion/DartCompletionProposal.java
index fdf4a65d289413f71e349099944df93760321006..8cf1cba1c024fb502e7accea0127e64611c6b4b2 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/completion/DartCompletionProposal.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/completion/DartCompletionProposal.java
@@ -14,6 +14,7 @@
package com.google.dart.tools.ui.internal.text.completion;
import com.google.dart.engine.element.Element;
+import com.google.dart.tools.core.completion.CompletionProposal;
import com.google.dart.tools.ui.internal.text.editor.DartTextHover;
import com.google.dart.tools.ui.text.dart.DartContentAssistInvocationContext;
@@ -107,6 +108,18 @@ public class DartCompletionProposal extends AbstractDartCompletionProposal {
Assert.isTrue(replacementLength >= 0);
Assert.isTrue(replacementLengthIdentifier >= 0);
+ // put cursor at the marker position
+ int cursorPos = replacementString.length();
+ {
+ int exclamationPos = replacementString.indexOf(CompletionProposal.CURSOR_MARKER);
+ if (exclamationPos != -1) {
+ cursorPos = exclamationPos;
+ replacementString = replacementString.substring(0, exclamationPos)
+ + replacementString.substring(exclamationPos + 1);
+ triggerCompletionAfterApply = true;
+ }
+ }
+
setReplacementString(replacementString);
setReplacementOffset(replacementOffset);
setReplacementLength(replacementLength);
@@ -115,7 +128,7 @@ public class DartCompletionProposal extends AbstractDartCompletionProposal {
setStyledDisplayString(displayString == null ? new StyledString(replacementString)
: displayString);
setRelevance(relevance);
- setCursorPosition(replacementString.length());
+ setCursorPosition(cursorPos);
setInDartDoc(inJavadoc);
setSortString(displayString == null ? replacementString : displayString.getString());
setElement(element);

Powered by Google App Engine
This is Rietveld 408576698