diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-05-22 17:22:51 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-05-26 11:32:03 +0200 |
commit | 0caf8dc94722962e0d2719399eae3a6b75574f6f (patch) | |
tree | 6298c06800350ddb8b9302a0f9a4c6e9969f9b4f /plugins | |
parent | 77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7 (diff) | |
download | dokka-0caf8dc94722962e0d2719399eae3a6b75574f6f.tar.gz dokka-0caf8dc94722962e0d2719399eae3a6b75574f6f.tar.bz2 dokka-0caf8dc94722962e0d2719399eae3a6b75574f6f.zip |
Light annotations fix
Diffstat (limited to 'plugins')
3 files changed, 11 insertions, 7 deletions
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<PsiAnnotation>.toListOfAnnotations() = mapNotNull { it.toAnnotation() } + private fun Collection<PsiAnnotation>.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<PsiJavaCodeReferenceElement>()?.resolve() ?: - throw IllegalStateException("$this cannot be resolved to symbol!") - ) + private fun PsiElement.driOfReference() = getChildOfType<PsiJavaCodeReferenceElement>()?.resolve()?.let { + DRI.from(it) + } ?: DRI("", getChildOfType<PsiJavaCodeReferenceElement>()?.qualifiedName ?: "").also { + logger.error("$this cannot be resolved to symbol!") + } } } diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index ec119ebb..4aba3e9d 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -137,6 +137,7 @@ fun ContentMatcherBuilder<*>.propertySignature( ) { group { header { +"Package test" } + skipAllNotMatching() } group { group { |