KT-8624 Don't complete "dynamic" keyword when targeting JVM
#KT-8624 Fixed
This commit is contained in:
+1
-1
@@ -274,7 +274,7 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
||||
KeywordValues.process(keywordValueConsumer, callTypeAndReceiver, bindingContext, resolutionFacade, moduleDescriptor, isJvmModule)
|
||||
|
||||
val keywordsPrefix = prefix.substringBefore('@') // if there is '@' in the prefix - use shorter prefix to not loose 'this' etc
|
||||
KeywordCompletion.complete(expression ?: parameters.getPosition(), keywordsPrefix) { lookupElement ->
|
||||
KeywordCompletion.complete(expression ?: parameters.getPosition(), keywordsPrefix, isJvmModule) { lookupElement ->
|
||||
val keyword = lookupElement.lookupString
|
||||
if (keyword in keywordsToSkip) return@complete
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ object KeywordCompletion {
|
||||
|
||||
private val KEYWORDS_TO_IGNORE_PREFIX = TokenSet.create(OVERRIDE_KEYWORD /* it's needed to complete overrides that should be work by member name too */)
|
||||
|
||||
public fun complete(position: PsiElement, prefix: String, consumer: (LookupElement) -> Unit) {
|
||||
public fun complete(position: PsiElement, prefix: String, isJvmModule: Boolean, consumer: (LookupElement) -> Unit) {
|
||||
if (!GENERAL_FILTER.isAcceptable(position, position)) return
|
||||
|
||||
val parserFilter = buildFilter(position)
|
||||
for (keywordToken in ALL_KEYWORDS) {
|
||||
var keyword = keywordToken.getValue()
|
||||
|
||||
if (keyword == COMPANION_KEYWORD.getValue()) { // complete "companion object" instead of simply "companion" unless we are before "object" already
|
||||
if (keywordToken == COMPANION_KEYWORD) { // complete "companion object" instead of simply "companion" unless we are before "object" already
|
||||
fun PsiElement.isSpace() = this is PsiWhiteSpace && '\n' !in getText()
|
||||
|
||||
var next = position.nextLeaf { !(it.isSpace() || it.getText() == "$") }?.getText()
|
||||
@@ -72,6 +72,8 @@ object KeywordCompletion {
|
||||
}
|
||||
}
|
||||
|
||||
if (keywordToken == DYNAMIC_KEYWORD && isJvmModule) continue // not supported for JVM
|
||||
|
||||
// we use simple matching by prefix, not prefix matcher from completion
|
||||
if (!keyword.startsWith(prefix) && keywordToken !in KEYWORDS_TO_IGNORE_PREFIX) continue
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo() {
|
||||
val test: <caret>
|
||||
}
|
||||
|
||||
// EXIST: dynamic
|
||||
@@ -4,5 +4,4 @@ fun foo() {
|
||||
|
||||
/*TODO: Is 'package' type qualifier syntax correct?*/
|
||||
// EXIST: package
|
||||
// EXIST: dynamic
|
||||
// NOTHING_ELSE
|
||||
|
||||
+6
@@ -2260,6 +2260,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DynamicKeyword.kt")
|
||||
public void testDynamicKeyword() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/js/DynamicKeyword.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InPackage.kt")
|
||||
public void testInPackage() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/js/InPackage.kt");
|
||||
|
||||
Reference in New Issue
Block a user