Fixed EA-76497

This commit is contained in:
Valentin Kipyatkov
2016-02-04 18:52:41 +03:00
parent bc2077bfaf
commit 8b6338ce62
4 changed files with 26 additions and 9 deletions
@@ -248,16 +248,18 @@ class KotlinCompletionContributor : CompletionContributor() {
val toFromOriginalFileMapper = ToFromOriginalFileMapper(originalFile, positionFile, parameters.offset)
if (position.node.elementType == KtTokens.LONG_TEMPLATE_ENTRY_START) {
val expression = (position.parent as KtBlockStringTemplateEntry).expression as KtDotQualifiedExpression
val correctedPosition = (expression.selectorExpression as KtNameReferenceExpression).firstChild
val context = position.getUserData(CompletionContext.COMPLETION_CONTEXT_KEY)!!
val correctedOffset = context.offsetMap.getOffset(STRING_TEMPLATE_AFTER_DOT_REAL_START_OFFSET)
val correctedParameters = parameters.withPosition(correctedPosition, correctedOffset)
performCompletionWithOutOfBlockTracking(position) {
doComplete(correctedParameters, toFromOriginalFileMapper, result,
lookupElementPostProcessor = { wrapLookupElementForStringTemplateAfterDotCompletion(it) })
val expression = (position.parent as KtBlockStringTemplateEntry).expression
if (expression is KtDotQualifiedExpression) {
val correctedPosition = (expression.selectorExpression as KtNameReferenceExpression).firstChild
val context = position.getUserData(CompletionContext.COMPLETION_CONTEXT_KEY)!!
val correctedOffset = context.offsetMap.getOffset(STRING_TEMPLATE_AFTER_DOT_REAL_START_OFFSET)
val correctedParameters = parameters.withPosition(correctedPosition, correctedOffset)
performCompletionWithOutOfBlockTracking(position) {
doComplete(correctedParameters, toFromOriginalFileMapper, result,
lookupElementPostProcessor = { wrapLookupElementForStringTemplateAfterDotCompletion(it) })
}
return
}
return
}
performCompletionWithOutOfBlockTracking(position) {
@@ -0,0 +1,3 @@
val v = "$x.1<caret>"
// NUMBER: 0
@@ -1578,6 +1578,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/inStringLiterals"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("EA76497.kt")
public void testEA76497() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/inStringLiterals/EA76497.kt");
doTest(fileName);
}
@TestMetadata("StringTemplate1.kt")
public void testStringTemplate1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/inStringLiterals/StringTemplate1.kt");
@@ -1578,6 +1578,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/inStringLiterals"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("EA76497.kt")
public void testEA76497() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/inStringLiterals/EA76497.kt");
doTest(fileName);
}
@TestMetadata("StringTemplate1.kt")
public void testStringTemplate1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/inStringLiterals/StringTemplate1.kt");