[ULC] Fix rendering for Foo.class in annotation value
Previously it was Foo::class, but it isn't correct because in java it is Foo.class P.s. Array<Foo> cannot be passed as annotation parameter
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
@java.lang.annotation.Repeatable(value = TwoContainer::class)
|
||||
@java.lang.annotation.Repeatable(value = TwoContainer.class)
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface Two /* Two*/ {
|
||||
public abstract java.lang.String name();// name()
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@java.lang.annotation.Repeatable(value = TwoContainer::class)
|
||||
@java.lang.annotation.Repeatable(value = TwoContainer.class)
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
@kotlin.annotation.Repeatable()
|
||||
public abstract @interface Two /* Two*/ {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@java.lang.annotation.Repeatable(value = TwoContainer::class)
|
||||
@java.lang.annotation.Repeatable(value = TwoContainer.class)
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
@kotlin.annotation.Repeatable()
|
||||
public abstract @interface Two /* Two*/ {
|
||||
|
||||
@@ -21,8 +21,8 @@ public abstract @interface Ann /* Ann*/ {
|
||||
}
|
||||
|
||||
public abstract interface Base /* Base*/ {
|
||||
@Ann(x = 1, y = "134", z = String::class, e = {Int::class, Double::class}, depr = kotlin.DeprecationLevel.WARNING, t = {@SimpleAnn(value = "243"), @SimpleAnn(value = "4324")})
|
||||
public abstract void foo(@Ann(x = 2, y = "324", z = Ann::class, e = {Byte::class, Base::class}, depr = kotlin.DeprecationLevel.WARNING, t = {@SimpleAnn(value = "687"), @SimpleAnn(value = "78")}) @org.jetbrains.annotations.NotNull() java.lang.String);// foo(java.lang.String)
|
||||
@Ann(x = 1, y = "134", z = kotlin.String.class, e = {kotlin.Int.class, kotlin.Double.class}, depr = kotlin.DeprecationLevel.WARNING, t = {@SimpleAnn(value = "243"), @SimpleAnn(value = "4324")})
|
||||
public abstract void foo(@Ann(x = 2, y = "324", z = Ann.class, e = {kotlin.Byte.class, Base.class}, depr = kotlin.DeprecationLevel.WARNING, t = {@SimpleAnn(value = "687"), @SimpleAnn(value = "78")}) @org.jetbrains.annotations.NotNull() java.lang.String);// foo(java.lang.String)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.asJava.elements.KtLightPsiLiteral
|
||||
import org.jetbrains.kotlin.load.kotlin.NON_EXISTENT_CLASS_NAME
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.constants.KClassValue
|
||||
|
||||
fun PsiClass.renderClass() = PsiClassRenderer.renderClass(this)
|
||||
|
||||
@@ -146,12 +147,19 @@ class PsiClassRenderer private constructor(
|
||||
it.name!! + bounds
|
||||
} + "> "
|
||||
|
||||
private fun KtLightPsiLiteral.renderKtLightPsiLiteral(): String =
|
||||
(value as? Pair<*, *>)?.let {
|
||||
val classId = it.first as? ClassId
|
||||
val name = it.second as? Name
|
||||
if (classId != null && name != null) "${classId.asSingleFqName()}.${name.asString()}" else null
|
||||
} ?: text
|
||||
private fun KtLightPsiLiteral.renderKtLightPsiLiteral(): String {
|
||||
val value = value
|
||||
if (value is Pair<*, *>) {
|
||||
val classId = value.first as? ClassId
|
||||
val name = value.second as? Name
|
||||
if (classId != null && name != null)
|
||||
return "${classId.asSingleFqName()}.${name.asString()}"
|
||||
}
|
||||
if (value is KClassValue.Value.NormalClass && value.arrayDimensions == 0) {
|
||||
return "${value.classId.asSingleFqName()}.class"
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
private fun PsiAnnotationMemberValue.renderAnnotationMemberValue(): String = when (this) {
|
||||
is KtLightPsiArrayInitializerMemberValue -> "{${initializers.joinToString { it.renderAnnotationMemberValue() }}}"
|
||||
|
||||
Reference in New Issue
Block a user