diff options
author | owengray-google <owengray@google.com> | 2022-04-08 11:53:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 18:53:52 +0300 |
commit | 13746f4afacd72576515dd94ba1167546418421f (patch) | |
tree | b6fbb6b0fae435c3940a4d06bba8822f76a7e5bb /plugins/base/src/main/kotlin | |
parent | c81b39f966ce15f38afc8bea60f800fed9ea2473 (diff) | |
download | dokka-13746f4afacd72576515dd94ba1167546418421f.tar.gz dokka-13746f4afacd72576515dd94ba1167546418421f.tar.bz2 dokka-13746f4afacd72576515dd94ba1167546418421f.zip |
Rework AnnotationTarget to be stricter (#2414)
Diffstat (limited to 'plugins/base/src/main/kotlin')
2 files changed, 14 insertions, 10 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 259f374a..6bc8774d 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -13,8 +13,9 @@ import org.jetbrains.dokka.analysis.KotlinAnalysis import org.jetbrains.dokka.analysis.from import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.parsers.MarkdownParser -import org.jetbrains.dokka.base.translators.typeConstructorsBeingExceptions import org.jetbrains.dokka.base.translators.psi.parsers.JavadocParser +import org.jetbrains.dokka.base.translators.psi.DefaultPsiToDocumentableTranslator +import org.jetbrains.dokka.base.translators.typeConstructorsBeingExceptions import org.jetbrains.dokka.base.translators.unquotedValue import org.jetbrains.dokka.links.* import org.jetbrains.dokka.links.Callable @@ -31,7 +32,6 @@ import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.dokka.utilities.parallelMap import org.jetbrains.dokka.utilities.parallelMapNotNull import org.jetbrains.kotlin.KtNodeTypes -import org.jetbrains.dokka.model.BooleanConstant import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.builtins.isBuiltinExtensionFunctionalType import org.jetbrains.kotlin.builtins.isExtensionFunctionType @@ -68,16 +68,16 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs import java.nio.file.Paths import org.jetbrains.kotlin.resolve.constants.AnnotationValue as ConstantsAnnotationValue import org.jetbrains.kotlin.resolve.constants.ArrayValue as ConstantsArrayValue -import org.jetbrains.kotlin.resolve.constants.EnumValue as ConstantsEnumValue -import org.jetbrains.kotlin.resolve.constants.KClassValue as ConstantsKtClassValue +import org.jetbrains.kotlin.resolve.constants.BooleanValue as ConstantsBooleanValue import org.jetbrains.kotlin.resolve.constants.DoubleValue as ConstantsDoubleValue +import org.jetbrains.kotlin.resolve.constants.EnumValue as ConstantsEnumValue import org.jetbrains.kotlin.resolve.constants.FloatValue as ConstantsFloatValue import org.jetbrains.kotlin.resolve.constants.IntValue as ConstantsIntValue +import org.jetbrains.kotlin.resolve.constants.KClassValue as ConstantsKtClassValue import org.jetbrains.kotlin.resolve.constants.LongValue as ConstantsLongValue +import org.jetbrains.kotlin.resolve.constants.NullValue as ConstantsNullValue import org.jetbrains.kotlin.resolve.constants.UIntValue as ConstantsUIntValue import org.jetbrains.kotlin.resolve.constants.ULongValue as ConstantsULongValue -import org.jetbrains.kotlin.resolve.constants.BooleanValue as ConstantsBooleanValue -import org.jetbrains.kotlin.resolve.constants.NullValue as ConstantsNullValue class DefaultDescriptorToDocumentableTranslator( private val context: DokkaContext @@ -773,7 +773,9 @@ private class DokkaDescriptorVisitor( private suspend fun toTypeConstructor(kt: KotlinType) = GenericTypeConstructor( DRI.from(kt.constructor.declarationDescriptor as DeclarationDescriptor), - kt.arguments.map { it.toProjection() }) + kt.arguments.map { it.toProjection() }, + extra = PropertyContainer.withAll(kt.getAnnotations().toSourceSetDependent().toAnnotations()) + ) private suspend fun buildAncestryInformation( kotlinType: KotlinType @@ -834,7 +836,8 @@ private class DokkaDescriptorVisitor( is DynamicType -> Dynamic is AbbreviatedType -> TypeAliased( abbreviation.toBound(), - expandedType.toBound() + expandedType.toBound(), + annotations() ) else -> when (val ctor = constructor.declarationDescriptor) { is TypeParameterDescriptor -> TypeParameter( diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 4b2d7720..f9199154 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -472,13 +472,14 @@ class DefaultPsiToDocumentableTranslator( extra = type.annotations() ) } - } ?: UnresolvedBound(type.presentableText) + } ?: UnresolvedBound(type.presentableText, type.annotations()) is PsiArrayType -> GenericTypeConstructor( DRI("kotlin", "Array"), listOf(getProjection(type.componentType)), extra = type.annotations() ) - is PsiPrimitiveType -> if (type.name == "void") Void else PrimitiveJavaType(type.name) + is PsiPrimitiveType -> if (type.name == "void") Void + else PrimitiveJavaType(type.name, type.annotations()) is PsiImmediateClassType -> JavaObject(type.annotations()) else -> throw IllegalStateException("${type.presentableText} is not supported by PSI parser") } |