EA-215308: Fix unsafe check casts in template entry handling
This commit is contained in:
+15
-13
@@ -243,20 +243,22 @@ class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
val toFromOriginalFileMapper = ToFromOriginalFileMapper.create(parameters)
|
val toFromOriginalFileMapper = ToFromOriginalFileMapper.create(parameters)
|
||||||
|
|
||||||
if (position.node.elementType == KtTokens.LONG_TEMPLATE_ENTRY_START) {
|
if (position.node.elementType == KtTokens.LONG_TEMPLATE_ENTRY_START) {
|
||||||
val expression = (position.parent as KtBlockStringTemplateEntry).expression
|
val expression = (position.parent as? KtBlockStringTemplateEntry)?.expression
|
||||||
if (expression is KtDotQualifiedExpression) {
|
if (expression is KtDotQualifiedExpression) {
|
||||||
val correctedPosition = (expression.selectorExpression as KtNameReferenceExpression).firstChild
|
val correctedPosition = (expression.selectorExpression as? KtNameReferenceExpression)?.firstChild
|
||||||
// Workaround for KT-16848
|
if (correctedPosition != null) {
|
||||||
// ex:
|
// Workaround for KT-16848
|
||||||
// expression: some.IntellijIdeaRulezzz
|
// ex:
|
||||||
// correctedOffset: ^
|
// expression: some.IntellijIdeaRulezzz
|
||||||
// expression: some.funcIntellijIdeaRulezzz
|
// correctedOffset: ^
|
||||||
// correctedOffset ^
|
// expression: some.funcIntellijIdeaRulezzz
|
||||||
val correctedOffset = correctedPosition.endOffset - CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED.length
|
// correctedOffset ^
|
||||||
val correctedParameters = parameters.withPosition(correctedPosition, correctedOffset)
|
val correctedOffset = correctedPosition.endOffset - CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED.length
|
||||||
doComplete(correctedParameters, toFromOriginalFileMapper, result,
|
val correctedParameters = parameters.withPosition(correctedPosition, correctedOffset)
|
||||||
lookupElementPostProcessor = { wrapLookupElementForStringTemplateAfterDotCompletion(it) })
|
doComplete(correctedParameters, toFromOriginalFileMapper, result,
|
||||||
return
|
lookupElementPostProcessor = { wrapLookupElementForStringTemplateAfterDotCompletion(it) })
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user