diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/injection/InterpolatedStringInjectorProcessor.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/injection/InterpolatedStringInjectorProcessor.kt index 5a6bd5ff92f..906bdddd821 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/injection/InterpolatedStringInjectorProcessor.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/injection/InterpolatedStringInjectorProcessor.kt @@ -83,7 +83,7 @@ fun splitLiteralToInjectionParts(injection: BaseInjection, literal: KtStringTemp } } - val suffix = if (child == lastChild) injection.suffix else "" + val suffix = if (i == len - 1) injection.suffix else "" if (part is PsiElement) { addInjectionRange(TextRange.create(partOffsetInParent, part.startOffsetInParent + part.textLength), prefix, suffix) diff --git a/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt index 3b9b6124593..bb95125e14b 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt @@ -443,6 +443,21 @@ class KotlinInjectionTest : AbstractInjectionTest() { shreds = listOf(ShredInfo(range(0, 9), hostRange=range(1, 4), prefix = "abc", suffix = "ghi")) ) + fun testSuffixAfterInterpolationInMultiline() = doInjectionPresentTest( + """ + //language=TEXT suffix="check" + val some = 1 + val text = ""${'"'} + ${'$'}{some} + ""${'"'} // Position is important! Shouldn't be start of the line. + """, + languageId = PlainTextLanguage.INSTANCE.id, unInjectShouldBePresent = false, + shreds = listOf( + ShredInfo(range(0, 3), hostRange = range(3,6), prefix = "", suffix = ""), + ShredInfo(range(3, 23), hostRange = range(13,16), prefix= "missingValue", suffix = "check") + ) + ) + fun testJavaAnnotationsPattern() { myFixture.addClass(""" @interface Matches { String value(); }