diff options
Diffstat (limited to 'plugins')
46 files changed, 123 insertions, 127 deletions
diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt index ddaefd8c..1d725398 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt @@ -2,15 +2,16 @@ package signatures import org.jsoup.Jsoup import org.jsoup.nodes.Element +import org.jsoup.select.Elements import utils.Tag import utils.TestOutputWriter -fun TestOutputWriter.renderedContent(path: String = "root/example.html") = +fun TestOutputWriter.renderedContent(path: String = "root/example.html"): Element = contents.getValue(path).let { Jsoup.parse(it) }.select("#content") .single() -fun Element.signature() = select("div.symbol.monospace") -fun Element.firstSignature() = signature().first() +fun Element.signature(): Elements = select("div.symbol.monospace") +fun Element.firstSignature(): Element = signature().first() class Parameters(vararg matchers: Any) : Tag("span", *matchers, expectedClasses = listOf("parameters")) class Parameter(vararg matchers: Any) : Tag("span", *matchers, expectedClasses = listOf("parameter"))
\ No newline at end of file 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") diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt index 4fa6a36e..e66f8a12 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt @@ -15,7 +15,7 @@ sealed class GfmCommand { get() = groupValues[1] val MatchResult.label get() = groupValues[2] - fun Appendable.templateCommand(command: GfmCommand, content: Appendable.() -> Unit): Unit { + fun Appendable.templateCommand(command: GfmCommand, content: Appendable.() -> Unit) { append("<!---$delimiter GfmCommand ${toJsonString(command)}$delimiter--->") content() append("<!---$delimiter--->") diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt index 4dbd5ca7..96bcec70 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt @@ -39,7 +39,7 @@ open class JavadocPageCreator(context: DokkaContext) { fun pageForClasslike(c: DClasslike): JavadocClasslikePageNode? = c.highestJvmSourceSet?.let { jvm -> - var children = c.classlikes.mapNotNull { pageForClasslike(it) } + val children = c.classlikes.mapNotNull { pageForClasslike(it) } JavadocClasslikePageNode( name = c.dri.classNames.orEmpty(), content = contentForClasslike(c), diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt index 6115cbff..2f5caa1c 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt @@ -85,7 +85,7 @@ data class TitleNode( val kind: Kind, override val sourceSets: Set<DisplaySourceSet> ) : JavadocContentNode(dri, kind, sourceSets) { - override fun hasAnyContent(): Boolean = !title.isBlank() || !version.isNullOrBlank() || subtitle.isNotEmpty() + override fun hasAnyContent(): Boolean = title.isNotBlank() || !version.isNullOrBlank() || subtitle.isNotEmpty() override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): TitleNode = this diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt index 6bc0d9fd..c04c7538 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt @@ -51,7 +51,7 @@ object TreeViewInstaller : PageTransformer { private fun installPackageTreeNode(node: JavadocPackagePageNode, root: RootPageNode): JavadocPackagePageNode { val packageTree = TreeViewPage( - name = "${node.name}", + name = node.name, packages = null, classes = node.children.filterIsInstance<JavadocClasslikePageNode>(), dri = node.dri, diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt index 7abbeca8..94af07af 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt @@ -128,7 +128,7 @@ class JavadocLocationTest : BaseAbstractTest() { locationTestInline { rootPageNode, dokkaContext -> val locationProvider = dokkaContext.plugin<JavadocPlugin>().querySingle { locationProviderFactory } .getLocationProvider(rootPageNode) - val packageNode = rootPageNode.firstChildOfType<JavadocPackagePageNode>() { it.name == "javadoc.test" } + val packageNode = rootPageNode.firstChildOfType<JavadocPackagePageNode> { it.name == "javadoc.test" } val packagePath = locationProvider.resolve(packageNode) assertEquals("javadoc/test/package-summary", packagePath) diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt index 531ff59f..aae6f570 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt @@ -2,13 +2,11 @@ package org.jetbrains.dokka.kotlinAsJava import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.DokkaBase -import org.jetbrains.dokka.base.DokkaBaseConfiguration import org.jetbrains.dokka.kotlinAsJava.signatures.JavaSignatureProvider import org.jetbrains.dokka.kotlinAsJava.transformers.JvmNameDocumentableTransformer import org.jetbrains.dokka.kotlinAsJava.transformers.KotlinAsJavaDocumentableTransformer import org.jetbrains.dokka.kotlinAsJava.translators.KotlinAsJavaDocumentableToPageTranslator import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.configuration class KotlinAsJavaPlugin : DokkaPlugin() { val kotlinAsJavaDocumentableTransformer by extending { diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt index 2a0762ba..1e3bd800 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -54,14 +54,14 @@ internal fun DPackage.asJava(): DPackage { classlikes = emptyList(), sources = emptyMap(), expectPresentInSet = null, - visibility = sourceSets.map { - it to JavaVisibility.Public - }.toMap(), + visibility = sourceSets.associateWith { + JavaVisibility.Public + }, companion = null, generics = emptyList(), supertypes = emptyMap(), documentation = emptyMap(), - modifier = sourceSets.map { it to JavaModifier.Final }.toMap(), + modifier = sourceSets.associateWith { JavaModifier.Final }, sourceSets = sourceSets, isExpectActual = false, extra = PropertyContainer.empty() @@ -98,9 +98,9 @@ internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: Stri getter = null, // Removing getters and setters as they will be available as functions extra = if (isTopLevel) extra + extra.mergeAdditionalModifiers( - sourceSets.map { - it to setOf(ExtraModifiers.JavaOnlyModifiers.Static) - }.toMap() + sourceSets.associateWith { + setOf(ExtraModifiers.JavaOnlyModifiers.Static) + } ) else extra ) @@ -138,9 +138,9 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas type = getter.type.asJava(), extra = if (isTopLevel) getter.extra + getter.extra.mergeAdditionalModifiers( - sourceSets.map { - it to setOf(ExtraModifiers.JavaOnlyModifiers.Static) - }.toMap() + sourceSets.associateWith { + setOf(ExtraModifiers.JavaOnlyModifiers.Static) + } ) else getter.extra ) @@ -167,9 +167,9 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas visibility = visibility.mapValues { JavaVisibility.Public }, type = Void, extra = if (isTopLevel) setter.extra + setter.extra.mergeAdditionalModifiers( - sourceSets.map { - it to setOf(ExtraModifiers.JavaOnlyModifiers.Static) - }.toMap() + sourceSets.associateWith { + setOf(ExtraModifiers.JavaOnlyModifiers.Static) + } ) else setter.extra ) @@ -187,16 +187,16 @@ private fun DFunction.asJava( name = newName, type = type.asJava(), modifier = if (modifier.all { (_, v) -> v is KotlinModifier.Final } && isConstructor) - sourceSets.map { it to JavaModifier.Empty }.toMap() - else sourceSets.map { it to modifier.values.first() }.toMap(), + sourceSets.associateWith { JavaModifier.Empty } + else sourceSets.associateWith { modifier.values.first() }, parameters = listOfNotNull(receiver?.asJava()) + parameters.map { it.asJava() }, visibility = visibility.map { (sourceSet, visibility) -> Pair(sourceSet, visibility.asJava()) }.toMap(), receiver = null, extra = if (isTopLevel) { extra + extra.mergeAdditionalModifiers( - sourceSets.map { - it to setOf(ExtraModifiers.JavaOnlyModifiers.Static) - }.toMap() + sourceSets.associateWith { + setOf(ExtraModifiers.JavaOnlyModifiers.Static) + } ) } else { extra @@ -253,7 +253,11 @@ internal fun DClasslike.asJava(): DClasslike = when (this) { internal fun DClass.asJava(): DClass = copy( constructors = constructors .filterNot { it.hasJvmSynthetic() } - .flatMap { it.asJava(dri.classNames ?: name) }, // name may not always be valid here, however classNames should always be not null + .flatMap { + it.asJava( + dri.classNames ?: name + ) + }, // name may not always be valid here, however classNames should always be not null functions = functionsInJava(), properties = properties .filterNot { it.hasJvmSynthetic() } @@ -261,9 +265,8 @@ internal fun DClass.asJava(): DClass = copy( classlikes = classlikes.map { it.asJava() }, generics = generics.map { it.asJava() }, supertypes = supertypes.mapValues { it.value.map { it.asJava() } }, - modifier = if (modifier.all { (_, v) -> v is KotlinModifier.Empty }) sourceSets.map { it to JavaModifier.Final } - .toMap() - else sourceSets.map { it to modifier.values.first() }.toMap() + modifier = if (modifier.all { (_, v) -> v is KotlinModifier.Empty }) sourceSets.associateWith { JavaModifier.Final } + else sourceSets.associateWith { modifier.values.first() } ) internal fun DClass.functionsInJava(): List<DFunction> = @@ -343,13 +346,13 @@ internal fun DObject.asJava(): DObject = copy( .map { it.asJava() } + DProperty( name = "INSTANCE", - modifier = sourceSets.map { it to JavaModifier.Final }.toMap(), + modifier = sourceSets.associateWith { JavaModifier.Final }, dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())), documentation = emptyMap(), sources = emptyMap(), - visibility = sourceSets.map { - it to JavaVisibility.Public - }.toMap(), + visibility = sourceSets.associateWith { + JavaVisibility.Public + }, type = GenericTypeConstructor(dri, emptyList()), setter = null, getter = null, diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt index a50fdf68..61a31627 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt @@ -29,8 +29,8 @@ object JavaSignatureUtils : 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.JavaOnlyModifiers>().toSet() - }?.toMap() ?: emptyMap() + } ?: emptyMap() }
\ No newline at end of file diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt index 31252ae0..c928ea67 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt @@ -18,7 +18,7 @@ class JvmNameProvider { fun <T> nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties<out Documentable>, T : Documentable { val name: String = (entry.fileLevelJvmName()?.params?.get("name") as? StringValue)?.value - ?: entry.sources.entries.first().value.path.split("/").last().split(".").first().capitalize() + "Kt" + ?: (entry.sources.entries.first().value.path.split("/").last().split(".").first().capitalize() + "Kt") return Name("${entry.dri.packageName}.$name") } diff --git a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt index f1aae2dc..80c3a3de 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt @@ -2,13 +2,14 @@ package org.jetbrains.dokka.kotlinAsJava.translators import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.DokkaBaseConfiguration -import org.jetbrains.dokka.base.signatures.SignatureProvider -import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode -import org.jetbrains.dokka.plugability.* +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.configuration +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.query +import org.jetbrains.dokka.plugability.querySingle +import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.utilities.DokkaLogger class KotlinAsJavaDocumentableToPageTranslator(context: DokkaContext) : DocumentableToPageTranslator { diff --git a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt index ef075153..ad3c8b0e 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaPageCreator.kt @@ -4,7 +4,6 @@ import org.jetbrains.dokka.base.DokkaBaseConfiguration import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.base.translators.documentables.DefaultPageCreator -import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.base.transformers.pages.tags.CustomTagContentProvider import org.jetbrains.dokka.model.DProperty import org.jetbrains.dokka.pages.MemberPageNode |