diff options
author | Goooler <wangzongler@gmail.com> | 2022-02-21 22:01:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 17:01:06 +0300 |
commit | f5b7797255576e5f1c230e2ca3fcb5f4e602387c (patch) | |
tree | 25fd98250066c4ed6c2fff1104be533604bbf1b9 /plugins/base/src | |
parent | df4780c31026aaa626746f49f0e6fa3fa0278a05 (diff) | |
download | dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.gz dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.bz2 dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.zip |
Code cleanups (#2165)
Diffstat (limited to 'plugins/base/src')
34 files changed, 76 insertions, 82 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt index 9122d8ee..f36071ff 100644 --- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt +++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/ModuleAndPackageDocumentationParsingContext.kt @@ -5,9 +5,9 @@ package org.jetbrains.dokka.base.parsers.moduleAndPackage import org.jetbrains.dokka.analysis.DokkaResolutionFacade import org.jetbrains.dokka.analysis.from import org.jetbrains.dokka.base.parsers.MarkdownParser -import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.* +import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.Module +import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.Package import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.doc.Description import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.kotlin.descriptors.ClassDescriptor diff --git a/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt b/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt index 3b849fec..056e0f93 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt @@ -3,7 +3,6 @@ package org.jetbrains.dokka.base.renderers import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode import org.jetbrains.dokka.pages.Kind -import org.jetbrains.dokka.utilities.DokkaLogger private val kindsOrder = listOf( ContentKind.Classlikes, diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 2d8f88a6..4dd020ce 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -29,11 +29,11 @@ open class HtmlRenderer( private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(context) private val sourceSetDependencyMap: Map<DokkaSourceSetID, List<DokkaSourceSetID>> = - context.configuration.sourceSets.map { sourceSet -> + context.configuration.sourceSets.associate { sourceSet -> sourceSet.sourceSetID to context.configuration.sourceSets .map { it.sourceSetID } .filter { it in sourceSet.dependentSourceSets } - }.toMap() + } private var shouldRenderSourceSetBubbles: Boolean = false @@ -180,7 +180,7 @@ open class HtmlRenderer( buildPlatformDependent( content.sourceSets.filter { sourceSetRestriction == null || it in sourceSetRestriction - }.map { it to setOf(content.inner) }.toMap(), + }.associateWith { setOf(content.inner) }, pageContext, content.extra, content.style diff --git a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt index d8595863..dba6cced 100644 --- a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt +++ b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt @@ -18,7 +18,7 @@ data class SearchRecord( val location: String, val searchKeys: List<String> = listOf(name) ) { - companion object {} + companion object } open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer { diff --git a/plugins/base/src/main/kotlin/renderers/html/Tags.kt b/plugins/base/src/main/kotlin/renderers/html/Tags.kt index f79d1633..a23c7bf1 100644 --- a/plugins/base/src/main/kotlin/renderers/html/Tags.kt +++ b/plugins/base/src/main/kotlin/renderers/html/Tags.kt @@ -23,9 +23,8 @@ open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) @HtmlTagMarker inline fun FlowOrPhrasingContent.strike(classes : String? = null, crossinline block : STRIKE.() -> Unit = {}) : Unit = STRIKE(attributesMapOf("class", classes), consumer).visit(block) -open class STRIKE(initialAttributes : Map<String, String>, override val consumer : TagConsumer<*>) : HTMLTag("strike", consumer, initialAttributes, null, false, false), HtmlBlockInlineTag { - -} +open class STRIKE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) : + HTMLTag("strike", consumer, initialAttributes, null, false, false), HtmlBlockInlineTag fun FlowOrMetaDataContent.templateCommand(data: Command, block: TemplateBlock = {}): Unit = (consumer as? ImmediateResolutionTagConsumer)?.processCommand(data, block) diff --git a/plugins/base/src/main/kotlin/renderers/preprocessors.kt b/plugins/base/src/main/kotlin/renderers/preprocessors.kt index 1a41162d..8a30bed1 100644 --- a/plugins/base/src/main/kotlin/renderers/preprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/preprocessors.kt @@ -1,8 +1,12 @@ package org.jetbrains.dokka.base.renderers import org.jetbrains.dokka.base.resolvers.shared.LinkFormat -import org.jetbrains.dokka.model.withDescendants -import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.pages.ModulePage +import org.jetbrains.dokka.pages.RendererSpecificPage +import org.jetbrains.dokka.pages.RendererSpecificResourcePage +import org.jetbrains.dokka.pages.RendererSpecificRootPage +import org.jetbrains.dokka.pages.RenderingStrategy +import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt index c4c46331..cae0ccaf 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt @@ -96,7 +96,7 @@ open class DokkaLocationProvider( .mapNotNull { ssid -> dokkaContext.configuration.sourceSets.find { it.sourceSetID == ssid }?.toDisplaySourceSet() } - }.orEmpty() + } return allSourceSets.asSequence().mapNotNull { displaySourceSet -> pagesIndex[DRIWithSourceSets(dri, displaySourceSet)]?.let { page -> resolve(page, context) } diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 8d97701d..3c9daa29 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -377,7 +377,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private fun PageContentBuilder.DocumentableContentBuilder.signatureForProjection( p: Projection, showFullyQualifiedName: Boolean = false - ): Unit { + ) { return when (p) { is TypeParameter -> { annotationsInline(p) diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt index bb350b34..0fea9132 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt @@ -26,9 +26,9 @@ object KotlinSignatureUtils : JvmSignatureUtils { annotationsInlineWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension) override fun <T : Documentable> WithExtraProperties<T>.modifiers() = - extra[AdditionalModifiers]?.content?.entries?.map { + extra[AdditionalModifiers]?.content?.entries?.associate { it.key to it.value.filterIsInstance<ExtraModifiers.KotlinOnlyModifiers>().toSet() - }?.toMap() ?: emptyMap() + } ?: emptyMap() val PrimitiveJavaType.dri: DRI get() = DRI("kotlin", name.capitalize()) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 61a7a6a2..6239ad6b 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -34,7 +34,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab it.sourceSetID in sourceSet.dependentSourceSets }.flatMap { getDependencies(it) } - return configuration.sourceSets.map { it to getDependencies(it) }.toMap() + return configuration.sourceSets.associateWith { getDependencies(it) } } private fun <T : Documentable> merge(elements: List<T>, reducer: (T, T) -> T): List<T> = @@ -104,8 +104,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab } val reducedToOneDocumentableWithActualSourceSetIds = groupedByOwnExpectWithActualSourceSetIds.map { it.first.reduce(reducer) to it.second } - val uniqueNamedDocumentables = reducedToOneDocumentableWithActualSourceSetIds.let(::mergeClashingElements) - return uniqueNamedDocumentables + return reducedToOneDocumentableWithActualSourceSetIds.let(::mergeClashingElements) } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt index 181113ae..463ec419 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt @@ -49,7 +49,7 @@ class InheritorsExtractorTransformer : DocumentableTransformer { private fun Map<DokkaSourceSet, Map<DRI, List<DRI>>>.getForDRI(dri: DRI) = map { (v, k) -> v to k[dri] - }.map { (k, v) -> k to v.orEmpty() }.toMap() + }.associate { (k, v) -> k to v.orEmpty() } private fun DModule.generateInheritanceMap() = getInheritanceEntriesRec().filterNot { it.second.isEmpty() }.groupBy({ it.first }) { it.second } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt index 961d2aca..2a5fbc11 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt @@ -3,7 +3,6 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.model.Annotations import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.ExceptionInSupertypes -import org.jetbrains.dokka.model.WithSupertypes import org.jetbrains.dokka.model.properties.WithExtraProperties fun <T> T.isDeprecated() where T : WithExtraProperties<out Documentable> = diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt index c1f1a7f5..fb8ce535 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt @@ -6,7 +6,6 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query -import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.transformers.pages.PageTransformer class PageMerger(context: DokkaContext) : PageTransformer { diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt index cadd3de0..c5b0f221 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt @@ -19,8 +19,7 @@ class DefaultSamplesTransformer(context: DokkaContext) : SamplesTransformer(cont private fun processSampleBody(psiElement: PsiElement): String = when (psiElement) { is KtDeclarationWithBody -> { - val bodyExpression = psiElement.bodyExpression - when (bodyExpression) { + when (val bodyExpression = psiElement.bodyExpression) { is KtBlockExpression -> bodyExpression.text.removeSurrounding("{", "}") else -> bodyExpression!!.text } diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt index 43252be3..3ff7a77d 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt @@ -46,8 +46,8 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { } } - private fun setUpAnalysis(context: DokkaContext) = context.configuration.sourceSets.map { sourceSet -> - sourceSet to if (sourceSet.samples.isEmpty()) context.plugin<DokkaBase>() + private fun setUpAnalysis(context: DokkaContext) = context.configuration.sourceSets.associateWith { sourceSet -> + if (sourceSet.samples.isEmpty()) context.plugin<DokkaBase>() .querySingle { kotlinAnalysis }[sourceSet] // from sourceSet.sourceRoots else AnalysisEnvironment(DokkaMessageCollector(context.logger), sourceSet.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { @@ -63,7 +63,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { val (facade, _) = createResolutionFacade(environment) EnvironmentAndFacade(environment, facade) } - }.toMap() + } private fun ContentNode.addSample( contentPage: ContentPage, diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index f636f984..b6de9276 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -416,7 +416,7 @@ private class DokkaDescriptorVisitor( companion = descriptor.companion(driWithPlatform), sourceSets = setOf(sourceSet), isExpectActual = (isExpect || isActual), - extra = PropertyContainer.withAll<DClass>( + extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations(), ImplementedInterfaces(info.ancestry.allImplementedInterfaces().toSourceSetDependent()), @@ -667,7 +667,7 @@ private class DokkaDescriptorVisitor( sources = descriptor.createSources(), sourceSets = setOf(sourceSet), isExpectActual = (isExpect || isActual), - extra = PropertyContainer.withAll<DFunction>( + extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() ) @@ -724,7 +724,7 @@ private class DokkaDescriptorVisitor( val enumEntries: List<ClassDescriptor> ) - private suspend fun MemberScope.getDescriptorsWithKind(shouldFilter: Boolean = false): DescriptorsWithKind { + private fun MemberScope.getDescriptorsWithKind(shouldFilter: Boolean = false): DescriptorsWithKind { val descriptors = getContributedDescriptors { true }.let { if (shouldFilter) it.filterDescriptorsInSourceSet() else it } @@ -820,7 +820,7 @@ private class DokkaDescriptorVisitor( ) ) - private suspend fun org.jetbrains.kotlin.descriptors.annotations.Annotations.getPresentableName(): String? = + private fun org.jetbrains.kotlin.descriptors.annotations.Annotations.getPresentableName(): String? = mapNotNull { it.toAnnotation() }.singleOrNull { it.dri.classNames == "ParameterName" }?.params?.get("name") .safeAs<StringValue>()?.value?.let { unquotedValue(it) } @@ -896,7 +896,7 @@ private class DokkaDescriptorVisitor( null } }, - kdocLocation = toSourceElement?.containingFile?.name?.let { + kdocLocation = toSourceElement.containingFile.name?.let { val fqName = fqNameOrNull()?.asString() if (fqName != null) "$it/$fqName" else it @@ -967,8 +967,8 @@ private class DokkaDescriptorVisitor( private suspend fun Annotated.getAnnotations() = annotations.parallelMapNotNull { it.toAnnotation() } - private fun ConstantValue<*>.toValue(): AnnotationParameterValue? = when (this) { - is ConstantsAnnotationValue -> value.toAnnotation()?.let { AnnotationValue(it) } + private fun ConstantValue<*>.toValue(): AnnotationParameterValue = when (this) { + is ConstantsAnnotationValue -> AnnotationValue(value.toAnnotation()) is ConstantsArrayValue -> ArrayValue(value.mapNotNull { it.toValue() }) is ConstantsEnumValue -> EnumValue( fullEnumEntryName(), @@ -1004,7 +1004,7 @@ private class DokkaDescriptorVisitor( DRI.from(annotationClass as DeclarationDescriptor), allValueArguments.map { it.key.asString() to it.value.toValue() }.filter { it.second != null - }.toMap() as Map<String, AnnotationParameterValue>, + }.toMap(), mustBeDocumented(), scope ) @@ -1031,16 +1031,16 @@ private class DokkaDescriptorVisitor( private fun ValueParameterDescriptor.getDefaultValue(): Expression? = ((source as? KotlinSourceElement)?.psi as? KtParameter)?.defaultValue?.toDefaultValueExpression() - private suspend fun PropertyDescriptor.getDefaultValue(): Expression? = + private fun PropertyDescriptor.getDefaultValue(): Expression? = (source as? KotlinSourceElement)?.psi?.children?.filterIsInstance<KtConstantExpression>()?.firstOrNull() ?.toDefaultValueExpression() - private suspend fun ClassDescriptor.getAppliedConstructorParameters() = + private fun ClassDescriptor.getAppliedConstructorParameters() = (source as PsiSourceElement).psi?.children?.flatMap { it.safeAs<KtInitializerList>()?.initializersAsExpression().orEmpty() }.orEmpty() - private suspend fun KtInitializerList.initializersAsExpression() = + private fun KtInitializerList.initializersAsExpression() = initializers.firstIsInstanceOrNull<KtCallElement>() ?.getValueArgumentsInParentheses() ?.map { it.getArgumentExpression()?.toDefaultValueExpression() ?: ComplexExpression("") } diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 946d6416..e2aca6f9 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -269,7 +269,7 @@ open class DefaultPageCreator( it.sourceSets.toSet(), kind = ContentKind.SourceSetDependentHint, styles = emptySet(), - extra = PropertyContainer.empty<ContentNode>() + extra = PropertyContainer.empty() ) { +buildSignature(it) contentForBrief(it) @@ -293,7 +293,7 @@ open class DefaultPageCreator( it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependentHint, - extra = PropertyContainer.empty<ContentNode>() + extra = PropertyContainer.empty() ) { +buildSignature(it) contentForBrief(it) @@ -722,7 +722,7 @@ open class DefaultPageCreator( }.groupBy { it.second::class } private val Documentable.descriptions: SourceSetDependent<Description> - get() = groupedTags.withTypeUnnamed<Description>() + get() = groupedTags.withTypeUnnamed() private val Documentable.customTags: Map<String, SourceSetDependent<CustomTagWrapper>> get() = groupedTags.withTypeNamed() diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 88c51b02..7acf735a 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -540,7 +540,7 @@ class DefaultPsiToDocumentableTranslator( } private fun PsiClass.splitFunctionsAndAccessors(): Pair<MutableList<PsiMethod>, MutableMap<PsiField, MutableList<PsiMethod>>> { - val fieldNames = fields.map { it.name to it }.toMap() + val fieldNames = fields.associateBy { it.name } val accessors = mutableMapOf<PsiField, MutableList<PsiMethod>>() val regularMethods = mutableListOf<PsiMethod>() methods.forEach { method -> @@ -572,7 +572,7 @@ class DefaultPsiToDocumentableTranslator( emptyList(), false, psi.additionalExtras().let { - PropertyContainer.withAll<DProperty>( + PropertyContainer.withAll( it.toSourceSetDependent().toAdditionalModifiers(), (psi.annotations.toList() .toListOfAnnotations() + it.toListOfAnnotations()).toSourceSetDependent() diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt index f93f7d6d..a228e95a 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -85,7 +85,7 @@ class JavadocParser( parseWithChildren = parseWithChildren ) - private fun parseDocTag(tag: PsiDocTag, docComment: PsiDocComment, analysedElement: PsiNamedElement): TagWrapper? = + private fun parseDocTag(tag: PsiDocTag, docComment: PsiDocComment, analysedElement: PsiNamedElement): TagWrapper = enumValueOrNull<JavadocTag>(tag.name)?.let { javadocTag -> val resolutionContext = CommentResolutionContext(comment = docComment, tag = javadocTag) when (resolutionContext.tag) { diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/exceptionTag.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/exceptionTag.kt index 6e1850bb..3cc16251 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/exceptionTag.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/exceptionTag.kt @@ -3,7 +3,6 @@ package org.jetbrains.dokka.base.translators.psi.parsers import com.intellij.psi.PsiElement import com.intellij.psi.PsiJavaCodeReferenceElement import com.intellij.psi.impl.source.tree.JavaDocElementType -import com.intellij.psi.javadoc.PsiDocTag import com.intellij.psi.util.PsiTreeUtil internal fun PsiElement.referenceElementOrSelf(): PsiElement? = diff --git a/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt index e6f2c5e9..295a969b 100644 --- a/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt +++ b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt @@ -92,7 +92,7 @@ class DeprecationFilterTest : BaseAbstractTest() { ) { preMergeDocumentablesTransformationStage = { Assertions.assertTrue( - it.first().packages.first().functions.size == 0 + it.first().packages.first().functions.isEmpty() ) } } @@ -132,7 +132,7 @@ class DeprecationFilterTest : BaseAbstractTest() { ) { preMergeDocumentablesTransformationStage = { Assertions.assertTrue( - it.first().packages.first().functions.size == 0 + it.first().packages.first().functions.isEmpty() ) } } diff --git a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt index 51ef4e83..3b333445 100644 --- a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt +++ b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt @@ -458,7 +458,7 @@ class VisibilityFilterTest : BaseAbstractTest() { ) { preMergeDocumentablesTransformationStage = { Assertions.assertTrue( - it.first().packages.first().functions.size == 0 + it.first().packages.first().functions.isEmpty() ) } } @@ -602,7 +602,7 @@ class VisibilityFilterTest : BaseAbstractTest() { ) { preMergeDocumentablesTransformationStage = { Assertions.assertTrue( - it.first().packages.first().functions.size == 0 + it.first().packages.first().functions.isEmpty() ) } } diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index b05ed4fb..920dea10 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -322,7 +322,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class constructors.map { it.name } allEquals "C" - with(constructors.find { it.parameters.isNullOrEmpty() } notNull "C()") { + with(constructors.find { it.parameters.isEmpty() } notNull "C()") { parameters counts 0 } diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt index 613576ae..59b1817a 100644 --- a/plugins/base/src/test/kotlin/model/CommentTest.kt +++ b/plugins/base/src/test/kotlin/model/CommentTest.kt @@ -175,11 +175,9 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme ) { with((this / "comment" / "property").cast<DProperty>()) { comments() equals "Summary\n\none: []" - docs().find { it is CustomTagWrapper && it.name == "one" }.let { - with(it.assertNotNull("'one' entry")) { - root.children counts 0 - root.params.keys counts 0 - } + with(docs().find { it is CustomTagWrapper && it.name == "one" }.assertNotNull("'one' entry")) { + root.children counts 0 + root.params.keys counts 0 } } } diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt index eca5daea..29c81a65 100644 --- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt +++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt @@ -44,7 +44,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { with((this / "function").cast<DPackage>()) { val fn1 = functions.find { - it.name == "fn" && it.parameters.isNullOrEmpty() + it.name == "fn" && it.parameters.isEmpty() }.assertNotNull("fn()") val fn2 = functions.find { it.name == "fn" && it.parameters.isNotEmpty() @@ -81,7 +81,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { with((this / "function").cast<DPackage>()) { val fn1 = functions.find { - it.name == "fn" && it.parameters.isNullOrEmpty() + it.name == "fn" && it.parameters.isEmpty() }.assertNotNull("fn()") val fn2 = functions.find { it.name == "fn" && it.parameters.count() == 1 @@ -228,7 +228,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun with((this / "function" / "Fancy").cast<DAnnotation>()) { with(extra[Annotations]!!.directAnnotations.entries.single().value.assertNotNull("Annotations")) { this counts 3 - with(map { it.dri.classNames to it }.toMap()) { + with(associate { it.dri.classNames to it }) { with(this["Target"].assertNotNull("Target")) { (params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf( EnumValue( @@ -298,7 +298,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun with(extra[Annotations]!!.directAnnotations.entries.single().value.assertNotNull("Annotations")) { this counts 3 - with(map { it.dri.classNames to it }.toMap()) { + with(associate { it.dri.classNames to it }) { with(this["Target"].assertNotNull("Target")) { (params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf( EnumValue( diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt index aa132f6e..748ef190 100644 --- a/plugins/base/src/test/kotlin/model/JavaTest.kt +++ b/plugins/base/src/test/kotlin/model/JavaTest.kt @@ -52,7 +52,10 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { with((this / "fn").cast<DFunction>()) { name equals "fn" val params = parameters.map { it.documentation.values.first().children.first() as Param } - params.mapNotNull { it.firstMemberOfType<Text>()?.body } equals listOf("is String parameter", "is int parameter") + params.map { it.firstMemberOfType<Text>().body } equals listOf( + "is String parameter", + "is int parameter" + ) } } } @@ -160,7 +163,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { constructors counts 2 constructors.forEach { it.name equals "Test" } - constructors.find { it.parameters.isNullOrEmpty() }.assertNotNull("Test()") + constructors.find { it.parameters.isEmpty() }.assertNotNull("Test()") with(constructors.find { it.parameters.isNotEmpty() }.assertNotNull("Test(String)")) { parameters.firstOrNull()?.type?.name equals "String" diff --git a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt index 13892408..94fcd5bf 100644 --- a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt +++ b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt @@ -48,11 +48,11 @@ abstract class HtmlRenderingOnlyTestBase : RenderingOnlyTestBase<Element>() { ) override val context = MockContext( - DokkaBase().outputWriter to { _ -> files }, + DokkaBase().outputWriter to { files }, DokkaBase().locationProviderFactory to ::DokkaLocationProviderFactory, - DokkaBase().htmlPreprocessors to { _ -> RootCreator }, - DokkaBase().externalLocationProviderFactory to { ::JavadocExternalLocationProviderFactory }, - DokkaBase().externalLocationProviderFactory to { ::DefaultExternalLocationProviderFactory }, + DokkaBase().htmlPreprocessors to { RootCreator }, + DokkaBase().externalLocationProviderFactory to ::JavadocExternalLocationProviderFactory, + DokkaBase().externalLocationProviderFactory to ::DefaultExternalLocationProviderFactory, DokkaBase().tabSortingStrategy to { DefaultTabSortingStrategy() }, testConfiguration = configuration ) diff --git a/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt b/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt index 171e510c..65ac1224 100644 --- a/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt +++ b/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt @@ -3,11 +3,13 @@ package signatures import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jsoup.Jsoup import org.jsoup.nodes.Element +import org.jsoup.select.Elements import utils.TestOutputWriterPlugin +import java.nio.file.Path import java.nio.file.Paths abstract class AbstractRenderingTest : BaseAbstractTest() { - val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() + val testDataDir: Path = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() val configuration = dokkaConfiguration { moduleName = "example" @@ -42,11 +44,14 @@ abstract class AbstractRenderingTest : BaseAbstractTest() { } } - fun TestOutputWriterPlugin.renderedContent(path: String) = writer.contents.getValue(path) + fun TestOutputWriterPlugin.renderedContent(path: String): Element = writer.contents.getValue(path) .let { Jsoup.parse(it) }.select("#content").single() - fun TestOutputWriterPlugin.renderedDivergentContent(path: String) = renderedContent(path).select("div.divergent-group") - fun TestOutputWriterPlugin.renderedSourceDepenentContent(path: String) = renderedContent(path).select("div.sourceset-depenent-content") + fun TestOutputWriterPlugin.renderedDivergentContent(path: String): Elements = + renderedContent(path).select("div.divergent-group") + + fun TestOutputWriterPlugin.renderedSourceDepenentContent(path: String): Elements = + renderedContent(path).select("div.sourceset-depenent-content") val Element.brief: String get() = children().select("p").text() diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt index a6f9af7d..8685e3c9 100644 --- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt +++ b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt @@ -1,4 +1,4 @@ -package transformerBuilders; +package transformerBuilders import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.pages.* diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt index d8ea90d7..6c9c351f 100644 --- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt +++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt @@ -2,15 +2,12 @@ package transformers import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationReader import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testApi.testRunner.TestDokkaConfigurationBuilder import testApi.testRunner.dPackage -import testApi.testRunner.dokkaConfiguration -import testApi.testRunner.sourceSet import kotlin.test.assertEquals class ContextModuleAndPackageDocumentationReaderTest3 : AbstractContextModuleAndPackageDocumentationReaderTest() { diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index a0528acd..99082110 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -24,7 +24,7 @@ abstract class ModelDSL : BaseAbstractTest() { interface AssertDSL { infix fun Any?.equals(other: Any?) = assertEquals(other, this) infix fun Collection<Any>?.allEquals(other: Any?) = - this?.also { c -> c.forEach { it equals other } } ?: run { assert(false) { "Collection is empty" } } + this?.onEach { it equals other } ?: run { assert(false) { "Collection is empty" } } infix fun <T> Collection<T>?.exists(e: T) { assertTrue(this.orEmpty().isNotEmpty(), "Collection cannot be null or empty") assertTrue(this!!.any{it == e}, "Collection doesn't contain $e") diff --git a/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt b/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt index b61ce704..b4f66be9 100644 --- a/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt +++ b/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt @@ -5,5 +5,5 @@ class JsClass { /** * @sample samples.SamplesJs.exampleUsage */ - fun printWithExclamation(msg: String) = println(msg + "!") + fun printWithExclamation(msg: String) = println("$msg!") }
\ No newline at end of file diff --git a/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt b/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt index 960184e6..22d44152 100644 --- a/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt +++ b/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt @@ -5,5 +5,5 @@ class JvmClass { /** * @sample samples.SamplesJvm.exampleUsage */ - fun printWithExclamation(msg: String) = println(msg + "!") + fun printWithExclamation(msg: String) = println("$msg!") }
\ No newline at end of file diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt index 6ad73db7..237cf66f 100644 --- a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt @@ -19,12 +19,6 @@ actual open class Clock { * ...JVM! */ fun onlyJVMFunction(): Double = 2.5 - /** - * Custom equals function - */ - override fun equals(other: Any?): Boolean { - return super.equals(other) - } open fun getDayOfTheWeek(): String { TODO("not implemented") |