Mark freshly supported annotations to use that mark for reporting corresponding warnings

This commit is contained in:
Victor Petukhov
2020-12-11 17:29:12 +03:00
parent 9693ea19fb
commit d6017420de
5 changed files with 21 additions and 9 deletions
@@ -45,14 +45,18 @@ object JavaAnnotationMapper {
internal val TARGET_ANNOTATION_ALLOWED_TARGETS = Name.identifier("allowedTargets")
internal val RETENTION_ANNOTATION_VALUE = Name.identifier("value")
fun mapOrResolveJavaAnnotation(annotation: JavaAnnotation, c: LazyJavaResolverContext): AnnotationDescriptor? =
fun mapOrResolveJavaAnnotation(
annotation: JavaAnnotation,
c: LazyJavaResolverContext,
isFreshlySupportedAnnotation: Boolean = false
): AnnotationDescriptor? =
when (annotation.classId) {
ClassId.topLevel(TARGET_ANNOTATION) -> JavaTargetAnnotationDescriptor(annotation, c)
ClassId.topLevel(RETENTION_ANNOTATION) -> JavaRetentionAnnotationDescriptor(annotation, c)
ClassId.topLevel(REPEATABLE_ANNOTATION) -> JavaAnnotationDescriptor(c, annotation, StandardNames.FqNames.repeatable)
ClassId.topLevel(DOCUMENTED_ANNOTATION) -> JavaAnnotationDescriptor(c, annotation, StandardNames.FqNames.mustBeDocumented)
ClassId.topLevel(DEPRECATED_ANNOTATION) -> null
else -> LazyJavaAnnotationDescriptor(c, annotation)
else -> LazyJavaAnnotationDescriptor(c, annotation, isFreshlySupportedAnnotation)
}
fun findMappedJavaAnnotation(
@@ -39,7 +39,8 @@ import org.jetbrains.kotlin.types.isError
class LazyJavaAnnotationDescriptor(
private val c: LazyJavaResolverContext,
private val javaAnnotation: JavaAnnotation
private val javaAnnotation: JavaAnnotation,
isFreshlySupportedAnnotation: Boolean = false
) : AnnotationDescriptor, PossiblyExternalAnnotationDescriptor {
override val fqName by c.storageManager.createNullableLazyValue {
javaAnnotation.classId?.asSingleFqName()
@@ -115,4 +116,6 @@ class LazyJavaAnnotationDescriptor(
)
override val isIdeExternalAnnotation: Boolean = javaAnnotation.isIdeExternalAnnotation
val isFreshlySupportedTypeUseAnnotation: Boolean = javaAnnotation.isFreshlySupportedTypeUseAnnotation || isFreshlySupportedAnnotation
}