KT-4158 Autopopup completion selects irrelevant keyword and confuses typing
#KT-4158 Fixed
This commit is contained in:
+3
-4
@@ -28,11 +28,10 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
* Special contributor for getting completion of type for extensions receiver.
|
||||
*/
|
||||
public class JetExtensionReceiverTypeContributor extends CompletionContributor {
|
||||
// A way to add reference into file at completion place
|
||||
public static final String DUMMY_IDENTIFIER = "KotlinExtensionDummy.fake() {}";
|
||||
|
||||
static final String DUMMY_IDENTIFIER = "KotlinExtensionDummy.fake() {}";
|
||||
|
||||
static final ElementPattern<? extends PsiElement> ACTIVATION_PATTERN =
|
||||
// TODO: Check for fun with generic type parameters
|
||||
public static final ElementPattern<? extends PsiElement> ACTIVATION_PATTERN =
|
||||
PlatformPatterns.psiElement().afterLeaf(
|
||||
JetTokens.FUN_KEYWORD.toString(),
|
||||
JetTokens.VAL_KEYWORD.toString(),
|
||||
|
||||
@@ -33,17 +33,15 @@ import com.intellij.psi.filters.position.PositionElementFilter
|
||||
import com.intellij.util.containers.MultiMap
|
||||
import java.util.HashSet
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.codeInsight.completion.PrefixMatcher
|
||||
import com.intellij.codeInsight.completion.CompletionProvider
|
||||
import com.intellij.codeInsight.completion.CompletionParameters
|
||||
import com.intellij.codeInsight.completion.CompletionResultSet
|
||||
import com.intellij.util.ProcessingContext
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
||||
import com.intellij.codeInsight.completion.*
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler
|
||||
import com.intellij.psi.filters.position.FilterPattern
|
||||
import com.intellij.patterns.PlatformPatterns
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetKeywordInsertHandler
|
||||
import org.jetbrains.jet.plugin.completion.weigher.addJetSorting
|
||||
import com.intellij.util.ProcessingContext
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
||||
import com.intellij.psi.filters.position.FilterPattern
|
||||
import com.intellij.patterns.PlatformPatterns
|
||||
import com.intellij.psi.filters.position.PatternFilter
|
||||
|
||||
public open class JetKeywordCompletionContributor() : CompletionContributor() {
|
||||
{
|
||||
@@ -153,6 +151,7 @@ public open class JetKeywordCompletionContributor() : CompletionContributor() {
|
||||
CommentFilter(),
|
||||
ParentFilter(ClassFilter(javaClass<JetLiteralStringTemplateEntry>())),
|
||||
ParentFilter(ClassFilter(javaClass<JetConstantExpression>())),
|
||||
PatternFilter(JetExtensionReceiverTypeContributor.ACTIVATION_PATTERN),
|
||||
LeftNeighbour(TextFilter("."))
|
||||
))
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
val <caret>
|
||||
}
|
||||
|
||||
// NUMBER: 0
|
||||
/* KT-4158 Type "var i" and press space. "var if" is auto-inserted. */
|
||||
@@ -2,51 +2,4 @@ fun <caret>() {
|
||||
|
||||
}
|
||||
|
||||
// ABSENT: abstract
|
||||
// ABSENT: annotation
|
||||
// ABSENT: as
|
||||
// ABSENT: break
|
||||
// ABSENT: by
|
||||
// ABSENT: catch
|
||||
// ABSENT: class
|
||||
// ABSENT: continue
|
||||
// ABSENT: do
|
||||
// ABSENT: else
|
||||
// ABSENT: enum
|
||||
// ABSENT: false
|
||||
// ABSENT: final
|
||||
// ABSENT: finally
|
||||
// ABSENT: for
|
||||
// ABSENT: fun
|
||||
// ABSENT: get
|
||||
// ABSENT: if
|
||||
// ABSENT: import
|
||||
// ABSENT: in
|
||||
// ABSENT: inline
|
||||
// ABSENT: internal
|
||||
// ABSENT: is
|
||||
// ABSENT: null
|
||||
// ABSENT: object
|
||||
// ABSENT: open
|
||||
// ABSENT: out
|
||||
// ABSENT: override
|
||||
// ABSENT: package
|
||||
// ABSENT: private
|
||||
// ABSENT: protected
|
||||
// ABSENT: public
|
||||
// ABSENT: return
|
||||
// ABSENT: set
|
||||
// ABSENT: super
|
||||
// ABSENT: This
|
||||
// ABSENT: this
|
||||
// ABSENT: throw
|
||||
// ABSENT: trait
|
||||
// ABSENT: true
|
||||
// ABSENT: try
|
||||
// ABSENT: type
|
||||
// ABSENT: val
|
||||
// ABSENT: var
|
||||
// ABSENT: vararg
|
||||
// ABSENT: when
|
||||
// ABSENT: where
|
||||
// ABSENT: while
|
||||
// NUMBER: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
val <caret>
|
||||
}
|
||||
|
||||
// NUMBER: 0
|
||||
|
||||
/* KT-4158 Type "var i" and press space. "var if" is auto-inserted. */
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
var <caret>
|
||||
|
||||
// NUMBER: 0
|
||||
|
||||
/* KT-4158 Type "var i" and press space. "var if" is auto-inserted. */
|
||||
@@ -71,6 +71,11 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
||||
doTest("idea/testData/completion/keywords/InClassBeforeFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InClassNoCompletionInValName.kt")
|
||||
public void testInClassNoCompletionInValName() throws Exception {
|
||||
doTest("idea/testData/completion/keywords/InClassNoCompletionInValName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InClassProperty.kt")
|
||||
public void testInClassProperty() throws Exception {
|
||||
doTest("idea/testData/completion/keywords/InClassProperty.kt");
|
||||
@@ -91,6 +96,11 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
||||
doTest("idea/testData/completion/keywords/InFunctionName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InFunctionNoCompletionInValName.kt")
|
||||
public void testInFunctionNoCompletionInValName() throws Exception {
|
||||
doTest("idea/testData/completion/keywords/InFunctionNoCompletionInValName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InFunctionScope.kt")
|
||||
public void testInFunctionScope() throws Exception {
|
||||
doTest("idea/testData/completion/keywords/InFunctionScope.kt");
|
||||
@@ -131,6 +141,11 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
||||
doTest("idea/testData/completion/keywords/InString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InTopNoCompletionInVarName.kt")
|
||||
public void testInTopNoCompletionInVarName() throws Exception {
|
||||
doTest("idea/testData/completion/keywords/InTopNoCompletionInVarName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InTopProperty.kt")
|
||||
public void testInTopProperty() throws Exception {
|
||||
doTest("idea/testData/completion/keywords/InTopProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user