aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/signatures
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2023-08-28 19:42:21 +0300
committerGitHub <noreply@github.com>2023-08-28 19:42:21 +0300
commit0e00edc6fcd406fcf38673ef6a2f8f59e8374de2 (patch)
tree697b0de0d44b421c922f1f5e6a7c1352f17c68a6 /plugins/base/src/test/kotlin/signatures
parentbec2cac91726e52884329e7997207e9777abaab7 (diff)
downloaddokka-0e00edc6fcd406fcf38673ef6a2f8f59e8374de2.tar.gz
dokka-0e00edc6fcd406fcf38673ef6a2f8f59e8374de2.tar.bz2
dokka-0e00edc6fcd406fcf38673ef6a2f8f59e8374de2.zip
Support Dokka K2 analysis (#3094)
Dokka has its own documentable model to represent analyzed code. The analysis is performed by a compiler frontend. In K1 the compiler frontend has descriptors that use the underlying Binding Context (global shared stateful structure). Dokka just maps descriptors to Documentable by DefaultDescriptorToDocumentableTranslator. K2 compiler has FIR tree, which means “Frontend Intermediate Representation”, instead of Binding Context. But we do not use FIR in Dokka directly, since it is too low-level for analysis. The Kotlin compiler provides high-level Analysis API for this case. The API is used by KSP too. Analysis API represent elements of FIR (declarations, parameters and so on) as Symbols. For more details see KtSymbolByFirBuilder, KtSymbol. For Dokka symbol is the replacement of descriptor in K2. Also, to set up the environment of project analysis in K1 we use idea dependencies (or copy-past from there). In K2 for these aims, there is a Standalone mode for Analysis API.
Diffstat (limited to 'plugins/base/src/test/kotlin/signatures')
-rw-r--r--plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt3
-rw-r--r--plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt7
-rw-r--r--plugins/base/src/test/kotlin/signatures/InheritedAccessorsSignatureTest.kt13
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt4
4 files changed, 19 insertions, 8 deletions
diff --git a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
index ca287216..af10cbee 100644
--- a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
@@ -1,8 +1,11 @@
package signatures
import org.junit.jupiter.api.Test
+import utils.OnlyDescriptors
+import utils.OnlyDescriptorsMPP
import utils.TestOutputWriterPlugin
+@OnlyDescriptorsMPP
class DivergentSignatureTest : AbstractRenderingTest() {
@Test
diff --git a/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt
index c9787b67..588b3d50 100644
--- a/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt
@@ -5,10 +5,7 @@ import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.jdk
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
-import utils.A
-import utils.Span
-import utils.TestOutputWriterPlugin
-import utils.match
+import utils.*
class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
private val configuration = dokkaConfiguration {
@@ -254,6 +251,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
}
}
+ @JavaCode
@Test
fun `java with java function`() {
val source = """
@@ -280,6 +278,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
}
}
+ @JavaCode
@Test
fun `java with kotlin function`() {
val source = """
diff --git a/plugins/base/src/test/kotlin/signatures/InheritedAccessorsSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/InheritedAccessorsSignatureTest.kt
index 0767b2df..4cd9a94d 100644
--- a/plugins/base/src/test/kotlin/signatures/InheritedAccessorsSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/InheritedAccessorsSignatureTest.kt
@@ -3,12 +3,10 @@ package signatures
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.junit.jupiter.api.Test
-import utils.A
-import utils.Span
-import utils.TestOutputWriterPlugin
-import utils.match
+import utils.*
import kotlin.test.assertEquals
+@JavaCode
class InheritedAccessorsSignatureTest : BaseAbstractTest() {
private val configuration = dokkaConfiguration {
@@ -24,6 +22,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptors("'var' expected but found: 'open var'")
@Test
fun `should collapse accessor functions inherited from java into the property`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -76,6 +75,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptors("'var' expected but found: 'open var'")
@Test
fun `should render as val if inherited java property has no setter`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -178,6 +178,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptors("'var' expected but found: 'open var'")
@Test
fun `should keep inherited java accessor lookalikes if underlying function is public`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -228,6 +229,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
}
}
+ @JavaCode
@Test
fun `should keep kotlin property with no accessors when java inherits kotlin a var`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -265,6 +267,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
}
}
+ @JavaCode
@Test
fun `kotlin property with compute get and set`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -326,6 +329,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptors("'var' expected but found: 'open var'")
@Test
fun `inherited property should inherit getter's visibility`() {
val configWithProtectedVisibility = dokkaConfiguration {
@@ -399,6 +403,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptors("'var' expected but found: 'open var'")
@Test
fun `should resolve protected java property as protected`() {
val configWithProtectedVisibility = dokkaConfiguration {
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index 38ae2be3..00d98102 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -549,6 +549,7 @@ class SignatureTest : BaseAbstractTest() {
}
}
}
+ @OnlyDescriptorsMPP
@Test
fun `actual typealias should have generic parameters and fully qualified name of the expansion type`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -583,6 +584,7 @@ class SignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptorsMPP
@Test
fun `type with an actual typealias`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -763,6 +765,7 @@ class SignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptors("Order of constructors is different in K2")
@Test
fun `generic constructor params`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -977,6 +980,7 @@ class SignatureTest : BaseAbstractTest() {
}
}
+ @OnlyDescriptors("'var' expected but found: 'open var'")
@Test
fun `java property without accessors should be var`() {
val writerPlugin = TestOutputWriterPlugin()