KtLightAnnotation: handling vararg with single arg (EA-114679)

It is deprecated but yet possible form of usage
This commit is contained in:
Nicolay Mitropolsky
2018-01-10 20:38:10 +03:00
parent 6197c5bf7f
commit 9cb62d66cb
2 changed files with 31 additions and 5 deletions
@@ -339,6 +339,27 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() {
}
}
fun testVarargWithSingleArg() {
myFixture.addClass("""
public @interface Annotation {
String[] value();
}
""".trimIndent())
myFixture.configureByText("AnnotatedClass.kt", """
@Annotation(value = "a")
open class AnnotatedClass
""".trimIndent())
myFixture.testHighlighting("Annotation.java", "AnnotatedClass.kt")
val annotations = myFixture.findClass("AnnotatedClass").expectAnnotations(1)
val annotationAttributeVal = annotations.first().findAttributeValue("value") as PsiArrayInitializerMemberValue
assertTextAndRange("\"a\"", annotationAttributeVal)
for ((i, arg) in listOf("\"a\"").withIndex()) {
assertTextAndRange(arg, annotationAttributeVal.initializers[i])
}
}
fun testVarargWithArrayLiteralAndSpread() {
myFixture.addClass("""
public @interface Annotation {