From b98e2513f2bea1b07faeba859daefd9f6b701a77 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 27 Apr 2015 17:35:32 +0200 Subject: [PATCH] fix Common.testInSecondaryConstructorDelegationCall completion test: don't insert $ which breaks parsing of argument list and causes the block to be detached from the constructor itself --- .../idea/completion/KotlinCompletionContributor.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) 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