Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[K2] Reorganize project model for MPP #3236

Merged
merged 6 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
89 changes: 71 additions & 18 deletions plugins/base/src/test/kotlin/content/annotations/SinceKotlinTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*


Expand Down Expand Up @@ -125,30 +122,54 @@ class SinceKotlinTest : AbstractRenderingTest() {
val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/jvm/")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

analysisPlatform = "jvm"
}
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/native/")
analysisPlatform = "native"
}
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/common/")
analysisPlatform = "common"
}
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/js/")
analysisPlatform = "js"
}
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/wasm/")
analysisPlatform = "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 {
Expand Down Expand Up @@ -185,33 +206,65 @@ 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"
}
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/common/")
classpath = listOfNotNull(commonStdlibPath)
analysisPlatform = "common"
}
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/js/")
classpath = listOfNotNull(jsStdlibPath)
analysisPlatform = "js"
}
sourceSet {
sourceRoots = listOf("src/")
sourceRoots = listOf("src/wasm/")
analysisPlatform = "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 */
Expand All @@ -226,7 +279,7 @@ class SinceKotlinTest : AbstractRenderingTest() {
.children.filter { it.name == "ring" && it is DFunction } as List<DFunction>
with(funcs) {
val sinceKotlin = mapOf(
Platform.common to SinceKotlinVersion("1.3"),
// Platform.common to SinceKotlinVersion("1.3"),
Platform.jvm to SinceKotlinVersion("1.3"),
Platform.js to SinceKotlinVersion("1.3"),
Platform.native to SinceKotlinVersion("1.3"),
Expand All @@ -238,7 +291,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}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ class ContentForSeeAlsoTest : BaseAbstractTest() {
}
}

@OnlyDescriptorsMPP
@Test
fun `multiplatform class with seealso in few platforms`() {
testInline(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`() {

Expand Down Expand Up @@ -151,7 +150,7 @@ class LinkableContentTest : BaseAbstractTest() {
}
}

@OnlyDescriptorsMPP
@OnlyDescriptorsMPP("#3238")
@Test
fun `Samples multiplatform documentation`() {

Expand Down Expand Up @@ -286,15 +285,15 @@ class LinkableContentTest : BaseAbstractTest() {
sourceSets {
sourceSet {
analysisPlatform = "js"
sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map {
sourceRoots = listOf("jsMain").map {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths.get("$testDataDir/$it/kotlin").toString()
}
name = "js"
includes = listOf(Paths.get("$includesDir/include2.md").toString())
}
sourceSet {
analysisPlatform = "jvm"
sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map {
sourceRoots = listOf("jvmMain").map {
Paths.get("$testDataDir/$it/kotlin").toString()
}
name = "jvm"
Expand Down
11 changes: 9 additions & 2 deletions plugins/base/src/test/kotlin/model/InheritorsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,22 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt",
fun multiplatform() {
val configuration = dokkaConfiguration {
sourceSets {
val commonSourceSet = sourceSet {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions plugins/base/src/test/kotlin/signatures/SignatureTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -590,7 +589,6 @@ class SignatureTest : BaseAbstractTest() {
}
}

@OnlyDescriptorsMPP
@Test
fun `type with an actual typealias`() {
val writerPlugin = TestOutputWriterPlugin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,7 +70,6 @@ class SourceLinkTransformerTest : BaseAbstractTest() {
}
}

@OnlyDescriptorsMPP
@Test
fun `source link should be for actual typealias`() {
val mppConfiguration = dokkaConfiguration {
Expand Down
4 changes: 4 additions & 0 deletions subprojects/analysis-kotlin-symbols/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ 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
}

// TODO [beresnev] get rid of it
compileOnly(libs.kotlinx.coroutines.core)

}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -46,7 +46,7 @@ internal fun ModuleAndPackageDocumentationParsingContext(
}
MarkdownParser(
externalDri = { link ->
analyze(analysisContext.mainModule) {
analyze(sourceModule) {
resolveKDocTextLink(
link,
contextPsi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading
Loading