FIR: move JavaAnnotationMapper.javaToKotlinNameMap to common

so that FIR IDE logic can reference it
This commit is contained in:
Tianyu Geng
2021-10-27 15:21:49 -07:00
committed by Ilya Kirillov
parent 4a3a621196
commit 8ba2e4d221
3 changed files with 11 additions and 10 deletions
@@ -21,8 +21,8 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor
import org.jetbrains.kotlin.load.java.javaToKotlinNameMap
import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.resolve.BindingContext
@@ -47,7 +47,7 @@ class JavaAnnotationCallChecker : CallChecker {
private fun reportDeprecatedJavaAnnotation(resolvedCall: ResolvedCall<*>, context: CallCheckerContext) {
val annotationEntry = resolvedCall.call.callElement as? KtAnnotationEntry ?: return
val type = context.trace.get(BindingContext.TYPE, annotationEntry.typeReference) ?: return
JavaAnnotationMapper.javaToKotlinNameMap[type.constructor.declarationDescriptor?.let { DescriptorUtils.getFqNameSafe(it) }]?.let {
javaToKotlinNameMap[type.constructor.declarationDescriptor?.let { DescriptorUtils.getFqNameSafe(it) }]?.let {
context.trace.report(ErrorsJvm.DEPRECATED_JAVA_ANNOTATION.on(annotationEntry, it))
}
}
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.load.java
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.name.FqName
val JSPECIFY_NULLABLE = FqName("org.jspecify.nullness.Nullable")
@@ -83,3 +84,11 @@ val MUTABLE_ANNOTATIONS = setOf(
JvmAnnotationNames.JETBRAINS_MUTABLE_ANNOTATION,
JvmAnnotationNames.MUTABLE_ANNOTATION
)
val javaToKotlinNameMap: Map<FqName, FqName> =
mapOf(
JvmAnnotationNames.TARGET_ANNOTATION to StandardNames.FqNames.target,
JvmAnnotationNames.RETENTION_ANNOTATION to StandardNames.FqNames.retention,
JvmAnnotationNames.DEPRECATED_ANNOTATION to StandardNames.FqNames.deprecated,
JvmAnnotationNames.DOCUMENTED_ANNOTATION to StandardNames.FqNames.mustBeDocumented
)
@@ -80,14 +80,6 @@ object JavaAnnotationMapper {
StandardNames.FqNames.retention to RETENTION_ANNOTATION,
StandardNames.FqNames.mustBeDocumented to DOCUMENTED_ANNOTATION
)
val javaToKotlinNameMap: Map<FqName, FqName> =
mapOf(
TARGET_ANNOTATION to StandardNames.FqNames.target,
RETENTION_ANNOTATION to StandardNames.FqNames.retention,
DEPRECATED_ANNOTATION to StandardNames.FqNames.deprecated,
DOCUMENTED_ANNOTATION to StandardNames.FqNames.mustBeDocumented
)
}
open class JavaAnnotationDescriptor(