[AA LC] Properly compute retention for @java.lang.annotation.Retention
This commit is contained in:
+8
-3
@@ -146,7 +146,12 @@ internal fun KtAnnotatedSymbol.computeAnnotations(
|
||||
if (parentIsAnnotation &&
|
||||
annotations.none { it.classId?.asFqNameString() == JAVA_LANG_ANNOTATION_RETENTION }
|
||||
) {
|
||||
result.add(createRetentionRuntimeAnnotation(parent))
|
||||
val argumentWithKotlinRetention = annotations.firstOrNull { it.classId == StandardClassIds.Annotations.Retention }
|
||||
?.arguments
|
||||
?.firstOrNull { it.name.asString() == "value" }
|
||||
?.expression
|
||||
val kotlinRetentionName = (argumentWithKotlinRetention as? KtEnumEntryAnnotationValue)?.callableId?.callableName?.asString()
|
||||
result.add(createRetentionRuntimeAnnotation(parent, kotlinRetentionName))
|
||||
}
|
||||
|
||||
if (nullabilityAnnotation != null) {
|
||||
@@ -156,7 +161,7 @@ internal fun KtAnnotatedSymbol.computeAnnotations(
|
||||
return result
|
||||
}
|
||||
|
||||
private fun createRetentionRuntimeAnnotation(parent: PsiElement): PsiAnnotation =
|
||||
private fun createRetentionRuntimeAnnotation(parent: PsiElement, retentionName: String? = null): PsiAnnotation =
|
||||
SymbolLightSimpleAnnotation(
|
||||
JAVA_LANG_ANNOTATION_RETENTION,
|
||||
parent,
|
||||
@@ -166,7 +171,7 @@ private fun createRetentionRuntimeAnnotation(parent: PsiElement): PsiAnnotation
|
||||
expression = KtEnumEntryAnnotationValue(
|
||||
callableId = CallableId(
|
||||
ClassId.fromString(RETENTION_POLICY_ENUM.asString()),
|
||||
Name.identifier(AnnotationRetention.RUNTIME.name)
|
||||
Name.identifier(retentionName ?: AnnotationRetention.RUNTIME.name)
|
||||
),
|
||||
sourcePsi = null
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.SOURCE)
|
||||
@kotlin.annotation.MustBeDocumented()
|
||||
@kotlin.annotation.Repeatable()
|
||||
@kotlin.annotation.Retention(value = kotlin.annotation.AnnotationRetention.SOURCE)
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract @interface Anno /* Anno*/ {
|
||||
}
|
||||
|
||||
@Deprecated(message = "This anno is deprecated, use === instead", replaceWith = @ReplaceWith(expression = "this === other"))
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.SOURCE)
|
||||
@kotlin.annotation.MustBeDocumented()
|
||||
@kotlin.annotation.Retention(value = kotlin.annotation.AnnotationRetention.SOURCE)
|
||||
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.CLASS, kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.EXPRESSION})
|
||||
|
||||
Reference in New Issue
Block a user