KT-2128 Code completion after number with dot - don't complete on '.' only in ".."

#KT-2128 Fixed
This commit is contained in:
Nikolay Krasko
2012-09-20 14:52:18 +04:00
parent b081615e59
commit 1ba4e5aee0
6 changed files with 27 additions and 6 deletions
@@ -16,7 +16,6 @@
package org.jetbrains.jet.plugin.completion;
import com.intellij.codeInsight.completion.CompletionCharFilter;
import com.intellij.codeInsight.lookup.CharFilter;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.psi.PsiFile;
@@ -24,8 +23,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetFile;
public class JetReferenceCharFilter extends CharFilter {
private final static CharFilter delegate = new CompletionCharFilter();
@Override
@Nullable
public Result acceptChar(char c, int prefixLength, Lookup lookup) {
@@ -34,10 +31,13 @@ public class JetReferenceCharFilter extends CharFilter {
return null;
}
if (c == '.') {
return Result.HIDE_LOOKUP;
if (c == '.' && prefixLength == 0 && !lookup.isSelectionTouched()) {
int caret = lookup.getEditor().getCaretModel().getOffset();
if (caret > 0 && lookup.getEditor().getDocument().getCharsSequence().charAt(caret - 1) == '.') {
return Result.HIDE_LOOKUP;
}
}
return delegate.acceptChar(c, prefixLength, lookup);
return null;
}
}
@@ -0,0 +1,3 @@
fun test() {
12.in<caret>
}
@@ -0,0 +1,3 @@
fun test() {
12.inc(). <caret>
}
@@ -0,0 +1,4 @@
fun test() {
for (i in 12.<caret>) {
}
}
@@ -0,0 +1,4 @@
fun test() {
for (i in 12.. ) {
}
}
@@ -30,6 +30,9 @@ import java.io.File;
* @author Nikolay Krasko
*/
public class JetConfidenceTest extends LightCompletionTestCase {
public void testCompleteOnDotOutOfRanges() {
doTest(".");
}
public void testImportAsConfidence() {
doTest("as");
@@ -51,6 +54,10 @@ public class JetConfidenceTest extends LightCompletionTestCase {
doTest("mm");
}
public void testNoAutoCompletionForRangeOperator() {
doTest(".");
}
protected void doTest(String completionActivateType) {
configureByFile(getBeforeFileName());
type(completionActivateType + " ");