KT-31762: Fix completion in enum entries constructors
- The issue was caused by incorrect parsing of enum entry because of `$` in the `KotlinCompletionContributor::DEFAULT_DUMMY_IDENTIFIER` - Incorrect parsing caused arguments next to completed one to be recognized as another enum entries - Change `KotlinCompletionContributor::isInClassHeader` to accept classes without bodies, so identifier without `$` is used inside enum entries constructors - ^KT-31762 Fixed
This commit is contained in:
committed by
Roman Golyshev
parent
042100ea77
commit
3661dedacf
+2
-2
@@ -170,9 +170,9 @@ class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
private fun isInClassHeader(tokenBefore: PsiElement?): Boolean {
|
private fun isInClassHeader(tokenBefore: PsiElement?): Boolean {
|
||||||
val classOrObject = tokenBefore?.parents?.firstIsInstanceOrNull<KtClassOrObject>() ?: return false
|
val classOrObject = tokenBefore?.parents?.firstIsInstanceOrNull<KtClassOrObject>() ?: return false
|
||||||
val name = classOrObject.nameIdentifier ?: return false
|
val name = classOrObject.nameIdentifier ?: return false
|
||||||
val body = classOrObject.getBody() ?: return false
|
val headerEnd = classOrObject.body?.startOffset ?: classOrObject.endOffset
|
||||||
val offset = tokenBefore.startOffset
|
val offset = tokenBefore.startOffset
|
||||||
return name.endOffset <= offset && offset <= body.startOffset
|
return name.endOffset <= offset && offset <= headerEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun specialLambdaSignatureDummyIdentifier(tokenBefore: PsiElement?): String? {
|
private fun specialLambdaSignatureDummyIdentifier(tokenBefore: PsiElement?): String? {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
enum class A { AAA }
|
||||||
|
enum class E(val one: A, val two: A) {
|
||||||
|
EE(A.<caret>, A.AAA)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: AAA
|
||||||
+5
@@ -440,6 +440,11 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
runTest("idea/idea-completion/testData/basic/common/KT13780_1.kt");
|
runTest("idea/idea-completion/testData/basic/common/KT13780_1.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("KT31762.kt")
|
||||||
|
public void testKT31762() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/KT31762.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("KT33903_1.kt")
|
@TestMetadata("KT33903_1.kt")
|
||||||
public void testKT33903_1() throws Exception {
|
public void testKT33903_1() throws Exception {
|
||||||
runTest("idea/idea-completion/testData/basic/common/KT33903_1.kt");
|
runTest("idea/idea-completion/testData/basic/common/KT33903_1.kt");
|
||||||
|
|||||||
+5
@@ -440,6 +440,11 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
runTest("idea/idea-completion/testData/basic/common/KT13780_1.kt");
|
runTest("idea/idea-completion/testData/basic/common/KT13780_1.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("KT31762.kt")
|
||||||
|
public void testKT31762() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/KT31762.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("KT33903_1.kt")
|
@TestMetadata("KT33903_1.kt")
|
||||||
public void testKT33903_1() throws Exception {
|
public void testKT33903_1() throws Exception {
|
||||||
runTest("idea/idea-completion/testData/basic/common/KT33903_1.kt");
|
runTest("idea/idea-completion/testData/basic/common/KT33903_1.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user