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
This commit is contained in:
+10
@@ -82,6 +82,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
else -> specialExtensionReceiverDummyIdentifier(tokenBefore)
|
else -> specialExtensionReceiverDummyIdentifier(tokenBefore)
|
||||||
?: specialInTypeArgsDummyIdentifier(tokenBefore)
|
?: specialInTypeArgsDummyIdentifier(tokenBefore)
|
||||||
?: specialInParameterListDummyIdentifier(tokenBefore)
|
?: specialInParameterListDummyIdentifier(tokenBefore)
|
||||||
|
?: specialInArgumentListDummyIdentifier(tokenBefore)
|
||||||
?: DEFAULT_DUMMY_IDENTIFIER
|
?: DEFAULT_DUMMY_IDENTIFIER
|
||||||
}
|
}
|
||||||
context.setDummyIdentifier(dummyIdentifier)
|
context.setDummyIdentifier(dummyIdentifier)
|
||||||
@@ -368,6 +369,15 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
return null
|
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<JetValueArgumentList>() ?: return null
|
||||||
|
if (argumentList.getParent() is JetConstructorDelegationCall) return CompletionUtil.DUMMY_IDENTIFIER_TRIMMED
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
private fun countParenthesisBalance(at: PsiElement, container: PsiElement): Int {
|
private fun countParenthesisBalance(at: PsiElement, container: PsiElement): Int {
|
||||||
val stopAt = container.prevLeaf()
|
val stopAt = container.prevLeaf()
|
||||||
var current: PsiElement? = at
|
var current: PsiElement? = at
|
||||||
|
|||||||
Reference in New Issue
Block a user