diff options
9 files changed, 88 insertions, 31 deletions
diff --git a/core/api/core.api b/core/api/core.api index 1e1dcbd3..7c74a922 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -1470,6 +1470,10 @@ public final class org/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers$ public static final field INSTANCE Lorg/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers$TailRec; } +public final class org/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers$Value : org/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers { + public static final field INSTANCE Lorg/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers$Value; +} + public final class org/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers$VarArg : org/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers { public static final field INSTANCE Lorg/jetbrains/dokka/model/ExtraModifiers$KotlinOnlyModifiers$VarArg; } diff --git a/core/src/main/kotlin/model/extraModifiers.kt b/core/src/main/kotlin/model/extraModifiers.kt index efaa3d60..d52408d1 100644 --- a/core/src/main/kotlin/model/extraModifiers.kt +++ b/core/src/main/kotlin/model/extraModifiers.kt @@ -4,6 +4,7 @@ sealed class ExtraModifiers(val name: String) { sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) { object Inline : KotlinOnlyModifiers("inline") + object Value : KotlinOnlyModifiers("value") object Infix : KotlinOnlyModifiers("infix") object External : KotlinOnlyModifiers("external") object Suspend : KotlinOnlyModifiers("suspend") @@ -34,6 +35,7 @@ sealed class ExtraModifiers(val name: String) { companion object { fun valueOf(str: String) = when (str) { "inline" -> KotlinOnlyModifiers.Inline + "value" -> KotlinOnlyModifiers.Value "infix" -> KotlinOnlyModifiers.Infix "external" -> KotlinOnlyModifiers.External "suspend" -> KotlinOnlyModifiers.Suspend diff --git a/gradle.properties b/gradle.properties index 88b1fdcc..346b5a80 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ # Project Settings -dokka_version_base=1.5 +dokka_version_base=1.5.0 dokka_publication_channels=bintray-kotlin-dev&space-dokka-dev dokka_integration_test_parallelism=2 # Versions -kotlin_version=1.4.32 -coroutines_version=1.4.1 +kotlin_version=1.5.0 +coroutines_version=1.4.3 kotlinx_html_version=0.7.3 -kotlin_plugin_version=212-1.4.32-release-IJ1314 +kotlin_plugin_version=202-1.5.0-release-755-release-IJ8194.7 idea_version=202.7660.26 language_version=1.4 # Code style diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt index 41bf4fb3..30f1f1fb 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt @@ -367,8 +367,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl LanguageVersionSettingsImpl.DEFAULT ) - override fun sdkDependency(module: ModuleInfo, ownerModuleDescriptor: ModuleDescriptorImpl?): ModuleInfo? = - null + override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null } } @@ -398,8 +397,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl override fun builtInsForModule(module: ModuleInfo): KotlinBuiltIns = DefaultBuiltIns.Instance - override fun sdkDependency(module: ModuleInfo, ownerModuleDescriptor: ModuleDescriptorImpl?): ModuleInfo? = - null + override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null } } @@ -430,8 +428,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl override fun builtInsForModule(module: ModuleInfo): KotlinBuiltIns = DefaultBuiltIns.Instance - override fun sdkDependency(module: ModuleInfo, ownerModuleDescriptor: ModuleDescriptorImpl?): ModuleInfo? = - null + override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null } } @@ -470,7 +467,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl descriptor: ModuleDescriptor, moduleInfo: ModuleInfo ): ResolverForModule = JvmResolverForModuleFactory( - JvmPlatformParameters({ content -> + JvmPlatformParameters(packagePartProviderFactory = { content -> JvmPackagePartProvider( configuration.languageVersionSettings, content.moduleContentScope @@ -478,14 +475,15 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl .apply { addRoots(javaRoots, messageCollector) } - }, { + }, moduleByJavaClass = { val file = (it as? BinaryJavaClass)?.virtualFile ?: (it as JavaClassImpl).psi.containingFile.virtualFile if (file in sourcesScope) module else library - }), + }, resolverForReferencedModule = null, + useBuiltinsProviderForModule = { false }), CompilerEnvironment, unspecifiedJvmPlatform ).createResolverForModule( @@ -496,8 +494,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl LanguageVersionSettingsImpl.DEFAULT ) - override fun sdkDependency(module: ModuleInfo, ownerModuleDescriptor: ModuleDescriptorImpl?): ModuleInfo? = - null + override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null } } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt index 68415875..bebbc705 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt @@ -4,6 +4,7 @@ import com.intellij.psi.PsiFile import org.jetbrains.dokka.analysis.DokkaResolutionFacade import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.caches.resolve.KotlinCacheService +import org.jetbrains.kotlin.caches.resolve.PlatformAnalysisSettings import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache @@ -30,6 +31,13 @@ class CoreKotlinCacheService(private val resolutionFacade: DokkaResolutionFacade override fun getResolutionFacadeByModuleInfo( moduleInfo: ModuleInfo, + settings: PlatformAnalysisSettings + ): ResolutionFacade? { + return resolutionFacade + } + + override fun getResolutionFacadeByModuleInfo( + moduleInfo: ModuleInfo, platform: org.jetbrains.kotlin.platform.TargetPlatform ): ResolutionFacade? { return resolutionFacade diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt index 2c19fb9f..c0fafc25 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.container.getService import org.jetbrains.kotlin.container.tryGetService import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.idea.FrontendInternals import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.psi.KtDeclaration @@ -33,7 +34,10 @@ class DokkaResolutionFacade( override val moduleDescriptor: ModuleDescriptor, val resolverForModule: ResolverForModule ) : ResolutionFacade { - override fun analyzeWithAllCompilerChecks(elements: Collection<KtElement>): AnalysisResult { + override fun analyzeWithAllCompilerChecks( + elements: Collection<KtElement>, + callback: DiagnosticSink.DiagnosticsCallback? + ): AnalysisResult { throw UnsupportedOperationException() } diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 4ddd2d39..92ffd9b6 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -901,10 +901,11 @@ private class DokkaDescriptorVisitor( private fun ClassDescriptor.additionalExtras() = listOfNotNull( ExtraModifiers.KotlinOnlyModifiers.Inline.takeIf { isInline }, + ExtraModifiers.KotlinOnlyModifiers.Value.takeIf { isValue }, ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal }, ExtraModifiers.KotlinOnlyModifiers.Inner.takeIf { isInner }, ExtraModifiers.KotlinOnlyModifiers.Data.takeIf { isData }, - ExtraModifiers.KotlinOnlyModifiers.Fun.takeIf { isFun } + ExtraModifiers.KotlinOnlyModifiers.Fun.takeIf { isFun }, ).toSet() private fun ValueParameterDescriptor.additionalExtras() = listOfNotNull( diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index 34857ad8..b05ed4fb 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -553,4 +553,38 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class } } } + + @Test + fun `inline classes`() { + inlineModelTest( + """ + | inline class X(val example: String) + | + | @JvmInline + | value class InlineTest(val x: String) + """.trimMargin() + ) { + val classlike = packages.flatMap { it.classlikes }.first() as DClass + classlike.name equals "X" + classlike.properties.first().name equals "example" + classlike.extra[AdditionalModifiers]?.content?.values?.firstOrNull() + ?.firstOrNull() equals ExtraModifiers.KotlinOnlyModifiers.Inline + } + } + + @Test + fun `value classes`() { + inlineModelTest( + """ + | @JvmInline + | value class InlineTest(val example: String) + """.trimMargin() + ) { + val classlike = packages.flatMap { it.classlikes }.first() as DClass + classlike.name equals "InlineTest" + classlike.properties.first().name equals "example" + classlike.extra[AdditionalModifiers]?.content?.values?.firstOrNull() + ?.firstOrNull() equals ExtraModifiers.KotlinOnlyModifiers.Value + } + } } diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index 503cf50c..2b0aff62 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -1,33 +1,22 @@ package model -import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.base.transformers.documentables.InheritorsExtractorTransformer import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo +import org.jetbrains.dokka.model.DClass import org.jetbrains.dokka.model.DInterface -import org.jetbrains.dokka.plugability.DokkaPlugin import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", "inheritors") { - object InheritorsPlugin : DokkaPlugin() { - val inheritors by extending { - CoreExtensions.documentableTransformer with InheritorsExtractorTransformer() - } - } - - @Disabled("reenable after fixing subtypes") @Test fun simple() { inlineModelTest( """|interface A{} |class B() : A {} """.trimMargin(), - pluginsOverrides = listOf(InheritorsPlugin) ) { with((this / "inheritors" / "A").cast<DInterface>()) { val map = extra[InheritorsInfo].assertNotNull("InheritorsInfo").value @@ -40,7 +29,26 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", } } - @Disabled("reenable after fixing subtypes") + @Test + fun sealed() { + inlineModelTest( + """|sealed class A {} + |class B() : A() {} + |class C() : A() {} + |class D() + """.trimMargin(), + ) { + with((this / "inheritors" / "A").cast<DClass>()) { + val map = extra[InheritorsInfo].assertNotNull("InheritorsInfo").value + with(map.keys.also { it counts 1 }.find { it.analysisPlatform == Platform.jvm }.assertNotNull("jvm key").let { map[it]!! } + ) { + this counts 2 + mapNotNull { it.classNames }.sorted() equals listOf("B", "C") + } + } + } + } + @Test fun multiplatform() { val configuration = dokkaConfiguration { @@ -71,7 +79,6 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", """.trimMargin(), configuration, cleanupOutput = false, - pluginOverrides = listOf(InheritorsPlugin) ) { documentablesTransformationStage = { m -> with((m / "inheritors" / "A").cast<DInterface>()) { |