From 0caf8dc94722962e0d2719399eae3a6b75574f6f Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Fri, 22 May 2020 17:22:51 +0200 Subject: Light annotations fix --- .../ModuleAndPackageDocumentationTransformer.kt | 2 +- .../translators/psi/DefaultPsiToDocumentableTranslator.kt | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt index b1f50a32..1164fb77 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt @@ -74,7 +74,7 @@ internal class ModuleAndPackageDocumentationTransformer(val context: DokkaContex val facade = context.platforms[pd]?.facade ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.moduleName}/${pd.sourceSetName}") } val descriptor = facade.resolveSession.getPackageFragment(FqName(it.name)) - ?: return@mapNotNull null.also { context.logger.warn("Could not find descriptor for $") } + ?: return@mapNotNull null.also { _ -> context.logger.warn("Could not find descriptor for ${it.name}") } doc?.get("Package")?.get(it.name)?.run { pd to MarkdownParser( facade, diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 9c731528..efd689ba 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -17,6 +17,7 @@ import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator import org.jetbrains.dokka.utilities.DokkaLogger +import org.jetbrains.kotlin.asJava.elements.KtLightAbstractAnnotation import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot import org.jetbrains.kotlin.descriptors.Visibilities @@ -399,7 +400,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { ) } - private fun Collection.toListOfAnnotations() = mapNotNull { it.toAnnotation() } + private fun Collection.toListOfAnnotations() = filter { it !is KtLightAbstractAnnotation }.mapNotNull { it.toAnnotation() } private fun JvmAnnotationAttribute.toValue(): AnnotationParameterValue = when (this) { is PsiNameValuePair -> value?.toValue() ?: StringValue("") @@ -408,7 +409,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { private fun PsiAnnotationMemberValue.toValue(): AnnotationParameterValue = when(this) { is PsiAnnotation -> AnnotationValue(toAnnotation()) - is PsiArrayInitializerMemberValue -> ArrayValue(this.initializers.map { it.toValue() }) + is PsiArrayInitializerMemberValue -> ArrayValue(initializers.map { it.toValue() }) is PsiReferenceExpression -> EnumValue( text ?: "", driOfReference() @@ -422,11 +423,13 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { private fun PsiAnnotation.toAnnotation() = Annotations.Annotation( driOfReference(), - attributes.mapNotNull { it.attributeName to it.toValue() }.toMap() + attributes.filter { it !is KtLightAbstractAnnotation }.mapNotNull { it.attributeName to it.toValue() }.toMap() ) - private fun PsiElement.driOfReference() = DRI.from(getChildOfType()?.resolve() ?: - throw IllegalStateException("$this cannot be resolved to symbol!") - ) + private fun PsiElement.driOfReference() = getChildOfType()?.resolve()?.let { + DRI.from(it) + } ?: DRI("", getChildOfType()?.qualifiedName ?: "").also { + logger.error("$this cannot be resolved to symbol!") + } } } -- cgit