Fix @Language injection when using named parameters

Start using names of arguments if they are available when fetching
the @Language injection information.

Fixes KT-35859
This commit is contained in:
Aurimas Liutikas
2020-08-19 19:03:59 -07:00
committed by Nikolay Krasko
parent a9ddf02556
commit 777b16e0a3
2 changed files with 34 additions and 3 deletions
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.psi
import com.intellij.codeInsight.completion.CompletionType
import com.intellij.lang.html.HTMLLanguage
import com.intellij.lang.xml.XMLLanguage
import com.intellij.openapi.fileTypes.PlainTextLanguage
import org.intellij.lang.annotations.Language
import org.intellij.lang.regexp.RegExpLanguage
@@ -780,5 +781,26 @@ class KotlinInjectionTest : AbstractInjectionTest() {
languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false
)
fun testInjectionWithUsageInFunctionWithMarkedSecondNamedParameterWithAnnotation() = doInjectionPresentTest(
"""
import org.intellij.lang.annotations.Language
fun foo(@Language("XML") a: String = "", @Language("HTML") b: String = "") {}
fun other() { foo(b = "some<caret>") }
""",
languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false
)
fun testInjectionWithUsageInFunctionWithMarkedFirstNamedParameterWithAnnotation() = doInjectionPresentTest(
"""
import org.intellij.lang.annotations.Language
fun foo(@Language("XML") a: String = "", @Language("HTML") b: String = "") {}
fun other() { foo(a = "some<caret>") }
""",
languageId = XMLLanguage.INSTANCE.id, unInjectShouldBePresent = false
)
}