diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt index 15a7121cdcd..635e99ddb9c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt @@ -82,6 +82,7 @@ public class KotlinCompletionContributor : CompletionContributor() { else -> specialExtensionReceiverDummyIdentifier(tokenBefore) ?: specialInTypeArgsDummyIdentifier(tokenBefore) ?: specialInParameterListDummyIdentifier(tokenBefore) + ?: specialInArgumentListDummyIdentifier(tokenBefore) ?: DEFAULT_DUMMY_IDENTIFIER } context.setDummyIdentifier(dummyIdentifier) @@ -368,6 +369,15 @@ public class KotlinCompletionContributor : CompletionContributor() { return null } + private fun specialInArgumentListDummyIdentifier(tokenBefore: PsiElement?): String? { + // If we insert $ in the argument list of a delegation specifier, this will break parsing + // and the following block will not be attached as a body to the constructor. Therefore + // we need to use a regular identifier. + val argumentList = tokenBefore?.getNonStrictParentOfType() ?: return null + if (argumentList.getParent() is JetConstructorDelegationCall) return CompletionUtil.DUMMY_IDENTIFIER_TRIMMED + return null + } + private fun countParenthesisBalance(at: PsiElement, container: PsiElement): Int { val stopAt = container.prevLeaf() var current: PsiElement? = at