Fix KtLightClass conversion and testParameterPropertyWithAnnotation
This commit is contained in:
committed by
Dmitry Jemerov
parent
fe021afa37
commit
b12f24b41c
@@ -138,12 +138,12 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin {
|
|||||||
return with(requiredType) {
|
return with(requiredType) {
|
||||||
when (original) {
|
when (original) {
|
||||||
is KtLightMethod -> el<UMethod>(build(KotlinUMethod.Companion::create)) // .Companion is needed because of KT-13934
|
is KtLightMethod -> el<UMethod>(build(KotlinUMethod.Companion::create)) // .Companion is needed because of KT-13934
|
||||||
is KtLightClass -> el<UDeclaration> {
|
is KtLightClass -> when (original.kotlinOrigin) {
|
||||||
(original.kotlinOrigin as? KtEnumEntry)?.let { enumEntry ->
|
is KtEnumEntry -> el<UEnumConstant> {
|
||||||
convertEnumEntry(enumEntry, givenParent)
|
convertEnumEntry(original.kotlinOrigin as KtEnumEntry, givenParent)
|
||||||
} ?: KotlinUClass.create(original, givenParent)
|
}
|
||||||
|
else -> el<UClass> { KotlinUClass.create(original, givenParent) }
|
||||||
}
|
}
|
||||||
|
|
||||||
is KtLightFieldImpl.KtLightEnumConstant -> el<UEnumConstant>(build(::KotlinUEnumConstant))
|
is KtLightFieldImpl.KtLightEnumConstant -> el<UEnumConstant>(build(::KotlinUEnumConstant))
|
||||||
is KtLightField -> el<UField>(build(::KotlinUField))
|
is KtLightField -> el<UField>(build(::KotlinUField))
|
||||||
is KtLightParameter, is UastKotlinPsiParameter -> el<UParameter>(build(::KotlinUParameter))
|
is KtLightParameter, is UastKotlinPsiParameter -> el<UParameter>(build(::KotlinUParameter))
|
||||||
|
|||||||
@@ -88,16 +88,16 @@ class KotlinUastApiTest : AbstractKotlinUastTest() {
|
|||||||
|
|
||||||
val test2 = file.classes.find { it.name == "Test2" }!!
|
val test2 = file.classes.find { it.name == "Test2" }!!
|
||||||
val constructor2 = test2.methods.find { it.name == "Test2" }!!
|
val constructor2 = test2.methods.find { it.name == "Test2" }!!
|
||||||
assertFalse(constructor2.uastParameters.first().annotations.any { it.qualifiedName == "MyAnnotation" })
|
assertFalse(constructor2.uastParameters.first().annotations.any { it.qualifiedName?.startsWith("MyAnnotation") ?: false })
|
||||||
|
|
||||||
val getter2 = test2.methods.find { it.name == "getBar" }!!
|
val getter2 = test2.methods.find { it.name == "getBar" }!!
|
||||||
getter2.annotations.single { it.qualifiedName == "MyAnnotation" }
|
getter2.annotations.single { it.qualifiedName == "MyAnnotation" }
|
||||||
|
|
||||||
val setter2 = test2.methods.find { it.name == "setBar" }!!
|
val setter2 = test2.methods.find { it.name == "setBar" }!!
|
||||||
setter2.annotations.single { it.qualifiedName == "MyAnnotation" }
|
setter2.annotations.single { it.qualifiedName == "MyAnnotation2" }
|
||||||
setter2.uastParameters.first().annotations.single { it.qualifiedName == "MyAnnotation" }
|
setter2.uastParameters.first().annotations.single { it.qualifiedName == "MyAnnotation3" }
|
||||||
|
|
||||||
test2.fields.find { it.name == "bar" }!!.annotations.single { it.qualifiedName == "MyAnnotation" }
|
test2.fields.find { it.name == "bar" }!!.annotations.single { it.qualifiedName == "MyAnnotation5" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user