Skip to content

Commit

Permalink
Replace KtKClassAnnotationValue.classId with `KtKClassAnnotationVal…
Browse files Browse the repository at this point in the history
…ue.type.classId`

Since it is recommended to avoid using `KtKClassAnnotationValue.classId` for cases other than error handling. It will likely be removed in Analysis API.
  • Loading branch information
vmishenev committed May 13, 2024
1 parent d61f7c7 commit bfab90a
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.analysis.api.base.KtConstantValue
import org.jetbrains.kotlin.analysis.api.symbols.KtPropertySymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbolOrigin
import org.jetbrains.kotlin.analysis.api.types.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
Expand Down Expand Up @@ -105,16 +106,16 @@ internal class AnnotationTranslator {

is KtArrayAnnotationValue -> ArrayValue(annotationValue.values.map { toDokkaAnnotationValue(it) })
is KtAnnotationApplicationValue -> AnnotationValue(toDokkaAnnotation(annotationValue.annotationValue))
is KtKClassAnnotationValue -> annotationValue.classId?.let { classId ->
ClassValue(
classId.relativeClassName.asString(),
classId.createDRI()
is KtKClassAnnotationValue -> when (val type: KtType = annotationValue.type) {
is KtNonErrorClassType -> ClassValue(
type.classId.relativeClassName.asString(),
type.classId.createDRI()
)
} ?: ClassValue(
annotationValue.type.asStringForDebugging(),
DRI(packageName = "", classNames = ERROR_CLASS_NAME)
)

else -> ClassValue(
type.asStringForDebugging(),
DRI(packageName = "", classNames = ERROR_CLASS_NAME)
)
}
is KtUnsupportedAnnotationValue -> ClassValue(
"<Unsupported Annotation Value>",
DRI(packageName = "", classNames = ERROR_CLASS_NAME)
Expand Down

0 comments on commit bfab90a

Please sign in to comment.