Mark freshly supported annotations to use that mark for reporting corresponding warnings
This commit is contained in:
+5
@@ -94,4 +94,9 @@ public class JavaAnnotationImpl extends JavaElementImpl<PsiAnnotation> implement
|
||||
ExternalAnnotationsManager externalAnnotationManager = ExternalAnnotationsManager.getInstance(psi.getProject());
|
||||
return externalAnnotationManager.isExternalAnnotation(psi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFreshlySupportedTypeUseAnnotation() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -96,13 +96,13 @@ class BinaryJavaClass(
|
||||
val baseType: JavaType = if (typeReference.superTypeIndex == -1) superclass!! else interfaces[typeReference.superTypeIndex]
|
||||
val targetType = BinaryJavaAnnotation.computeTargetType(baseType, translatedPath)
|
||||
|
||||
return BinaryJavaAnnotation.addAnnotation(targetType as JavaPlainType, descriptor, context, signatureParser)
|
||||
return BinaryJavaAnnotation.addAnnotation(targetType as JavaPlainType, descriptor, context, signatureParser, true)
|
||||
}
|
||||
TypeReference.CLASS_TYPE_PARAMETER_BOUND -> {
|
||||
val baseType = computeTypeParameterBound(typeParameters, typeReference)
|
||||
val targetType = BinaryJavaAnnotation.computeTargetType(baseType, translatedPath)
|
||||
|
||||
return BinaryJavaAnnotation.addAnnotation(targetType as JavaPlainType, descriptor, context, signatureParser)
|
||||
return BinaryJavaAnnotation.addAnnotation(targetType as JavaPlainType, descriptor, context, signatureParser, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,11 +110,11 @@ class BinaryJavaClass(
|
||||
return when (typeReference.sort) {
|
||||
TypeReference.CLASS_TYPE_PARAMETER ->
|
||||
BinaryJavaAnnotation.addAnnotation(
|
||||
typeParameters[typeReference.typeParameterIndex] as BinaryJavaTypeParameter, descriptor, context, signatureParser
|
||||
typeParameters[typeReference.typeParameterIndex] as BinaryJavaTypeParameter, descriptor, context, signatureParser, true
|
||||
)
|
||||
TypeReference.CLASS_TYPE_PARAMETER_BOUND ->
|
||||
BinaryJavaAnnotation.addAnnotation(
|
||||
computeTypeParameterBound(typeParameters, typeReference) as JavaPlainType, descriptor, context, signatureParser
|
||||
computeTypeParameterBound(typeParameters, typeReference) as JavaPlainType, descriptor, context, signatureParser, true
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@ interface JavaTypeParameterListOwner : JavaElement {
|
||||
interface JavaAnnotation : JavaElement {
|
||||
val arguments: Collection<JavaAnnotationArgument>
|
||||
val classId: ClassId?
|
||||
val isIdeExternalAnnotation: Boolean
|
||||
get() = false
|
||||
val isIdeExternalAnnotation: Boolean get() = false
|
||||
val isFreshlySupportedTypeUseAnnotation: Boolean get() = false
|
||||
|
||||
fun resolve(): JavaClass?
|
||||
}
|
||||
|
||||
+6
-2
@@ -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(
|
||||
|
||||
+4
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user