Fix losing suffix in multiline literals with interpolation (KT-29013)

Element was looped in internal loop, but this was missing in add suffix
check.
This commit is contained in:
Nikolay Krasko
2018-12-26 12:46:57 +03:00
parent 6d8439e9fb
commit b232386d9d
2 changed files with 16 additions and 1 deletions
@@ -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)
@@ -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 = ""${'"'}
<caret>${'$'}{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(); }