mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] take prefix into account when injecting into multi-dollar strings
KTIJ-33031 GitOrigin-RevId: 3d5253791733df4c821c40a2659b03c591275f5b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fa98ce5640
commit
4327d7b425
+3
-2
@@ -73,7 +73,8 @@ abstract class KotlinLanguageInjectionPerformerBase : LanguageInjectionPerformer
|
||||
ContainerUtil.concat(listOfNotNull(child.left, child.right), tail), pendingPrefix, unparseable, collected)
|
||||
}
|
||||
child is KtStringTemplateExpression -> {
|
||||
if (child.children.isEmpty()) {
|
||||
val entries = child.entries
|
||||
if (entries.isEmpty()) {
|
||||
// empty range to save injection in the empty string
|
||||
collected += injectionRange(
|
||||
child,
|
||||
@@ -83,7 +84,7 @@ abstract class KotlinLanguageInjectionPerformerBase : LanguageInjectionPerformer
|
||||
)
|
||||
}
|
||||
return collectInjections(child,
|
||||
ContainerUtil.concat(child.children.toList(), tail), pendingPrefix, unparseable, collected)
|
||||
ContainerUtil.concat(entries.toList(), tail), pendingPrefix, unparseable, collected)
|
||||
}
|
||||
literal == null -> {
|
||||
val (prefix, myUnparseable) = makePlaceholder(child)
|
||||
|
||||
+27
@@ -8,6 +8,7 @@ import org.jetbrains.kotlin.idea.base.injection.KotlinInjectionTestBase
|
||||
import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode
|
||||
import org.jetbrains.kotlin.idea.fir.invalidateCaches
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.withCustomCompilerOptions
|
||||
|
||||
class K2KotlinInjectionTest: KotlinInjectionTestBase() {
|
||||
|
||||
@@ -41,4 +42,30 @@ class K2KotlinInjectionTest: KotlinInjectionTestBase() {
|
||||
|
||||
assertEquals("Wrong injection language", KotlinLanguage.INSTANCE, injectedFile?.language)
|
||||
}
|
||||
|
||||
fun testInjectionIntoMultiDollarString() {
|
||||
val file = myFixture.configureByText(
|
||||
"a.kt",
|
||||
"""
|
||||
// COMPILER_ARGUMENTS: -Xmulti-dollar-interpolation
|
||||
|
||||
import org.intellij.lang.annotations.Language
|
||||
|
||||
@Language("JSON")
|
||||
val json = $$$""${'"'}
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"title": "REST",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
""${'"'}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
withCustomCompilerOptions(file.text, project, module) {
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user