From e4044ec67ad90041b02bb84c4b966ffeac537617 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Sun, 1 Mar 2020 21:26:13 +0100 Subject: Add initial version of Kotlin as Java plugin --- .../transformers/KotlinAsJavaDocumentableTransformer.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt (limited to 'plugins/kotlin-as-java/src/main/kotlin/transformers') diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt new file mode 100644 index 00000000..8f51e105 --- /dev/null +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt @@ -0,0 +1,11 @@ +package org.jetbrains.dokka.kotlinAsJava.transformers + +import org.jetbrains.dokka.kotlinAsJava.converters.asJava +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer + +class KotlinAsJavaDocumentableTransformer : DocumentableTransformer { + override fun invoke(original: Module, context: DokkaContext): Module = + original.copy(packages = original.packages.map { it.asJava() }) +} -- cgit From 996feefe717ac623daabaadda71b5b9d2bbe1cf1 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Mon, 16 Mar 2020 14:33:38 +0100 Subject: Rename Documentables to avoid name conflicts --- core/src/main/kotlin/DokkaGenerator.kt | 12 +- core/src/main/kotlin/model/Documentable.kt | 190 ++++++++++----------- .../main/kotlin/model/documentableProperties.kt | 6 +- .../DescriptorToDocumentableTranslator.kt | 4 +- .../documentation/DocumentableMerger.kt | 4 +- .../documentation/DocumentableToPageTranslator.kt | 4 +- .../documentation/DocumentableTransformer.kt | 4 +- .../psi/PsiToDocumentableTranslator.kt | 4 +- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 4 +- .../kotlin/signatures/KotlinSignatureProvider.kt | 35 ++-- .../documentables/DefaultDocumentableMerger.kt | 116 ++++++------- .../DefaultDescriptorToDocumentableTranslator.kt | 78 +++++---- .../DefaultDocumentableToPageTranslator.kt | 4 +- .../documentables/DefaultPageCreator.kt | 18 +- .../psi/DefaultPsiToDocumentableTranslator.kt | 40 ++--- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 5 +- plugins/base/src/test/kotlin/issues/IssuesTest.kt | 18 +- plugins/base/src/test/kotlin/markdown/KDocTest.kt | 4 +- plugins/base/src/test/kotlin/model/ClassesTest.kt | 60 +++---- plugins/base/src/test/kotlin/model/CommentTest.kt | 32 ++-- .../base/src/test/kotlin/model/FunctionsTest.kt | 18 +- plugins/base/src/test/kotlin/model/JavaTest.kt | 38 ++--- plugins/base/src/test/kotlin/model/PackagesTest.kt | 16 +- plugins/base/src/test/kotlin/model/PropertyTest.kt | 20 +-- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 6 +- plugins/base/src/test/kotlin/utils/TestUtils.kt | 8 +- .../kotlin/converters/KotlinToJavaConverter.kt | 54 +++--- .../kotlin/signatures/JavaSignatureProvider.kt | 34 ++-- .../KotlinAsJavaDocumentableTransformer.kt | 4 +- .../main/kotlin/testApi/testRunner/TestRunner.kt | 14 +- 30 files changed, 422 insertions(+), 432 deletions(-) (limited to 'plugins/kotlin-as-java/src/main/kotlin/transformers') diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 1a0822d7..a3f72220 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -5,7 +5,7 @@ import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiManager import org.jetbrains.dokka.analysis.AnalysisEnvironment import org.jetbrains.dokka.analysis.DokkaResolutionFacade -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext @@ -76,17 +76,17 @@ class DokkaGenerator( platforms.map { (pdata, _) -> translatePsi(pdata, context) } fun mergeDocumentationModels( - modulesFromPlatforms: List, + modulesFromPlatforms: List, context: DokkaContext ) = context.single(CoreExtensions.documentableMerger).invoke(modulesFromPlatforms, context) fun transformDocumentationModel( - documentationModel: Module, + documentationModel: DModule, context: DokkaContext ) = context[CoreExtensions.documentableTransformer].fold(documentationModel) { acc, t -> t(acc, context) } fun createPages( - transformedDocumentation: Module, + transformedDocumentation: DModule, context: DokkaContext ) = context.single(CoreExtensions.documentableToPageTranslator).invoke(transformedDocumentation) @@ -119,7 +119,7 @@ class DokkaGenerator( EnvironmentAndFacade(environment, facade) } - private fun translateDescriptors(platformData: PlatformData, context: DokkaContext): Module { + private fun translateDescriptors(platformData: PlatformData, context: DokkaContext): DModule { val (environment, facade) = context.platforms.getValue(platformData) val packageFragments = environment.getSourceFiles().asSequence() @@ -132,7 +132,7 @@ class DokkaGenerator( .invoke(platformData.name, packageFragments, platformData) } - private fun translatePsi(platformData: PlatformData, context: DokkaContext): Module { + private fun translatePsi(platformData: PlatformData, context: DokkaContext): DModule { val (environment, _) = context.platforms.getValue(platformData) val sourceRoots = environment.configuration.get(CLIConfigurationKeys.CONTENT_ROOTS) diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index b697f4e4..22930bf2 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -48,9 +48,9 @@ interface WithExpectActual { } interface WithScope { - val functions: List - val properties: List - val classlikes: List + val functions: List + val properties: List + val classlikes: List } interface WithVisibility { @@ -81,15 +81,15 @@ sealed class JavaModifier(name: String) : Modifier(name) { } interface WithCompanion { - val companion: Object? + val companion: DObject? } interface WithConstructors { - val constructors: List + val constructors: List } interface WithGenerics { - val generics: List + val generics: List } interface WithSupertypes { @@ -97,232 +97,232 @@ interface WithSupertypes { } interface Callable : WithVisibility, WithType, WithAbstraction, WithExpectActual { - val receiver: Parameter? + val receiver: DParameter? } -abstract class Classlike : Documentable(), WithScope, WithVisibility, WithExpectActual +abstract class DClasslike : Documentable(), WithScope, WithVisibility, WithExpectActual -data class Module( +data class DModule( override val name: String, - val packages: List, + val packages: List, override val documentation: PlatformDependent, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithExtraProperties { override val dri: DRI = DRI.topLevel override val children: List get() = packages - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Package( +data class DPackage( override val dri: DRI, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val documentation: PlatformDependent, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithScope, WithExtraProperties { override val name = dri.packageName.orEmpty() override val children: List get() = (properties + functions + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Class( +data class DClass( override val dri: DRI, override val name: String, - override val constructors: List, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val constructors: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val sources: PlatformDependent, override val visibility: PlatformDependent, - override val companion: Object?, - override val generics: List, + override val companion: DObject?, + override val generics: List, override val supertypes: PlatformDependent>, override val documentation: PlatformDependent, override val modifier: Modifier, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, - WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, + WithExtraProperties { override val children: List get() = (functions + properties + classlikes + constructors) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Enum( +data class DEnum( override val dri: DRI, override val name: String, - val entries: List, + val entries: List, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, - override val companion: Object?, - override val constructors: List, + override val companion: DObject?, + override val constructors: List, override val supertypes: PlatformDependent>, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties { override val children: List get() = (entries + functions + properties + classlikes + constructors) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class EnumEntry( +data class DEnumEntry( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithScope, WithExtraProperties { override val children: List get() = (functions + properties + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Function( +data class DFunction( override val dri: DRI, override val name: String, val isConstructor: Boolean, - val parameters: List, + val parameters: List, override val documentation: PlatformDependent, override val sources: PlatformDependent, override val visibility: PlatformDependent, override val type: Bound, - override val generics: List, - override val receiver: Parameter?, + override val generics: List, + override val receiver: DParameter?, override val modifier: Modifier, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithGenerics, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), Callable, WithGenerics, WithExtraProperties { override val children: List get() = parameters - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Interface( +data class DInterface( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, - override val companion: Object?, - override val generics: List, + override val companion: DObject?, + override val generics: List, override val supertypes: PlatformDependent>, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties { override val children: List get() = (functions + properties + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Object( +data class DObject( override val name: String?, override val dri: DRI, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, override val supertypes: PlatformDependent>, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithSupertypes, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithSupertypes, WithExtraProperties { override val children: List get() = (functions + properties + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Annotation( +data class DAnnotation( override val name: String, override val dri: DRI, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, - override val companion: Object?, - override val constructors: List, + override val companion: DObject?, + override val constructors: List, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithCompanion, WithConstructors, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties { override val children: List get() = (functions + properties + classlikes + constructors) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Property( +data class DProperty( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, override val sources: PlatformDependent, override val visibility: PlatformDependent, override val type: Bound, - override val receiver: Parameter?, - val setter: Function?, - val getter: Function?, + override val receiver: DParameter?, + val setter: DFunction?, + val getter: DFunction?, override val modifier: Modifier, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), Callable, WithExtraProperties { override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } // TODO: treat named Parameters and receivers differently -data class Parameter( +data class DParameter( override val dri: DRI, override val name: String?, override val documentation: PlatformDependent, val type: Bound, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithExtraProperties { override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class TypeParameter( +data class DTypeParameter( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, val bounds: List, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithExtraProperties { override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } sealed class Projection diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index 38a06451..67e5e88d 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -3,12 +3,12 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -data class InheritedFunction(val isInherited: Boolean): ExtraProperty { - object InheritedFunctionKey: ExtraProperty.Key { +data class InheritedFunction(val isInherited: Boolean): ExtraProperty { + object InheritedFunctionKey: ExtraProperty.Key { override fun mergeStrategyFor(left: Boolean, right: Boolean) = MergeStrategy.Fail { throw IllegalArgumentException("Function inheritance should be consistent!") } } - override val key: ExtraProperty.Key = + override val key: ExtraProperty.Key = InheritedFunctionKey } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt index d72eeafd..ca66b90a 100644 --- a/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.transformers.descriptors -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor @@ -9,5 +9,5 @@ interface DescriptorToDocumentableTranslator { moduleName: String, packageFragments: Iterable, platformData: PlatformData - ): Module + ): DModule } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt index 5a17bc24..c8ae9c02 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt @@ -1,8 +1,8 @@ package org.jetbrains.dokka.transformers.documentation -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext interface DocumentableMerger { - operator fun invoke(modules: Collection, context: DokkaContext): Module + operator fun invoke(modules: Collection, context: DokkaContext): DModule } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt index e41e0c84..83456f01 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt @@ -1,8 +1,8 @@ package org.jetbrains.dokka.transformers.documentation -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode interface DocumentableToPageTranslator { - operator fun invoke(module: Module): ModulePageNode + operator fun invoke(module: DModule): ModulePageNode } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt index 88a1514d..3eb4704e 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt @@ -1,8 +1,8 @@ package org.jetbrains.dokka.transformers.documentation -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext interface DocumentableTransformer { - operator fun invoke(original: Module, context: DokkaContext): Module + operator fun invoke(original: DModule, context: DokkaContext): DModule } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt index 1ea07ff3..6f5025bd 100644 --- a/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.transformers.psi import com.intellij.psi.PsiJavaFile -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.plugability.DokkaContext @@ -11,5 +11,5 @@ interface PsiToDocumentableTranslator { psiFiles: List, platformData: PlatformData, context: DokkaContext - ): Module + ): DModule } diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index d7b2a912..34dac9f4 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -4,7 +4,7 @@ import kotlinx.html.* import kotlinx.html.stream.createHTML import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import java.io.File @@ -269,7 +269,7 @@ private fun PageNode.pageKind() = when (this) { is PackagePageNode -> "package" is ClasslikePageNode -> "class" is MemberPageNode -> when (this.documentable) { - is Function -> "function" + is DFunction -> "function" else -> "other" } else -> "other" diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index f600a3bf..8a080bb9 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -6,12 +6,11 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.DriOfUnit import org.jetbrains.dokka.links.sureClassNames import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode -import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.TextStyle import org.jetbrains.dokka.utilities.DokkaLogger @@ -21,26 +20,26 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private val ignoredVisibilities = setOf(JavaVisibility.Default, KotlinVisibility.Public) override fun signature(documentable: Documentable): ContentNode = when (documentable) { - is Function -> signature(documentable) - is Property -> signature(documentable) - is Classlike -> signature(documentable) - is TypeParameter -> signature(documentable) + is DFunction -> signature(documentable) + is DProperty -> signature(documentable) + is DClasslike -> signature(documentable) + is DTypeParameter -> signature(documentable) else -> throw NotImplementedError( "Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}" ) } - private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } - if (c is Class) { + if (c is DClass) { text(c.modifier.name + " ") } when (c) { - is Class -> text("class ") - is Interface -> text("interface ") - is Enum -> text("enum ") - is Object -> text("object ") - is Annotation -> text("annotation class ") + is DClass -> text("class ") + is DInterface -> text("interface ") + is DEnum -> text("enum ") + is DObject -> text("object ") + is DAnnotation -> text("annotation class ") } link(c.name!!, c.dri) if (c is WithSupertypes) { @@ -52,11 +51,11 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } } - private fun signature(p: Property) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(p: DProperty) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { signatureForProjection(p.type) } - private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(f.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } text(f.modifier.name + " ") text("fun ") @@ -82,7 +81,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } } - private fun signature(t: TypeParameter) = contentBuilder.contentFor(t) { + private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) { link(t.name, t.dri) list(t.bounds, prefix = " : ") { signatureForProjection(it) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 4d47401b..bb7dbaaf 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -1,10 +1,10 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Package -import org.jetbrains.dokka.model.Annotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction +import org.jetbrains.dokka.model.DPackage +import org.jetbrains.dokka.model.DAnnotation import org.jetbrains.dokka.model.properties.mergeExtras import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.plugability.DokkaContext @@ -12,7 +12,7 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableMerger import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult internal object DefaultDocumentableMerger : DocumentableMerger { - override fun invoke(modules: Collection, context: DokkaContext): Module { + override fun invoke(modules: Collection, context: DokkaContext): DModule { val name = modules.map { it.name }.distinct().singleOrNull() ?: run { context.logger.error("All module names need to be the same") modules.first().name @@ -21,11 +21,11 @@ internal object DefaultDocumentableMerger : DocumentableMerger { return modules.reduce { left, right -> val list = listOf(left, right) - Module( + DModule( name = name, packages = merge( list.flatMap { it.packages }, - Package::mergeWith + DPackage::mergeWith ), documentation = list.platformDependentFor { documentation }, platformData = list.flatMap { it.platformData }.distinct() @@ -106,25 +106,25 @@ private sealed class Expect { } } -fun Package.mergeWith(other: Package): Package = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DPackage.mergeWith(other: DPackage): DPackage = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Function.mergeWith(other: Function): Function = copy( - parameters = merge(this.parameters + other.parameters, Parameter::mergeWith), +fun DFunction.mergeWith(other: DFunction): DFunction = copy( + parameters = merge(this.parameters + other.parameters, DParameter::mergeWith), receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct(), - generics = merge(generics + other.generics, TypeParameter::mergeWith) + generics = merge(generics + other.generics, DTypeParameter::mergeWith) ).mergeExtras(this, other) -fun Property.mergeWith(other: Property): Property = copy( +fun DProperty.mergeWith(other: DProperty): DProperty = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -134,33 +134,33 @@ fun Property.mergeWith(other: Property): Property = copy( setter = setter?.let { s -> other.setter?.let { s.mergeWith(it) } ?: s } ?: other.setter ).mergeExtras(this, other) -fun Classlike.setPlatformData(platformData: List): Classlike = when (this) { - is Class -> copy(platformData = platformData) - is Enum -> copy(platformData = platformData) - is Interface -> copy(platformData = platformData) - is Object -> copy(platformData = platformData) +fun DClasslike.setPlatformData(platformData: List): DClasslike = when (this) { + is DClass -> copy(platformData = platformData) + is DEnum -> copy(platformData = platformData) + is DInterface -> copy(platformData = platformData) + is DObject -> copy(platformData = platformData) else -> throw IllegalStateException("${this::class.qualifiedName} ${this.name} cannot have platform set") } -fun Classlike.mergeWith(other: Classlike): Classlike = when { - this is Class && other is Class -> mergeWith(other) - this is Enum && other is Enum -> mergeWith(other) - this is Interface && other is Interface -> mergeWith(other) - this is Object && other is Object -> mergeWith(other) - this is Annotation && other is Annotation -> mergeWith(other) +fun DClasslike.mergeWith(other: DClasslike): DClasslike = when { + this is DClass && other is DClass -> mergeWith(other) + this is DEnum && other is DEnum -> mergeWith(other) + this is DInterface && other is DInterface -> mergeWith(other) + this is DObject && other is DObject -> mergeWith(other) + this is DAnnotation && other is DAnnotation -> mergeWith(other) else -> throw IllegalStateException("${this::class.qualifiedName} ${this.name} cannot be mergesd with ${other::class.qualifiedName} ${other.name}") } -fun Class.mergeWith(other: Class): Class = copy( +fun DClass.mergeWith(other: DClass): DClass = copy( constructors = mergeExpectActual( constructors + other.constructors, - Function::mergeWith + DFunction::mergeWith ) { copy(platformData = it) }, - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, - generics = merge(generics + other.generics, TypeParameter::mergeWith), + generics = merge(generics + other.generics, DTypeParameter::mergeWith), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -168,15 +168,15 @@ fun Class.mergeWith(other: Class): Class = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Enum.mergeWith(other: Enum): Enum = copy( - entries = merge(entries + other.entries, EnumEntry::mergeWith), +fun DEnum.mergeWith(other: DEnum): DEnum = copy( + entries = merge(entries + other.entries, DEnumEntry::mergeWith), constructors = mergeExpectActual( constructors + other.constructors, - Function::mergeWith + DFunction::mergeWith ) { copy(platformData = it) }, - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), @@ -185,18 +185,18 @@ fun Enum.mergeWith(other: Enum): Enum = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun EnumEntry.mergeWith(other: EnumEntry): EnumEntry = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DEnumEntry.mergeWith(other: DEnumEntry): DEnumEntry = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Object.mergeWith(other: Object): Object = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DObject.mergeWith(other: DObject): DObject = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -204,12 +204,12 @@ fun Object.mergeWith(other: Object): Object = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Interface.mergeWith(other: Interface): Interface = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DInterface.mergeWith(other: DInterface): DInterface = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, - generics = merge(generics + other.generics, TypeParameter::mergeWith), + generics = merge(generics + other.generics, DTypeParameter::mergeWith), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -217,14 +217,14 @@ fun Interface.mergeWith(other: Interface): Interface = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Annotation.mergeWith(other: Annotation): Annotation = copy( +fun DAnnotation.mergeWith(other: DAnnotation): DAnnotation = copy( constructors = mergeExpectActual( constructors + other.constructors, - Function::mergeWith + DFunction::mergeWith ) { copy(platformData = it) }, - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -232,12 +232,12 @@ fun Annotation.mergeWith(other: Annotation): Annotation = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Parameter.mergeWith(other: Parameter): Parameter = copy( +fun DParameter.mergeWith(other: DParameter): DParameter = copy( documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun TypeParameter.mergeWith(other: TypeParameter): TypeParameter = copy( +fun DTypeParameter.mergeWith(other: DTypeParameter): DTypeParameter = copy( documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 9a71145f..eb23ffd7 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.withClass import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.PlatformData @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBo import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.components.isVararg import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces @@ -30,7 +29,6 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeProjection import org.jetbrains.dokka.model.Variance -import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.fqName import org.jetbrains.kotlin.idea.kdoc.findKDoc class DefaultDescriptorToDocumentableTranslator( @@ -47,7 +45,7 @@ class DefaultDescriptorToDocumentableTranslator( DRIWithPlatformInfo(DRI.topLevel, PlatformDependent.empty()) ) } - }.let { Module(moduleName, it, PlatformDependent.empty(), listOf(platformData)) } + }.let { DModule(moduleName, it, PlatformDependent.empty(), listOf(platformData)) } } @@ -69,11 +67,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv override fun visitPackageFragmentDescriptor( descriptor: PackageFragmentDescriptor, parent: DRIWithPlatformInfo - ): Package { + ): DPackage { val driWithPlatform = DRI(packageName = descriptor.fqName.asString()).withEmptyInfo() val scope = descriptor.getMemberScope() - return Package( + return DPackage( dri = driWithPlatform.dri, functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), @@ -83,7 +81,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike = + override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DClasslike = when (descriptor.kind) { ClassKind.ENUM_CLASS -> enumDescriptor(descriptor, parent) ClassKind.OBJECT -> objectDescriptor(descriptor, parent) @@ -91,12 +89,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv else -> classDescriptor(descriptor, parent) } - private fun interfaceDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Interface { + private fun interfaceDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DInterface { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) - return Interface( + return DInterface( dri = driWithPlatform.dri, name = descriptor.name.asString(), functions = scope.functions(driWithPlatform), @@ -113,12 +111,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun objectDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Object { + private fun objectDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DObject { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) - return Object( + return DObject( dri = driWithPlatform.dri, name = descriptor.name.asString(), functions = scope.functions(driWithPlatform), @@ -133,12 +131,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun enumDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Enum { + private fun enumDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DEnum { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) - return Enum( + return DEnum( dri = driWithPlatform.dri, name = descriptor.name.asString(), entries = scope.enumEntries(driWithPlatform), @@ -156,11 +154,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun enumEntryDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): EnumEntry { + private fun enumEntryDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DEnumEntry { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope - return EnumEntry( + return DEnumEntry( dri = driWithPlatform.dri, name = descriptor.name.asString(), documentation = descriptor.resolveDescriptorData(platformData), @@ -172,13 +170,13 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun classDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Class { + private fun classDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DClass { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) val actual = descriptor.createSources() - return Class( + return DClass( dri = driWithPlatform.dri, name = descriptor.name.asString(), constructors = descriptor.constructors.map { @@ -203,11 +201,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { + override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): DProperty { val dri = parent.dri.copy(callable = Callable.from(descriptor)) val actual = descriptor.createSources() - return Property( + return DProperty( dri = dri, name = descriptor.name.asString(), receiver = descriptor.extensionReceiverParameter?.let { @@ -229,11 +227,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { + override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): DFunction { val dri = parent.dri.copy(callable = Callable.from(descriptor)) val actual = descriptor.createSources() - return Function( + return DFunction( dri = dri, name = descriptor.name.asString(), isConstructor = false, @@ -254,10 +252,10 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { + override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): DFunction { val dri = parent.dri.copy(callable = Callable.from(descriptor)) val actual = descriptor.createSources() - return Function( + return DFunction( dri = dri, name = "", isConstructor = true, @@ -281,7 +279,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv override fun visitReceiverParameterDescriptor( descriptor: ReceiverParameterDescriptor, parent: DRIWithPlatformInfo - ) = Parameter( + ) = DParameter( dri = parent.dri.copy(target = 0), name = null, type = descriptor.type.toBound(), @@ -293,12 +291,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv descriptor: PropertyAccessorDescriptor, propertyDescriptor: PropertyDescriptor, parent: DRI - ): Function { + ): DFunction { val dri = parent.copy(callable = Callable.from(descriptor)) val isGetter = descriptor is PropertyGetterDescriptor fun PropertyDescriptor.asParameter(parent: DRI) = - Parameter( + DParameter( parent.copy(target = 1), this.name.asString(), type = this.type.toBound(), @@ -320,7 +318,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv listOf(propertyDescriptor.asParameter(dri)) } - return Function( + return DFunction( dri, name, isConstructor = false, @@ -343,7 +341,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv } private fun parameter(index: Int, descriptor: ValueParameterDescriptor, parent: DRIWithPlatformInfo) = - Parameter( + DParameter( dri = parent.dri.copy(target = index + 1), name = descriptor.name.asString(), type = descriptor.type.toBound(), @@ -352,28 +350,28 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv extra = descriptor.additionalExtras() ) - private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = + private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.FUNCTIONS) { true } .filterIsInstance() .map { visitFunctionDescriptor(it, parent) } - private fun MemberScope.properties(parent: DRIWithPlatformInfo): List = + private fun MemberScope.properties(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.VALUES) { true } .filterIsInstance() .map { visitPropertyDescriptor(it, parent) } - private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List = + private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } .filterIsInstance() .map { visitClassDescriptor(it, parent) } - .mapNotNull { it as? Classlike } + .mapNotNull { it as? DClasslike } - private fun MemberScope.packages(parent: DRIWithPlatformInfo): List = + private fun MemberScope.packages(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.PACKAGES) { true } .filterIsInstance() .map { visitPackageFragmentDescriptor(it, parent) } - private fun MemberScope.enumEntries(parent: DRIWithPlatformInfo): List = + private fun MemberScope.enumEntries(parent: DRIWithPlatformInfo): List = this.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } .filterIsInstance() .filter { it.kind == ClassKind.ENUM_ENTRY } @@ -391,7 +389,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv } private fun TypeParameterDescriptor.toTypeParameter() = - TypeParameter( + DTypeParameter( DRI.from(this), name.identifier, PlatformDependent.from(platformData, getDocumentation()), @@ -428,7 +426,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv MarkdownParser(resolutionFacade, this).parseFromKDocTag(it) } - fun ClassDescriptor.companion(dri: DRIWithPlatformInfo): Object? = companionObjectDescriptor?.let { + fun ClassDescriptor.companion(dri: DRIWithPlatformInfo): DObject? = companionObjectDescriptor?.let { objectDescriptor(it, dri) } @@ -467,7 +465,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ExtraModifiers.OVERRIDE.takeIf { getSuperInterfaces().isNotEmpty() || getSuperClassNotAny() != null } ).toContainer() - fun ValueParameterDescriptor.additionalExtras(): PropertyContainer = + fun ValueParameterDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( ExtraModifiers.DYNAMIC.takeIf { isDynamic() }, ExtraModifiers.NOINLINE.takeIf { isNoinline }, @@ -477,13 +475,13 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ExtraModifiers.VARARG.takeIf { isVararg } ).toContainer() - fun TypeParameterDescriptor.additionalExtras(): PropertyContainer = + fun TypeParameterDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( ExtraModifiers.DYNAMIC.takeIf { isDynamic() }, ExtraModifiers.REIFIED.takeIf { isReified } ).toContainer() - fun PropertyDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( + fun PropertyDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( ExtraModifiers.DYNAMIC.takeIf { isDynamic() }, ExtraModifiers.CONST.takeIf { isConst }, ExtraModifiers.LATEINIT.takeIf { isLateInit }, diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt index 16f9b9b3..04251947 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka.base.translators.documentables import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.utilities.DokkaLogger @@ -12,6 +12,6 @@ class DefaultDocumentableToPageTranslator( private val signatureProvider: SignatureProvider, private val logger: DokkaLogger ) : DocumentableToPageTranslator { - override fun invoke(module: Module): ModulePageNode = + override fun invoke(module: DModule): ModulePageNode = DefaultPageCreator(commentsToContentConverter, signatureProvider, logger).pageForModule(module) } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 560bda71..a0b5a072 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -4,7 +4,7 @@ import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.doc.Property import org.jetbrains.dokka.model.doc.TagWrapper import org.jetbrains.dokka.pages.* @@ -17,16 +17,16 @@ open class DefaultPageCreator( ) { protected open val contentBuilder = PageContentBuilder(commentsToContentConverter, signatureProvider, logger) - open fun pageForModule(m: Module) = + open fun pageForModule(m: DModule) = ModulePageNode(m.name.ifEmpty { "" }, contentForModule(m), m, m.packages.map(::pageForPackage)) - open fun pageForPackage(p: Package): PackagePageNode = PackagePageNode( + open fun pageForPackage(p: DPackage): PackagePageNode = PackagePageNode( p.name, contentForPackage(p), setOf(p.dri), p, p.classlikes.map(::pageForClasslike) + p.functions.map(::pageForFunction) ) - open fun pageForClasslike(c: Classlike): ClasslikePageNode { + open fun pageForClasslike(c: DClasslike): ClasslikePageNode { val constructors = if (c is WithConstructors) c.constructors else emptyList() return ClasslikePageNode( @@ -37,9 +37,9 @@ open class DefaultPageCreator( ) } - open fun pageForFunction(f: Function) = MemberPageNode(f.name, contentForFunction(f), setOf(f.dri), f) + open fun pageForFunction(f: DFunction) = MemberPageNode(f.name, contentForFunction(f), setOf(f.dri), f) - protected open fun contentForModule(m: Module) = contentBuilder.contentFor(m) { + protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) { header(1) { text(m.name) } block("Packages", 2, ContentKind.Packages, m.packages, m.platformData.toSet()) { link(it.name, it.dri) @@ -48,7 +48,7 @@ open class DefaultPageCreator( // text("Link to allpage here") } - protected open fun contentForPackage(p: Package) = contentBuilder.contentFor(p) { + protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) { header(1) { text("Package ${p.name}") } +contentForScope(p, p.dri, p.platformData) } @@ -87,7 +87,7 @@ open class DefaultPageCreator( } } - protected open fun contentForClasslike(c: Classlike) = contentBuilder.contentFor(c) { + protected open fun contentForClasslike(c: DClasslike) = contentBuilder.contentFor(c) { header(1) { text(c.name.orEmpty()) } +buildSignature(c) @@ -126,7 +126,7 @@ open class DefaultPageCreator( } }.children - protected open fun contentForFunction(f: Function) = contentBuilder.contentFor(f) { + protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) { header(1) { text(f.name) } +buildSignature(f) +contentForComments(f) diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 65f94843..c5c72a65 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -9,9 +9,9 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.JavaClassReference import org.jetbrains.dokka.links.withClass import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.plugability.DokkaContext @@ -31,17 +31,17 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { psiFiles: List, platformData: PlatformData, context: DokkaContext - ): Module { + ): DModule { val docParser = DokkaPsiParser( platformData, context.logger ) - return Module( + return DModule( moduleName, psiFiles.groupBy { it.packageName }.map { (packageName, psiFiles) -> val dri = DRI(packageName = packageName) - Package( + DPackage( dri, emptyList(), emptyList(), @@ -93,7 +93,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { private fun T.toPlatformDependant() = PlatformDependent(mapOf(platformData to this)) - fun parseClasslike(psi: PsiClass, parent: DRI): Classlike = with(psi) { + fun parseClasslike(psi: PsiClass, parent: DRI): DClasslike = with(psi) { val dri = parent.withClass(name.toString()) val ancestorsSet = hashSetOf() val superMethodsKeys = hashSetOf() @@ -133,7 +133,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { val ancestors = ancestorsSet.toList().toPlatformDependant() return when { isAnnotationType -> - Annotation( + DAnnotation( name.orEmpty(), dri, documentation, @@ -146,11 +146,11 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { constructors.map { parseFunction(it, dri, true) }, listOf(platformData) ) - isEnum -> Enum( + isEnum -> DEnum( dri, name.orEmpty(), fields.filterIsInstance().map { entry -> - EnumEntry( + DEnumEntry( dri.withClass("$name.${entry.name}"), entry.name.orEmpty(), javadocParser.parseDocumentation(entry).toPlatformDependant(), @@ -171,7 +171,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { ancestors, listOf(platformData) ) - isInterface -> Interface( + isInterface -> DInterface( dri, name.orEmpty(), documentation, @@ -185,7 +185,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { ancestors, listOf(platformData) ) - else -> Class( + else -> DClass( dri, name.orEmpty(), constructors.map { parseFunction(it, dri, true) }, @@ -209,7 +209,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { parent: DRI, isConstructor: Boolean = false, isInherited: Boolean = false - ): Function { + ): DFunction { val dri = parent.copy( callable = Callable( psi.name, @@ -218,12 +218,12 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { JavaClassReference(parameter.type.canonicalText) }) ) - return Function( + return DFunction( dri, if (isConstructor) "" else psi.name, isConstructor, psi.parameterList.parameters.mapIndexed { index, psiParameter -> - Parameter( + DParameter( dri.copy(target = index + 1), psiParameter.name, javadocParser.parseDocumentation(psiParameter).toPlatformDependant(), @@ -239,7 +239,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { null, psi.getModifier(), listOf(platformData), - PropertyContainer.empty() + InheritedFunction( + PropertyContainer.empty() + InheritedFunction( isInherited ) ) @@ -278,7 +278,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { else -> JavaModifier.Empty } - private fun PsiTypeParameterListOwner.mapTypeParameters(dri: DRI): List { + private fun PsiTypeParameterListOwner.mapTypeParameters(dri: DRI): List { fun mapBounds(bounds: Array): List = if (bounds.isEmpty()) emptyList() else bounds.mapNotNull { (it as? PsiClassType)?.let { classType -> @@ -286,7 +286,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { } } return typeParameters.mapIndexed { index, type -> - TypeParameter( + DTypeParameter( dri.copy(genericTarget = index), type.name.orEmpty(), javadocParser.parseDocumentation(type).toPlatformDependant(), @@ -323,7 +323,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { return regularMethods to accessors } - private fun parseField(psi: PsiField, parent: DRI, accessors: List): Property { + private fun parseField(psi: PsiField, parent: DRI, accessors: List): DProperty { val dri = parent.copy( callable = Callable( psi.name!!, // TODO: Investigate if this is indeed nullable @@ -331,7 +331,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { emptyList() ) ) - return Property( + return DProperty( dri, psi.name!!, // TODO: Investigate if this is indeed nullable javadocParser.parseDocumentation(psi).toPlatformDependant(), diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index ea3238a5..34e92d82 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -1,9 +1,8 @@ package enums -import org.jetbrains.dokka.model.Enum +import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.pages.ClasslikePageNode import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.Assert import org.junit.Assert.* import org.junit.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest @@ -72,7 +71,7 @@ class EnumsTest : AbstractCoreTest() { p.first().classlikes.let { c -> assertTrue("Classlikes list cannot be empty", c.isNotEmpty()) - val enum = c.first() as Enum + val enum = c.first() as DEnum assertEquals(enum.name, "Test") assertEquals(enum.entries.count(), 2) assertNotNull(enum.companion) diff --git a/plugins/base/src/test/kotlin/issues/IssuesTest.kt b/plugins/base/src/test/kotlin/issues/IssuesTest.kt index ea2f0f8e..e34c610a 100644 --- a/plugins/base/src/test/kotlin/issues/IssuesTest.kt +++ b/plugins/base/src/test/kotlin/issues/IssuesTest.kt @@ -1,7 +1,7 @@ package issues -import org.jetbrains.dokka.model.Class -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DClass +import org.jetbrains.dokka.model.DFunction import org.junit.Test import utils.AbstractModelTest @@ -33,16 +33,16 @@ class IssuesTest : AbstractModelTest("/src/main/kotlin/issues/Test.kt", "issues" |} """ ) { - with((this / "issues" / "Test").cast()) { + with((this / "issues" / "Test").cast()) { // passes - (this / "working").cast().type.constructorFqName equals "kotlin.String" - (this / "doSomething").cast().type.constructorFqName equals "kotlin.String" + (this / "working").cast().type.constructorFqName equals "kotlin.String" + (this / "doSomething").cast().type.constructorFqName equals "kotlin.String" // fails - (this / "brokenGenerics").cast().type.constructorFqName equals "kotlin.collections.List" - (this / "brokenApply").cast().type.constructorFqName equals "issues.Test" - (this / "brokenRun").cast().type.constructorFqName equals "issues.Test" - (this / "brokenLet").cast().type.constructorFqName equals "issues.Test" + (this / "brokenGenerics").cast().type.constructorFqName equals "kotlin.collections.List" + (this / "brokenApply").cast().type.constructorFqName equals "issues.Test" + (this / "brokenRun").cast().type.constructorFqName equals "issues.Test" + (this / "brokenLet").cast().type.constructorFqName equals "issues.Test" } } } diff --git a/plugins/base/src/test/kotlin/markdown/KDocTest.kt b/plugins/base/src/test/kotlin/markdown/KDocTest.kt index e250670a..fa538c3e 100644 --- a/plugins/base/src/test/kotlin/markdown/KDocTest.kt +++ b/plugins/base/src/test/kotlin/markdown/KDocTest.kt @@ -1,6 +1,6 @@ package markdown -import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.pages.ModulePageNode import org.junit.Assert @@ -26,7 +26,7 @@ open class KDocTest : AbstractCoreTest() { """.trimMargin() private fun actualDocumentationNode(modulePageNode: ModulePageNode) = - (modulePageNode.documentable?.children?.first() as Package) + (modulePageNode.documentable?.children?.first() as DPackage) .classlikes.single() .documentation.values.single() diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index a59174bf..d627dab4 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -2,7 +2,7 @@ package model import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.KotlinModifier.* -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DFunction import org.junit.Test import utils.AbstractModelTest import utils.assertNotNull @@ -17,7 +17,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class """ |class Klass {}""" ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 4 } @@ -31,7 +31,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |object Obj {} """ ) { - with((this / "classes" / "Obj").cast()) { + with((this / "classes" / "Obj").cast()) { name equals "Obj" children counts 3 } @@ -45,7 +45,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |class Klass(name: String) """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 4 @@ -71,11 +71,11 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 5 - with((this / "fn").cast()) { + with((this / "fn").cast()) { type.constructorFqName equals "kotlin.Unit" parameters counts 0 visibility.values allEquals KotlinVisibility.Public @@ -93,11 +93,11 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 5 - with((this / "name").cast()) { + with((this / "name").cast()) { name equals "name" // TODO property name } @@ -117,19 +117,19 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 5 - with((this / "Companion").cast()) { + with((this / "Companion").cast()) { name equals "Companion" children counts 5 - with((this / "x").cast()) { + with((this / "x").cast()) { name equals "x" } - with((this / "foo").cast()) { + with((this / "foo").cast()) { name equals "foo" parameters counts 0 type.constructorFqName equals "kotlin.Unit" @@ -146,7 +146,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |data class Klass() {} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" visibility.values allEquals KotlinVisibility.Public with(extra[AdditionalModifiers.AdditionalKey].assertNotNull("Extras")) { @@ -170,7 +170,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |sealed class Klass() {} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" modifier equals KotlinModifier.Sealed } @@ -215,18 +215,18 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - val C = (this / "classes" / "C").cast() - val D = (this / "classes" / "D").cast() + val C = (this / "classes" / "C").cast() + val D = (this / "classes" / "D").cast() with(C) { modifier equals Open - with((this / "f").cast()) { + with((this / "f").cast()) { modifier equals Open } } with(D) { modifier equals Final - with((this / "f").cast()) { + with((this / "f").cast()) { modifier equals Open } D.supertypes.flatMap { it.component2() }.firstOrNull() equals C.dri @@ -249,13 +249,13 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - val C = (this / "classes" / "C").cast() - val D = (this / "classes" / "D").cast() - val E = (this / "classes" / "E").cast() + val C = (this / "classes" / "C").cast() + val D = (this / "classes" / "D").cast() + val E = (this / "classes" / "E").cast() with(C) { modifier equals Abstract - ((this / "foo").cast()).modifier equals Abstract + ((this / "foo").cast()).modifier equals Abstract } with(D) { @@ -280,9 +280,9 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "C").cast()) { + with((this / "classes" / "C").cast()) { - with((this / "D").cast()) { + with((this / "D").cast()) { } } } @@ -312,10 +312,10 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |val Klass.Default.x: Int get() = 1 """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" - with((this / "Default").cast()) { + with((this / "Default").cast()) { name equals "Default" // TODO extensions } @@ -342,7 +342,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "C").cast()) { + with((this / "classes" / "C").cast()) { name equals "C" constructors counts 2 @@ -384,14 +384,14 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" - with((this / "Companion").cast()) { + with((this / "Companion").cast()) { name equals "Companion" visibility.values allEquals KotlinVisibility.Private - with((this / "fn").cast()) { + with((this / "fn").cast()) { name equals "fn" parameters counts 0 receiver equals null diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt index d576cf49..055892af 100644 --- a/plugins/base/src/test/kotlin/model/CommentTest.kt +++ b/plugins/base/src/test/kotlin/model/CommentTest.kt @@ -1,6 +1,6 @@ package model -import org.jetbrains.dokka.model.Property +import org.jetbrains.dokka.model.DProperty import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.model.doc.Text import org.junit.Test @@ -28,7 +28,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val prop2 = "" """ ) { - with((this / "comment" / "prop1").cast()) { + with((this / "comment" / "prop1").cast()) { name equals "prop1" with(this.docs().firstOrNull()?.root.assertNotNull("Code")) { (children.firstOrNull() as? Text) @@ -37,7 +37,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme params["lang"] equals "brainfuck" } } - with((this / "comment" / "prop2").cast()) { + with((this / "comment" / "prop2").cast()) { name equals "prop2" comments() equals "a + b - c" } @@ -51,7 +51,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { name equals "property" comments() equals "" } @@ -68,7 +68,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme """ ) { val p = this - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "" } } @@ -87,7 +87,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc1\ndoc2 doc3" } } @@ -107,7 +107,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc1\ndoc2 doc3" } } @@ -121,7 +121,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc" } } @@ -136,7 +136,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc" } } @@ -151,7 +151,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc" } } @@ -168,7 +168,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: []" docs().find { it is CustomWrapperTag && it.name == "one" }.let { with(it.assertNotNull("'one' entry")) { @@ -188,7 +188,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals """it's "useful"""" } } @@ -205,7 +205,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: [section one]" } } @@ -224,7 +224,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: [section one]\ntwo: [section two]" } } @@ -243,7 +243,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: [line one line two]" } } @@ -290,7 +290,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |} """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { this } } diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt index 9554ad02..f3a7adc7 100644 --- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt +++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt @@ -1,7 +1,7 @@ package model -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.DFunction +import org.jetbrains.dokka.model.DPackage import org.junit.Test import utils.* @@ -17,7 +17,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |fun fn() {} """ ) { - with((this / "function" / "fn").cast()) { + with((this / "function" / "fn").cast()) { name equals "fn" type.constructorFqName equals "kotlin.Unit" this.children.assertCount(0, "Function children: ") @@ -39,7 +39,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |fun fn(i: Int) {} """ ) { - with((this / "function").cast()) { + with((this / "function").cast()) { val fn1 = functions.find { it.name == "fn" && it.parameters.isNullOrEmpty() }.assertNotNull("fn()") @@ -76,7 +76,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |fun String.fn(x: Int) {} """ ) { - with((this / "function").cast()) { + with((this / "function").cast()) { val fn1 = functions.find { it.name == "fn" && it.parameters.isNullOrEmpty() }.assertNotNull("fn()") @@ -114,7 +114,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |} """ ) { - with((this / "function" / "function").cast()) { + with((this / "function" / "function").cast()) { comments() equals "Multiline\nFunction Documentation" name equals "function" @@ -141,7 +141,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { // TODO add annotations - with((this / "function" / "f").cast()) { + with((this / "function" / "f").cast()) { assert(false) { "No annotation data" } } } @@ -162,7 +162,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { // TODO add data about inline - with((this / "function" / "f").cast()) { + with((this / "function" / "f").cast()) { assert(false) { "No inline data" } } } @@ -184,7 +184,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { // TODO add data about suspend - with((this / "function" / "f").cast()) { + with((this / "function" / "f").cast()) { assert(false) { "No suspend data" } } } diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt index ea454763..c2545e7a 100644 --- a/plugins/base/src/test/kotlin/model/JavaTest.kt +++ b/plugins/base/src/test/kotlin/model/JavaTest.kt @@ -1,8 +1,8 @@ package model import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.junit.Assert.assertTrue import org.junit.Test import utils.AbstractModelTest @@ -24,10 +24,10 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { name equals "Test" children counts 1 - with((this / "fn").cast()) { + with((this / "fn").cast()) { name equals "fn" this } @@ -82,7 +82,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test" / "fn").cast()) { + with((this / "java" / "Test" / "fn").cast()) { this } } @@ -108,7 +108,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |public class Foo extends Exception implements Cloneable {} """ ) { - with((this / "java" / "Foo").cast()) { + with((this / "java" / "Foo").cast()) { val sups = listOf("Exception", "Cloneable") assertTrue( "Foo must extend ${sups.joinToString(", ")}", @@ -128,11 +128,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { name equals "Test" children counts 1 - with((this / "arrayToString").cast()) { + with((this / "arrayToString").cast()) { name equals "arrayToString" type.constructorFqName equals "java.lang.String[]" with(parameters.firstOrNull().assertNotNull("parameters")) { @@ -153,7 +153,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Foo").cast()) { + with((this / "java" / "Foo").cast()) { this } } @@ -189,7 +189,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { name equals "Test" constructors counts 2 @@ -211,9 +211,9 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "InnerClass").cast()) { + with((this / "java" / "InnerClass").cast()) { children counts 1 - with((this / "D").cast()) { + with((this / "D").cast()) { name equals "D" children counts 0 } @@ -230,11 +230,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Foo").cast()) { + with((this / "java" / "Foo").cast()) { name equals "Foo" children counts 1 - with((this / "bar").cast()) { + with((this / "bar").cast()) { name equals "bar" with(parameters.firstOrNull().assertNotNull("parameter")) { name equals "x" @@ -255,15 +255,15 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { children counts 2 - with((this / "i").cast()) { + with((this / "i").cast()) { getter.assertNotNull("i.get") setter.assertNotNull("i.set") } - with((this / "s").cast()) { + with((this / "s").cast()) { getter.assertNotNull("s.get") setter.assertNotNull("s.set") @@ -344,11 +344,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "E").cast()) { + with((this / "java" / "E").cast()) { name equals "E" entries counts 1 - with((this / "Foo").cast()) { + with((this / "Foo").cast()) { name equals "Foo" } } diff --git a/plugins/base/src/test/kotlin/model/PackagesTest.kt b/plugins/base/src/test/kotlin/model/PackagesTest.kt index e19cc82d..008ae14d 100644 --- a/plugins/base/src/test/kotlin/model/PackagesTest.kt +++ b/plugins/base/src/test/kotlin/model/PackagesTest.kt @@ -1,6 +1,6 @@ package model -import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.DPackage import org.junit.Test import utils.AbstractModelTest @@ -14,7 +14,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "").cast()) { + with((this / "").cast()) { name equals "" children counts 0 } @@ -29,7 +29,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "simple").cast()) { + with((this / "simple").cast()) { name equals "simple" children counts 0 } @@ -44,7 +44,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "dot.name").cast()) { + with((this / "dot.name").cast()) { name equals "dot.name" children counts 0 } @@ -63,11 +63,11 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac prependPackage = false ) { children counts 2 - with((this / "dot.name").cast()) { + with((this / "dot.name").cast()) { name equals "dot.name" children counts 0 } - with((this / "simple").cast()) { + with((this / "simple").cast()) { name equals "simple" children counts 0 } @@ -85,7 +85,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac prependPackage = false ) { children counts 1 - with((this / "simple").cast()) { + with((this / "simple").cast()) { name equals "simple" children counts 0 } @@ -102,7 +102,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "simple.name").cast()) { + with((this / "simple.name").cast()) { name equals "simple.name" children counts 1 } diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt index e4ef0aec..d12e292b 100644 --- a/plugins/base/src/test/kotlin/model/PropertyTest.kt +++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt @@ -1,8 +1,8 @@ package model import org.jetbrains.dokka.model.KotlinVisibility -import org.jetbrains.dokka.model.Package -import org.jetbrains.dokka.model.Property +import org.jetbrains.dokka.model.DPackage +import org.jetbrains.dokka.model.DProperty import org.junit.Test import utils.AbstractModelTest import utils.assertNotNull @@ -15,7 +15,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro """ |val property = "test"""" ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { @@ -33,7 +33,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro |var property = "test" """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 setter.assertNotNull("Setter") @@ -53,7 +53,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro | get() = "test" """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { @@ -73,7 +73,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro | set(value) {} """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 setter.assertNotNull("Setter") @@ -93,7 +93,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro | get() = size() * 2 """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 with(receiver.assertNotNull("property receiver")) { @@ -120,15 +120,15 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro |} """ ) { - with((this / "property").cast()) { - with((this / "Foo" / "property").cast()) { + with((this / "property").cast()) { + with((this / "Foo" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { type.constructorFqName equals "kotlin.Int" } } - with((this / "Bar" / "property").cast()) { + with((this / "Bar" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt index 75c8e008..1e6f64c6 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -1,8 +1,6 @@ package utils -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.model.DModule abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { @@ -11,7 +9,7 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo platform: String = "jvm", targetList: List = listOf("jvm"), prependPackage: Boolean = true, - block: Module.() -> Unit + block: DModule.() -> Unit ) { val configuration = dokkaConfiguration { passes { diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 6913ba5b..bf86c1b1 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -1,13 +1,9 @@ package utils -import org.jetbrains.dokka.model.Class +import org.jetbrains.dokka.model.DClass import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Property import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest -import kotlin.reflect.KClass -import kotlin.reflect.full.safeCast @DslMarker annotation class TestDSL @@ -64,5 +60,5 @@ fun T?.assertNotNull(name: String = ""): T = this ?: throw AssertionError("$ fun T?.docs() = this?.documentation.orEmpty().values.flatMap { it.children } -val Class.supers +val DClass.supers get() = supertypes.flatMap{it.component2()} \ No newline at end of file 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 cf777e67..991ee07d 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -4,9 +4,9 @@ import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.withClass import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.name.ClassId @@ -21,21 +21,21 @@ private fun List.groupedByLocation() = } // TODO: first() does not look reasonable }) { it.second } -internal fun Package.asJava(): Package { +internal fun DPackage.asJava(): DPackage { @Suppress("UNCHECKED_CAST") val syntheticClasses = ((properties + functions) as List) .groupedByLocation() .map { (syntheticClassName, nodes) -> - Class( + DClass( dri = dri.withClass(syntheticClassName), name = syntheticClassName, - properties = nodes.filterIsInstance().map { it.asJava() }, + properties = nodes.filterIsInstance().map { it.asJava() }, constructors = emptyList(), functions = ( - nodes.filterIsInstance() + nodes.filterIsInstance() .map { it.javaAccessors() } + - nodes.filterIsInstance() - .map { it.asJava(syntheticClassName) }) as List, // TODO: methods are static and receiver is a param + nodes.filterIsInstance() + .map { it.asJava(syntheticClassName) }) as List, // TODO: methods are static and receiver is a param classlikes = emptyList(), sources = PlatformDependent.empty(), visibility = PlatformDependent( @@ -60,7 +60,7 @@ internal fun Package.asJava(): Package { ) } -internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: String? = null) = +internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: String? = null) = copy( dri = if (relocateToClass.isNullOrBlank()) { dri @@ -81,7 +81,7 @@ internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: Strin extra = if (isTopLevel) extra.plus(extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else extra ) -internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List = +internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List = listOfNotNull( getter?.copy( dri = if (relocateToClass.isNullOrBlank()) { @@ -122,7 +122,7 @@ internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass ) -internal fun Function.asJava(containingClassName: String): Function { +internal fun DFunction.asJava(containingClassName: String): DFunction { val newName = when { isConstructor -> containingClassName else -> name @@ -137,16 +137,16 @@ internal fun Function.asJava(containingClassName: String): Function { ) // TODO static if toplevel } -internal fun Classlike.asJava(): Classlike = when (this) { - is Class -> asJava() - is Enum -> asJava() - is Annotation -> asJava() - is Object -> asJava() - is Interface -> asJava() +internal fun DClasslike.asJava(): DClasslike = when (this) { + is DClass -> asJava() + is DEnum -> asJava() + is DAnnotation -> asJava() + is DObject -> asJava() + is DInterface -> asJava() else -> throw IllegalArgumentException("$this shouldn't be here") } -internal fun Class.asJava(): Class = copy( +internal fun DClass.asJava(): DClass = copy( constructors = constructors.map { it.asJava(name) }, functions = (functions + properties.map { it.getter } + properties.map { it.setter }).filterNotNull().map { it.asJava(name) @@ -160,7 +160,7 @@ internal fun Class.asJava(): Class = copy( modifier = if (modifier is KotlinModifier.Empty) JavaModifier.Final else modifier ) -private fun TypeParameter.asJava(): TypeParameter = copy( +private fun DTypeParameter.asJava(): DTypeParameter = copy( dri = dri.possiblyAsJava(), bounds = bounds.map { it.asJava() } ) @@ -175,7 +175,7 @@ private fun Bound.asJava(): Bound = when (this) { else -> this } -internal fun Enum.asJava(): Enum = copy( +internal fun DEnum.asJava(): DEnum = copy( constructors = constructors.map { it.asJava(name) }, functions = (functions + properties.map { it.getter } + properties.map { it.setter }).filterNotNull().map { it.asJava(name) @@ -188,12 +188,12 @@ internal fun Enum.asJava(): Enum = copy( // , entries = entries.map { it.asJava() } ) -internal fun Object.asJava(): Object = copy( +internal fun DObject.asJava(): DObject = copy( functions = (functions + properties.map { it.getter } + properties.map { it.setter }) .filterNotNull() .map { it.asJava(name.orEmpty()) }, properties = properties.map { it.asJava() } + - Property( + DProperty( name = "INSTANCE", modifier = JavaModifier.Final, dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())), @@ -209,7 +209,7 @@ internal fun Object.asJava(): Object = copy( getter = null, platformData = platformData, receiver = null, - extra = PropertyContainer.empty() + AdditionalModifiers(setOf(ExtraModifiers.STATIC)) + extra = PropertyContainer.empty() + AdditionalModifiers(setOf(ExtraModifiers.STATIC)) ), classlikes = classlikes.map { it.asJava() }, supertypes = supertypes.copy( @@ -217,7 +217,7 @@ internal fun Object.asJava(): Object = copy( ) ) -internal fun Interface.asJava(): Interface = copy( +internal fun DInterface.asJava(): DInterface = copy( functions = (functions + properties.map { it.getter } + properties.map { it.setter }) .filterNotNull() .map { it.asJava(name) }, @@ -229,13 +229,13 @@ internal fun Interface.asJava(): Interface = copy( ) ) -internal fun Annotation.asJava(): Annotation = copy( +internal fun DAnnotation.asJava(): DAnnotation = copy( properties = properties.map { it.asJava() }, constructors = emptyList(), classlikes = classlikes.map { it.asJava() } ) // TODO investigate if annotation class can have methods and properties not from constructor -internal fun Parameter.asJava(): Parameter = copy( +internal fun DParameter.asJava(): DParameter = copy( type = type.asJava(), name = if (name.isNullOrBlank()) "\$self" else name ) diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index 55dd7a97..0ec7d0af 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -5,9 +5,9 @@ import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentCon import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.sureClassNames import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode import org.jetbrains.dokka.pages.TextStyle @@ -22,28 +22,28 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge override fun signature(documentable: Documentable): ContentNode = when (documentable) { - is Function -> signature(documentable) - is Property -> signature(documentable) - is Classlike -> signature(documentable) - is TypeParameter -> signature(documentable) + is DFunction -> signature(documentable) + is DProperty -> signature(documentable) + is DClasslike -> signature(documentable) + is DTypeParameter -> signature(documentable) else -> throw NotImplementedError( "Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}" ) } - private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } - if (c is Class) { + if (c is DClass) { text(c.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ") } when (c) { - is Class -> text("class ") - is Interface -> text("interface ") - is Enum -> text("enum ") - is Object -> text("class ") - is Annotation -> text("@interface ") + is DClass -> text("class ") + is DInterface -> text("interface ") + is DEnum -> text("enum ") + is DObject -> text("class ") + is DAnnotation -> text("@interface ") } link(c.name!!, c.dri) if (c is WithGenerics) { @@ -60,11 +60,11 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge } } - private fun signature(p: Property) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(p: DProperty) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { signatureForProjection(p.type) } - private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { text(f.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ") val returnType = f.type signatureForProjection(returnType) @@ -82,7 +82,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge text(")") } - private fun signature(t: TypeParameter) = contentBuilder.contentFor(t) { + private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) { text(t.name.substringAfterLast(".")) list(t.bounds, prefix = " extends ") { signatureForProjection(it) diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt index 8f51e105..8b07670f 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt @@ -1,11 +1,11 @@ package org.jetbrains.dokka.kotlinAsJava.transformers import org.jetbrains.dokka.kotlinAsJava.converters.asJava -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer class KotlinAsJavaDocumentableTransformer : DocumentableTransformer { - override fun invoke(original: Module, context: DokkaContext): Module = + override fun invoke(original: DModule, context: DokkaContext): DModule = original.copy(packages = original.packages.map { it.asJava() }) } diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt index 641cc5f9..a0e3b709 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.testApi.testRunner import org.jetbrains.dokka.* -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.RootPageNode @@ -104,9 +104,9 @@ abstract class AbstractCoreTest { protected class TestBuilder { var analysisSetupStage: (Map) -> Unit = {} var pluginsSetupStage: (DokkaContext) -> Unit = {} - var documentablesCreationStage: (List) -> Unit = {} - var documentablesMergingStage: (Module) -> Unit = {} - var documentablesTransformationStage: (Module) -> Unit = {} + var documentablesCreationStage: (List) -> Unit = {} + var documentablesMergingStage: (DModule) -> Unit = {} + var documentablesTransformationStage: (DModule) -> Unit = {} var pagesGenerationStage: (ModulePageNode) -> Unit = {} var pagesTransformationStage: (RootPageNode) -> Unit = {} var renderingStage: (RootPageNode, DokkaContext) -> Unit = { a, b -> } @@ -216,9 +216,9 @@ abstract class AbstractCoreTest { data class TestMethods( val analysisSetupStage: (Map) -> Unit, val pluginsSetupStage: (DokkaContext) -> Unit, - val documentablesCreationStage: (List) -> Unit, - val documentablesMergingStage: (Module) -> Unit, - val documentablesTransformationStage: (Module) -> Unit, + val documentablesCreationStage: (List) -> Unit, + val documentablesMergingStage: (DModule) -> Unit, + val documentablesTransformationStage: (DModule) -> Unit, val pagesGenerationStage: (ModulePageNode) -> Unit, val pagesTransformationStage: (RootPageNode) -> Unit, val renderingStage: (RootPageNode, DokkaContext) -> Unit -- cgit