aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gradle/libs.versions.toml2
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/SinceKotlinTest.kt95
-rw-r--r--plugins/base/src/test/kotlin/content/exceptions/ContentForExceptions.kt1
-rw-r--r--plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt1
-rw-r--r--plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt9
-rw-r--r--plugins/base/src/test/kotlin/model/InheritorsTest.kt11
-rw-r--r--plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt4
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt2
-rw-r--r--subprojects/analysis-kotlin-symbols/build.gradle.kts4
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/java/KotlinDocCommentParser.kt2
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationParsingContext.kt6
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationReader.kt2
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/AnalysisContext.kt135
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/KotlinAnalysis.kt132
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/KotlinAnalysisProjectProvider.kt2
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/KotlinSampleProvider.kt21
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolExternalDocumentablesProvider.kt5
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolFullClassHierarchyBuilder.kt2
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DRIFactory.kt2
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DefaultSymbolToDocumentableTranslator.kt10
22 files changed, 246 insertions, 206 deletions
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 9a25490b..c7202839 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -11,7 +11,7 @@ kotlinx-bcv = "0.13.2"
## Analysis
kotlin-compiler = "1.9.10"
-kotlin-compiler-k2 = "1.9.30-dev-3330"
+kotlin-compiler-k2 = "2.0.0-dev-5387"
# MUST match the version of the intellij platform used in the kotlin compiler,
# otherwise this will lead to different versions of psi API and implementations
diff --git a/plugins/base/src/test/kotlin/content/annotations/SinceKotlinTest.kt b/plugins/base/src/test/kotlin/content/annotations/SinceKotlinTest.kt
index 4cb25704..6ee95bbd 100644
--- a/plugins/base/src/test/kotlin/content/annotations/SinceKotlinTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/SinceKotlinTest.kt
@@ -14,10 +14,7 @@ import org.jetbrains.dokka.model.doc.CustomTagWrapper
import org.jetbrains.dokka.model.doc.Text
import org.jetbrains.dokka.pages.ContentPage
import signatures.AbstractRenderingTest
-import utils.ParamAttributes
-import utils.TestOutputWriterPlugin
-import utils.assertNotNull
-import utils.bareSignature
+import utils.*
import kotlin.test.*
@@ -125,30 +122,58 @@ class SinceKotlinTest : AbstractRenderingTest() {
val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/jvm/")
analysisPlatform = "jvm"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/native/")
analysisPlatform = "native"
+ name = "native"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/common/")
analysisPlatform = "common"
+ name = "common"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/js/")
analysisPlatform = "js"
+ name = "js"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/wasm/")
analysisPlatform = "wasm"
+ name = "wasm"
}
}
}
testInline(
"""
- |/src/main/kotlin/test/source.kt
+ |/src/jvm/kotlin/test/source.kt
+ |package test
+ |
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/native/kotlin/test/source.kt
+ |package test
+ |
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/common/kotlin/test/source.kt
+ |package test
+ |
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/js/kotlin/test/source.kt
+ |package test
+ |
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/wasm/kotlin/test/source.kt
|package test
|
|fun ring(abc: String): String {
@@ -185,33 +210,69 @@ class SinceKotlinTest : AbstractRenderingTest() {
val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/jvm/")
classpath = listOfNotNull(jvmStdlibPath)
analysisPlatform = "jvm"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/native/")
analysisPlatform = "native"
+ name = "native"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/common/")
classpath = listOfNotNull(commonStdlibPath)
analysisPlatform = "common"
+ name = "common"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/js/")
classpath = listOfNotNull(jsStdlibPath)
analysisPlatform = "js"
+ name = "js"
}
sourceSet {
- sourceRoots = listOf("src/")
+ sourceRoots = listOf("src/wasm/")
analysisPlatform = "wasm"
+ name = "wasm"
}
}
}
testInline(
"""
- |/src/main/kotlin/test/source.kt
+ |/src/jvm/kotlin/test/source.kt
+ |package test
+ |
+ |/** dssdd */
+ |@SinceKotlin("1.3")
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/native/kotlin/test/source.kt
+ |package test
+ |
+ |/** dssdd */
+ |@SinceKotlin("1.3")
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/common/kotlin/test/source.kt
+ |package test
+ |
+ |/** dssdd */
+ |@SinceKotlin("1.3")
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/js/kotlin/test/source.kt
+ |package test
+ |
+ |/** dssdd */
+ |@SinceKotlin("1.3")
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ |/src/wasm/kotlin/test/source.kt
|package test
|
|/** dssdd */
@@ -238,7 +299,7 @@ class SinceKotlinTest : AbstractRenderingTest() {
find { it.sourceSets.first().analysisPlatform == i.key }?.documentation?.values?.first()
?.dfs { it is CustomTagWrapper && it.name == "Since Kotlin" }
.assertNotNull("SinceKotlin[${i.key}]")
- assertEquals((tag.children.first() as Text).body, i.value.toString())
+ assertEquals(i.value.toString(), (tag.children.first() as Text).body , "Platform ${i.key}")
}
}
}
diff --git a/plugins/base/src/test/kotlin/content/exceptions/ContentForExceptions.kt b/plugins/base/src/test/kotlin/content/exceptions/ContentForExceptions.kt
index 9a9fd8b4..22becb93 100644
--- a/plugins/base/src/test/kotlin/content/exceptions/ContentForExceptions.kt
+++ b/plugins/base/src/test/kotlin/content/exceptions/ContentForExceptions.kt
@@ -339,7 +339,6 @@ class ContentForExceptions : BaseAbstractTest() {
}
}
- @OnlyDescriptorsMPP("Return type for native `function` should be null rather than kotlin/Unit")
@Test
fun `throws in merged functions`() {
testInline(
diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt
index 2790d8b6..fb72178b 100644
--- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt
+++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt
@@ -759,7 +759,6 @@ class ContentForSeeAlsoTest : BaseAbstractTest() {
}
}
- @OnlyDescriptorsMPP
@Test
fun `multiplatform class with seealso in few platforms`() {
testInline(
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index 504a1ebe..1b73ffee 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -20,12 +20,11 @@ import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.test.assertNotNull
-import utils.OnlyDescriptors
import utils.OnlyDescriptorsMPP
class LinkableContentTest : BaseAbstractTest() {
- @OnlyDescriptorsMPP
+ @OnlyDescriptorsMPP("#3238")
@Test
fun `Include module and package documentation`() {
@@ -151,7 +150,7 @@ class LinkableContentTest : BaseAbstractTest() {
}
}
- @OnlyDescriptorsMPP
+ @OnlyDescriptorsMPP("#3238")
@Test
fun `Samples multiplatform documentation`() {
@@ -286,7 +285,7 @@ class LinkableContentTest : BaseAbstractTest() {
sourceSets {
sourceSet {
analysisPlatform = "js"
- sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map {
+ sourceRoots = listOf("jsMain").map {
Paths.get("$testDataDir/$it/kotlin").toString()
}
name = "js"
@@ -294,7 +293,7 @@ class LinkableContentTest : BaseAbstractTest() {
}
sourceSet {
analysisPlatform = "jvm"
- sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map {
+ sourceRoots = listOf("jvmMain").map {
Paths.get("$testDataDir/$it/kotlin").toString()
}
name = "jvm"
diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt
index 5c8e7c74..459dd9ac 100644
--- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt
+++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt
@@ -60,15 +60,22 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt",
fun multiplatform() {
val configuration = dokkaConfiguration {
sourceSets {
+ val commonSourceSet = sourceSet {
+ name = "common"
+ sourceRoots = listOf("common/src/")
+ analysisPlatform = "common"
+ }
sourceSet {
name = "jvm"
- sourceRoots = listOf("common/src/", "jvm/src/")
+ sourceRoots = listOf("jvm/src/")
analysisPlatform = "jvm"
+ dependentSourceSets = setOf(commonSourceSet.value.sourceSetID)
}
sourceSet {
name = "js"
- sourceRoots = listOf("common/src/", "js/src/")
+ sourceRoots = listOf("js/src/")
analysisPlatform = "js"
+ dependentSourceSets = setOf(commonSourceSet.value.sourceSetID)
}
}
}
diff --git a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
index 45a5523f..509dd6e7 100644
--- a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
@@ -7,10 +7,8 @@ package signatures
import utils.TestOutputWriterPlugin
import kotlin.test.Test
import kotlin.test.assertEquals
-import utils.OnlyDescriptors
-import utils.OnlyDescriptorsMPP
-@OnlyDescriptorsMPP
+
class DivergentSignatureTest : AbstractRenderingTest() {
@Test
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index 37efd6df..80a043fe 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -555,7 +555,6 @@ class SignatureTest : BaseAbstractTest() {
}
}
}
- @OnlyDescriptorsMPP
@Test
fun `actual typealias should have generic parameters and fully qualified name of the expansion type`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -590,7 +589,6 @@ class SignatureTest : BaseAbstractTest() {
}
}
- @OnlyDescriptorsMPP
@Test
fun `type with an actual typealias`() {
val writerPlugin = TestOutputWriterPlugin()
diff --git a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt
index 85ba5ba4..54f0120a 100644
--- a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt
+++ b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt
@@ -15,7 +15,7 @@ import kotlin.test.assertEquals
class ModuleAndPackageDocumentationTransformerFunctionalTest : BaseAbstractTest() {
- @OnlyDescriptorsMPP
+ @OnlyDescriptorsMPP("#3238")
@Test
fun `multiplatform project`(@TempDir tempDir: Path) {
val include = tempDir.resolve("include.md").toFile()
diff --git a/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt
index c23a0885..87424120 100644
--- a/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt
+++ b/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt
@@ -9,7 +9,6 @@ import org.jetbrains.dokka.SourceLinkDefinitionImpl
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jsoup.nodes.Element
import signatures.renderedContent
-import utils.OnlyDescriptorsMPP
import utils.TestOutputWriterPlugin
import java.net.URL
import kotlin.test.Test
@@ -71,7 +70,6 @@ class SourceLinkTransformerTest : BaseAbstractTest() {
}
}
- @OnlyDescriptorsMPP
@Test
fun `source link should be for actual typealias`() {
val mppConfiguration = dokkaConfiguration {
diff --git a/subprojects/analysis-kotlin-symbols/build.gradle.kts b/subprojects/analysis-kotlin-symbols/build.gradle.kts
index 6733b778..b6626f92 100644
--- a/subprojects/analysis-kotlin-symbols/build.gradle.kts
+++ b/subprojects/analysis-kotlin-symbols/build.gradle.kts
@@ -72,6 +72,9 @@ dependencies {
isTransitive = false // see KTIJ-19820
}
}
+ // copy-pasted from Analysis API https://github.com/JetBrains/kotlin/blob/a10042f9099e20a656dec3ecf1665eea340a3633/analysis/low-level-api-fir/build.gradle.kts#L37
+ runtimeOnly("com.github.ben-manes.caffeine:caffeine:2.9.3")
+
runtimeOnly(libs.kotlinx.collections.immutable)
implementation(libs.kotlin.compiler.k2) {
isTransitive = false
@@ -79,6 +82,7 @@ dependencies {
// TODO [beresnev] get rid of it
compileOnly(libs.kotlinx.coroutines.core)
+
}
tasks {
diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/java/KotlinDocCommentParser.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/java/KotlinDocCommentParser.kt
index 33cc4305..0ee95e45 100644
--- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/java/KotlinDocCommentParser.kt
+++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/java/KotlinDocCommentParser.kt
@@ -39,7 +39,7 @@ internal class KotlinDocCommentParser(
}
val kotlinAnalysis = context.plugin<SymbolsAnalysisPlugin>().querySingle { kotlinAnalysis }
val elementName = element.resolveDocContext.ktElement.name
- return analyze(kotlinAnalysis[sourceSet].mainModule) {
+ return analyze(kotlinAnalysis.getModule(sourceSet)) {
parseFromKDocTag(
kDocTag = element.comment,
externalDri = { link -> resolveKDocLink(link).ifUnresolved { context.logger.logUnresolvedLink(link.getLinkText(), elementName) } },
diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationParsingContext.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationParsingContext.kt
index ef59aa33..f5cfbdb9 100644
--- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationParsingContext.kt
+++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationParsingContext.kt
@@ -36,8 +36,8 @@ internal fun ModuleAndPackageDocumentationParsingContext(
if (kotlinAnalysis == null || sourceSet == null) {
MarkdownParser(externalDri = { null }, sourceLocation)
} else {
- val analysisContext = kotlinAnalysis[sourceSet]
- val contextPsi = analyze(analysisContext.mainModule) {
+ val sourceModule = kotlinAnalysis.getModule(sourceSet)
+ val contextPsi = analyze(sourceModule) {
val contextSymbol = when (fragment.classifier) {
Module -> ROOT_PACKAGE_SYMBOL
Package -> getPackageSymbolIfPackageExists(FqName(fragment.name))
@@ -46,7 +46,7 @@ internal fun ModuleAndPackageDocumentationParsingContext(
}
MarkdownParser(
externalDri = { link ->
- analyze(analysisContext.mainModule) {
+ analyze(sourceModule) {
resolveKDocTextLink(
link,
contextPsi
diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationReader.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationReader.kt
index c581c7a8..ef79e885 100644
--- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationReader.kt
+++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/moduledocs/ModuleAndPackageDocumentationReader.kt
@@ -38,7 +38,7 @@ private class ContextModuleAndPackageDocumentationReader(
): SourceSetDependent<DocumentationNode> {
return sourceSets.associateWithNotNull { sourceSet ->
val fragments = documentationFragments[sourceSet].orEmpty().filter(predicate)
- kotlinAnalysis[sourceSet] // test: to throw exception for unknown sourceSet
+ kotlinAnalysis.getModule(sourceSet)// test: to throw exception for unknown sourceSet
val documentations = fragments.map { fragment ->
parseModuleAndPackageDocumentation(
context = ModuleAndPackageDocumentationParsingContext(context.logger, kotlinAnalysis, sourceSet),
diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/AnalysisContext.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/AnalysisContext.kt
index cf57e815..191c5f92 100644
--- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/AnalysisContext.kt
+++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/AnalysisContext.kt
@@ -5,140 +5,49 @@
package org.jetbrains.dokka.analysis.kotlin.symbols.plugin
import com.intellij.openapi.Disposable
-import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.model.SourceSetDependent
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.kotlin.analysis.api.standalone.StandaloneAnalysisAPISession
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
import java.io.Closeable
-import java.io.File
-@Suppress("FunctionName", "UNUSED_PARAMETER")
internal fun SamplesKotlinAnalysis(
sourceSets: List<DokkaConfiguration.DokkaSourceSet>,
context: DokkaContext,
- projectKotlinAnalysis: KotlinAnalysis
-): KotlinAnalysis {
- val environments = sourceSets
- .filter { it.samples.isNotEmpty() }
- .associateWith { sourceSet ->
- createAnalysisContext(
- classpath = sourceSet.classpath,
- sourceRoots = sourceSet.samples,
- sourceSet = sourceSet
- )
- }
-
- return EnvironmentKotlinAnalysis(environments, projectKotlinAnalysis)
-}
+): KotlinAnalysis = createAnalysisSession(
+ sourceSets = sourceSets,
+ logger = context.logger,
+ isSampleProject = true
+)
internal fun ProjectKotlinAnalysis(
sourceSets: List<DokkaConfiguration.DokkaSourceSet>,
context: DokkaContext,
-): KotlinAnalysis {
- val environments = sourceSets.associateWith { sourceSet ->
- createAnalysisContext(
- context = context,
- sourceSets = sourceSets,
- sourceSet = sourceSet
- )
- }
- return EnvironmentKotlinAnalysis(environments)
-}
-
-
-@Suppress("UNUSED_PARAMETER")
-internal fun createAnalysisContext(
- context: DokkaContext,
- sourceSets: List<DokkaConfiguration.DokkaSourceSet>,
- sourceSet: DokkaConfiguration.DokkaSourceSet
-): AnalysisContext {
- val parentSourceSets = sourceSets.filter { it.sourceSetID in sourceSet.dependentSourceSets }
- val classpath = sourceSet.classpath + parentSourceSets.flatMap { it.classpath }
- val sources = sourceSet.sourceRoots + parentSourceSets.flatMap { it.sourceRoots }
-
- return createAnalysisContext(classpath, sources, sourceSet)
-}
-
-internal fun createAnalysisContext(
- classpath: List<File>,
- sourceRoots: Set<File>,
- sourceSet: DokkaConfiguration.DokkaSourceSet
-): AnalysisContext {
- val applicationDisposable: Disposable = Disposer.newDisposable("StandaloneAnalysisAPISession.application")
- val projectDisposable: Disposable = Disposer.newDisposable("StandaloneAnalysisAPISession.project")
-
- val analysis= createAnalysisSession(
- classpath = classpath,
- sourceRoots = sourceRoots,
- analysisPlatform = sourceSet.analysisPlatform,
- languageVersion = sourceSet.languageVersion,
- apiVersion = sourceSet.apiVersion,
- applicationDisposable = applicationDisposable,
- projectDisposable = projectDisposable
- )
- return AnalysisContextImpl(
- mainModule = analysis.second,
- analysisSession = analysis.first,
- applicationDisposable = applicationDisposable,
- projectDisposable = projectDisposable
- )
-}
-
-
-/**
- * First child delegation. It does not close [parent].
- */
-internal abstract class KotlinAnalysis(
- private val parent: KotlinAnalysis? = null
+): KotlinAnalysis = createAnalysisSession(
+ sourceSets = sourceSets,
+ logger = context.logger
+)
+
+internal class KotlinAnalysis(
+ private val sourceModules: SourceSetDependent<KtSourceModule>,
+ private val analysisSession: StandaloneAnalysisAPISession,
+ private val applicationDisposable: Disposable,
+ private val projectDisposable: Disposable
) : Closeable {
- operator fun get(key: DokkaConfiguration.DokkaSourceSet): AnalysisContext {
- return get(key.sourceSetID)
- }
-
- internal operator fun get(key: DokkaSourceSetID): AnalysisContext {
- return find(key)
- ?: parent?.get(key)
- ?: throw IllegalStateException("Missing EnvironmentAndFacade for sourceSet $key")
- }
-
- internal abstract fun find(sourceSetID: DokkaSourceSetID): AnalysisContext?
-}
-
-internal open class EnvironmentKotlinAnalysis(
- private val environments: SourceSetDependent<AnalysisContext>,
- parent: KotlinAnalysis? = null,
-) : KotlinAnalysis(parent = parent) {
+ fun getModule(sourceSet: DokkaConfiguration.DokkaSourceSet) =
+ sourceModules[sourceSet] ?: error("Missing a source module for sourceSet ${sourceSet.displayName} with id ${sourceSet.sourceSetID}")
- override fun find(sourceSetID: DokkaSourceSetID): AnalysisContext? =
- environments.entries.firstOrNull { (sourceSet, _) -> sourceSet.sourceSetID == sourceSetID }?.value
+ fun getModuleOrNull(sourceSet: DokkaConfiguration.DokkaSourceSet) =
+ sourceModules[sourceSet]
- override fun close() {
- environments.values.forEach(AnalysisContext::close)
- }
-}
-
-internal interface AnalysisContext: Closeable {
- val project: Project
- val mainModule: KtSourceModule
- val analysisSession: StandaloneAnalysisAPISession
-}
-
-private class AnalysisContextImpl(
- override val mainModule: KtSourceModule,
- override val analysisSession: StandaloneAnalysisAPISession,
- private val applicationDisposable: Disposable,
- private val projectDisposable: Disposable
-) : AnalysisContext {
- override val project: Project
- get() = analysisSession.project
+ val modulesWithFiles
+ get() = analysisSession.modulesWithFiles
override fun close() {
Disposer.dispose(applicationDisposable)
Disposer.dispose(projectDisposable)
}
-}
+} \ No newline at end of file
diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/KotlinAnalysis.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/KotlinAnalysis.kt
index a6155fb0..e074a142 100644
--- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/KotlinAnalysis.kt
+++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/KotlinAnalysis.kt
@@ -5,11 +5,14 @@
package org.jetbrains.dokka.analysis.kotlin.symbols.plugin
import com.intellij.openapi.Disposable
+import com.intellij.openapi.util.Disposer
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.Platform
+import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeTokenProvider
import org.jetbrains.kotlin.analysis.api.standalone.KtAlwaysAccessibleLifetimeTokenProvider
-import org.jetbrains.kotlin.analysis.api.standalone.StandaloneAnalysisAPISession
import org.jetbrains.kotlin.analysis.api.standalone.buildStandaloneAnalysisAPISession
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
import org.jetbrains.kotlin.analysis.project.structure.builder.KtModuleBuilder
@@ -30,10 +33,10 @@ internal fun Platform.toTargetPlatform() = when (this) {
Platform.jvm -> JvmPlatforms.defaultJvmPlatform
}
-private fun getJdkHomeFromSystemProperty(): File? {
+private fun getJdkHomeFromSystemProperty(logger: DokkaLogger): File? {
val javaHome = File(System.getProperty("java.home"))