aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-09-09 14:26:28 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-10 13:11:02 +0200
commit3792ef312ef347ef3300690e71c1cbf963a175e3 (patch)
tree8c9ece686ca772896602a8571ea54fcbd894d1bd /plugins/base
parentd8a3e7db72109c8f439095a924bdc1da47b6ab6a (diff)
downloaddokka-3792ef312ef347ef3300690e71c1cbf963a175e3.tar.gz
dokka-3792ef312ef347ef3300690e71c1cbf963a175e3.tar.bz2
dokka-3792ef312ef347ef3300690e71c1cbf963a175e3.zip
Add tests
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/base-test-utils/build.gradle.kts1
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt (renamed from plugins/base/src/test/kotlin/utils/JsoupUtils.kt)0
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt (renamed from plugins/base/src/test/kotlin/signatures/SignatureUtils.kt)0
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt1
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt30
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt30
-rw-r--r--plugins/base/src/test/kotlin/utils/TestUtils.kt3
7 files changed, 47 insertions, 18 deletions
diff --git a/plugins/base/base-test-utils/build.gradle.kts b/plugins/base/base-test-utils/build.gradle.kts
index a4a4df69..1de0ac0f 100644
--- a/plugins/base/base-test-utils/build.gradle.kts
+++ b/plugins/base/base-test-utils/build.gradle.kts
@@ -1,4 +1,5 @@
dependencies {
compileOnly(project(":plugins:base"))
implementation(project(":core:test-api"))
+ implementation("org.jsoup:jsoup:1.12.1")
}
diff --git a/plugins/base/src/test/kotlin/utils/JsoupUtils.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt
index e8c7838d..e8c7838d 100644
--- a/plugins/base/src/test/kotlin/utils/JsoupUtils.kt
+++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureUtils.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt
index e77b8757..e77b8757 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureUtils.kt
+++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/SignatureUtils.kt
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 2a091ff5..08e702ba 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -346,7 +346,6 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
is TypeAliased -> signatureForProjection(p.typeAlias)
-
is JavaObject -> link("Any", DriOfAny)
is Void -> link("Unit", DriOfUnit)
is PrimitiveJavaType -> signatureForProjection(p.translateToKotlin(), showFullyQualifiedName)
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 392bba7e..b1c82efb 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -635,22 +635,20 @@ private class DokkaDescriptorVisitor(
abbreviation.toBound(),
expandedType.toBound()
)
- else -> {
- when (val ctor = constructor.declarationDescriptor) {
- is TypeParameterDescriptor -> TypeParameter(
- dri = DRI.from(ctor),
- name = ctor.name.asString()
- )
- else -> TypeConstructor(
- DRI.from(ctor!!), // TODO: remove '!!'
- arguments.map { it.toProjection() },
- if (isExtensionFunctionType) FunctionModifiers.EXTENSION
- else if (isFunctionType) FunctionModifiers.FUNCTION
- else FunctionModifiers.NONE
- )
- }.let {
- if (isMarkedNullable) Nullable(it) else it
- }
+ else -> when (val ctor = constructor.declarationDescriptor) {
+ is TypeParameterDescriptor -> TypeParameter(
+ dri = DRI.from(ctor),
+ name = ctor.name.asString()
+ )
+ else -> TypeConstructor(
+ DRI.from(ctor!!), // TODO: remove '!!'
+ arguments.map { it.toProjection() },
+ if (isExtensionFunctionType) FunctionModifiers.EXTENSION
+ else if (isFunctionType) FunctionModifiers.FUNCTION
+ else FunctionModifiers.NONE
+ )
+ }.let {
+ if (isMarkedNullable) Nullable(it) else it
}
}
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index df2c3825..f5b1bf2e 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -1,6 +1,8 @@
package signatures
+import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.DokkaSourceSetID
+import org.jetbrains.dokka.jdk
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
@@ -450,6 +452,34 @@ class SignatureTest : AbstractCoreTest() {
}
@Test
+ fun `typealias with generic params swapped`() {
+
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt
+ |package kotlinAsJavaPlugin
+ |
+ |typealias XD<B, A> = Map<A, B>
+ |
+ |class ABC {
+ | fun someFun(xd: XD<Int, String>) = 1
+ |}
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-a-b-c/some-fun.html").signature().first().match(
+ "fun ", A("someFun"), "(xd: ", A("XD"), "<", A("Int"),
+ ", ", A("String"), ">):", A("Int"), Span()
+ )
+ }
+ }
+ }
+
+ @Test
fun `generic constructor params`() {
diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt
index 5183972a..2ef6534e 100644
--- a/plugins/base/src/test/kotlin/utils/TestUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt
@@ -76,4 +76,5 @@ val Bound.name: String?
is Void -> "void"
is Dynamic -> "dynamic"
is UnresolvedBound -> "<ERROR CLASS>"
- } \ No newline at end of file
+ is TypeAliased -> typeAlias.name
+ }