FIR IDE: test resolution of various annotation values

This commit is contained in:
Jinseong Jeon
2021-09-15 16:05:40 -07:00
committed by Ilya Kirillov
parent 150f066254
commit 744961bd00
18 changed files with 134 additions and 0 deletions
@@ -50,6 +50,11 @@ abstract class AbstractResolveCallTest : AbstractHLApiSingleModuleTest() {
is KtArrayAccessExpression -> element.resolveCall()
is KtSimpleNameExpression -> element.resolveAccessorCall()
is KtValueArgument -> resolveCall(element.getArgumentExpression()!!)
is KtDeclarationModifierList -> {
val annotationEntry = element.annotationEntries.singleOrNull()
?: error("Only single annotation entry is supported for now")
annotationEntry.resolveCall()
}
else -> error("Selected element type (${element::class.simpleName}) is not supported for resolveCall()")
}
@@ -24,6 +24,48 @@ public class ResolveCallTestGenerated extends AbstractResolveCallTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/analysisSession/resolveCall"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("annotationEntry.kt")
public void testAnnotationEntry() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/annotationEntry.kt");
}
@Test
@TestMetadata("annotationInAnnotation_arrayOf.kt")
public void testAnnotationInAnnotation_arrayOf() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/annotationInAnnotation_arrayOf.kt");
}
@Test
@TestMetadata("annotationInAnnotation_collectionLiteral.kt")
public void testAnnotationInAnnotation_collectionLiteral() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/annotationInAnnotation_collectionLiteral.kt");
}
@Test
@TestMetadata("annotationInAnnotation_multipleAnnotations_arrayOf.kt")
public void testAnnotationInAnnotation_multipleAnnotations_arrayOf() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/annotationInAnnotation_multipleAnnotations_arrayOf.kt");
}
@Test
@TestMetadata("annotationInAnnotation_multipleAnnotations_collectionLiteral.kt")
public void testAnnotationInAnnotation_multipleAnnotations_collectionLiteral() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/annotationInAnnotation_multipleAnnotations_collectionLiteral.kt");
}
@Test
@TestMetadata("annotationInAnnotation_noarg.kt")
public void testAnnotationInAnnotation_noarg() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/annotationInAnnotation_noarg.kt");
}
@Test
@TestMetadata("annotationInAnnotation_vararg.kt")
public void testAnnotationInAnnotation_vararg() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/annotationInAnnotation_vararg.kt");
}
@Test
@TestMetadata("arrayOfInAnnotation.kt")
public void testArrayOfInAnnotation() throws Exception {
@@ -54,6 +96,12 @@ public class ResolveCallTestGenerated extends AbstractResolveCallTest {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/delegatedConstructorCall_this_unresolved.kt");
}
@Test
@TestMetadata("enumAsAnnotationValue.kt")
public void testEnumAsAnnotationValue() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/enumAsAnnotationValue.kt");
}
@Test
@TestMetadata("functionCallInTheSameFile.kt")
public void testFunctionCallInTheSameFile() throws Exception {
@@ -0,0 +1,6 @@
annotation class Annotation(vararg val strings: String)
annotation class AnnotationInner(val value: Annotation)
<expr>@AnnotationInner(Annotation("v1", "v2"))</expr>
class C
@@ -0,0 +1,3 @@
KtAnnotationCall:
argumentMapping = { Annotation("v1", "v2") -> (value: Annotation) }
targetFunction = <constructor>(value: Annotation): AnnotationInner
@@ -0,0 +1,6 @@
annotation class Annotation(vararg val strings: String)
annotation class AnnotationInner(val value: Annotation)
@AnnotationInner(<expr>Annotation(strings = arrayOf("v1", "v2"))</expr>)
class C
@@ -0,0 +1,4 @@
KtFunctionCall:
argumentMapping = { arrayOf("v1", "v2") -> (vararg strings: kotlin.String) }
targetFunction = <constructor>(vararg strings: kotlin.String): Annotation
substitutor = <empty substitutor>
@@ -0,0 +1,6 @@
annotation class Annotation(vararg val strings: String)
annotation class AnnotationInner(val value: Annotation)
@AnnotationInner(<expr>Annotation(["v1", "v2"])</expr>)
class C
@@ -0,0 +1,4 @@
KtFunctionCall:
argumentMapping = { ["v1", "v2"] -> (vararg strings: kotlin.String) }
targetFunction = <constructor>(vararg strings: kotlin.String): Annotation
substitutor = <empty substitutor>
@@ -0,0 +1,6 @@
annotation class Annotation(vararg val strings: String)
annotation class AnnotationArray(vararg val annos: Annotation)
@AnnotationArray(<expr>annos = arrayOf(Annotation("v1", "v2"), Annotation(strings = arrayOf("v3", "v4")))</expr>)
class C
@@ -0,0 +1,4 @@
KtFunctionCall:
argumentMapping = { Annotation("v1", "v2") -> (vararg elements: Annotation), Annotation(strings = arrayOf("v3", "v4")) -> (vararg elements: Annotation) }
targetFunction = kotlin/arrayOf(vararg elements: Annotation): kotlin.Array<Annotation>
substitutor = <map substitutor: {FirTypeParameterSymbol T=Annotation}>
@@ -0,0 +1,6 @@
annotation class Annotation(vararg val strings: String)
annotation class AnnotationArray(vararg val annos: Annotation)
<expr>@AnnotationArray([Annotation("v1", "v2"), Annotation(["v3", "v4"])])</expr>
class C
@@ -0,0 +1,3 @@
KtAnnotationCall:
argumentMapping = { [Annotation("v1", "v2"), Annotation(["v3", "v4"])] -> (vararg annos: Annotation) }
targetFunction = <constructor>(vararg annos: Annotation): AnnotationArray
@@ -0,0 +1,6 @@
annotation class Annotation(vararg val strings: String)
annotation class AnnotationInner(val value: Annotation)
@AnnotationInner(<expr>Annotation()</expr>)
class C
@@ -0,0 +1,4 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = <constructor>(vararg strings: kotlin.String): Annotation
substitutor = <empty substitutor>
@@ -0,0 +1,6 @@
annotation class Annotation(vararg val strings: String)
annotation class AnnotationInner(val value: Annotation)
@AnnotationInner(<expr>Annotation("v1", "v2")</expr>)
class C
@@ -0,0 +1,4 @@
KtFunctionCall:
argumentMapping = { "v1" -> (vararg strings: kotlin.String), "v2" -> (vararg strings: kotlin.String) }
targetFunction = <constructor>(vararg strings: kotlin.String): Annotation
substitutor = <empty substitutor>
@@ -0,0 +1,10 @@
enum class Color {
R,
G,
B
}
annotation class Annotation(val color : Color)
<expr>@Annotation(Color.R)</expr>
class C
@@ -0,0 +1,3 @@
KtAnnotationCall:
argumentMapping = { Color.R -> (color: Color) }
targetFunction = <constructor>(color: Color): Annotation