Skip to content

Commit

Permalink
Update Analysis API to 2.0.20-dev-3206 (#3602)
Browse files Browse the repository at this point in the history
* Update Analysis API to 2.0.20-dev-3206

* Refactor translating a class annotation value

After https://youtrack.jetbrains.com/issue/KT-61775/

* Replace `KtKClassAnnotationValue.classId` with `KtKClassAnnotationValue.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 14, 2024
1 parent 2a1f2b8 commit b5d74f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 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,18 106,17 @@ internal class AnnotationTranslator {

is KtArrayAnnotationValue -> ArrayValue(annotationValue.values.map { toDokkaAnnotationValue(it) })
is KtAnnotationApplicationValue -> AnnotationValue(toDokkaAnnotation(annotationValue.annotationValue))
is KtKClassAnnotationValue.KtNonLocalKClassAnnotationValue -> ClassValue(
annotationValue.classId.relativeClassName.asString(),
annotationValue.classId.createDRI()
)

is KtKClassAnnotationValue.KtLocalKClassAnnotationValue -> throw IllegalStateException("Unexpected a local class in annotation")
is KtKClassAnnotationValue.KtErrorClassAnnotationValue -> ClassValue(
annotationValue.unresolvedQualifierName ?: "",
DRI(packageName = "", classNames = ERROR_CLASS_NAME)
)

KtUnsupportedAnnotationValue -> ClassValue(
is KtKClassAnnotationValue -> when (val type: KtType = annotationValue.type) {
is KtNonErrorClassType -> ClassValue(
type.classId.relativeClassName.asString(),
type.classId.createDRI()
)
else -> ClassValue(
type.asStringForDebugging(),
DRI(packageName = "", classNames = ERROR_CLASS_NAME)
)
}
is KtUnsupportedAnnotationValue -> ClassValue(
"<Unsupported Annotation Value>",
DRI(packageName = "", classNames = ERROR_CLASS_NAME)
)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,7 @@ kotlinx-bcv = "0.13.2"

## Analysis
kotlin-compiler = "2.0.0-RC3"
kotlin-compiler-k2 = "2.0.20-dev-7"
kotlin-compiler-k2 = "2.0.20-dev-3206"

# MUST match the version of the intellij platform used in the kotlin compiler,
# otherwise this will lead to different versions of psi API and implementations
Expand Down

0 comments on commit b5d74f7

Please sign in to comment.