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:
+1
-1
@@ -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) {
|
if (part is PsiElement) {
|
||||||
addInjectionRange(TextRange.create(partOffsetInParent, part.startOffsetInParent + part.textLength), prefix, suffix)
|
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"))
|
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() {
|
fun testJavaAnnotationsPattern() {
|
||||||
myFixture.addClass("""
|
myFixture.addClass("""
|
||||||
@interface Matches { String value(); }
|
@interface Matches { String value(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user