aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/utils
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-05-28 21:12:50 +0200
committerPaweł Marks <pmarks@virtuslab.com>2020-06-12 14:15:24 +0200
commitdd44b839eac1b7b647e97f2cc73dd96bd054713b (patch)
tree6ab5a393c2a7d926519626f5f45f5c8b8cd60505 /plugins/base/src/test/kotlin/utils
parentd7be30c841cb925fd0d6322ccdd9877169730b92 (diff)
downloaddokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.tar.gz
dokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.tar.bz2
dokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.zip
Refactor of Annotations and ExtraModifiers to be platform depedent
Diffstat (limited to 'plugins/base/src/test/kotlin/utils')
-rw-r--r--plugins/base/src/test/kotlin/utils/contentUtils.kt154
1 files changed, 76 insertions, 78 deletions
diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt
index 7e1b8bf4..c7cea1f1 100644
--- a/plugins/base/src/test/kotlin/utils/contentUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt
@@ -28,36 +28,34 @@ fun ContentMatcherBuilder<*>.bareSignature(
returnType: String? = null,
vararg params: Pair<String, ParamAttributes>
) = group { // TODO: remove it when double wrapping for signatures will be resolved
- group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
- }
+ annotations.entries.forEach {
+ group {
+ unwrapAnnotation(it)
}
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
- link { +name }
- +"("
- params.forEachIndexed { id, (n, t) ->
-
- t.annotations.forEach {
- unwrapAnnotation(it)
- }
- t.keywords.forEach {
- +it
- }
+ }
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
+ link { +name }
+ +"("
+ params.forEachIndexed { id, (n, t) ->
- +"$n:"
- group { link { +(t.type) } }
- if (id != params.lastIndex)
- +", "
+ t.annotations.forEach {
+ unwrapAnnotation(it)
}
- +")"
- if (returnType != null) {
- +(": ")
- group {
- link {
- +(returnType)
- }
+ t.keywords.forEach {
+ +it
+ }
+
+ +"$n:"
+ group { link { +(t.type) } }
+ if (id != params.lastIndex)
+ +", "
+ }
+ +")"
+ if (returnType != null) {
+ +(": ")
+ group {
+ link {
+ +(returnType)
}
}
}
@@ -87,40 +85,38 @@ fun ContentMatcherBuilder<*>.bareSignatureWithReceiver(
returnType: String? = null,
vararg params: Pair<String, ParamAttributes>
) = group { // TODO: remove it when double wrapping for signatures will be resolved
- group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
- }
- }
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
+ annotations.entries.forEach {
group {
- link { +receiver }
+ unwrapAnnotation(it)
}
- +"."
- link { +name }
- +"("
- params.forEachIndexed { id, (n, t) ->
-
- t.annotations.forEach {
- unwrapAnnotation(it)
- }
- t.keywords.forEach {
- +it
- }
+ }
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
+ group {
+ link { +receiver }
+ }
+ +"."
+ link { +name }
+ +"("
+ params.forEachIndexed { id, (n, t) ->
- +"$n:"
- group { link { +(t.type) } }
- if (id != params.lastIndex)
- +", "
+ t.annotations.forEach {
+ unwrapAnnotation(it)
}
- +")"
- if (returnType != null) {
- +(": ")
- group {
- link {
- +(returnType)
- }
+ t.keywords.forEach {
+ +it
+ }
+
+ +"$n:"
+ group { link { +(t.type) } }
+ if (id != params.lastIndex)
+ +", "
+ }
+ +")"
+ if (returnType != null) {
+ +(": ")
+ group {
+ link {
+ +(returnType)
}
}
}
@@ -148,20 +144,18 @@ fun ContentMatcherBuilder<*>.propertySignature(
link { +name }
platformHinted {
group {
- group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
- }
+ annotations.entries.forEach {
+ group {
+ unwrapAnnotation(it)
}
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
- link { +name }
- if (type != null) {
- +(": ")
- group {
- link {
- +(type)
- }
+ }
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
+ link { +name }
+ if (type != null) {
+ +(": ")
+ group {
+ link {
+ +(type)
}
}
}
@@ -184,15 +178,19 @@ fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuil
group { content() }
}
-fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry<String, Set<String>>) {
- +"@"
- link { +elem.key }
- +"("
- elem.value.forEach {
- +("$it = ")
- skipAllNotMatching()
+private fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry<String, Set<String>>) {
+ group {
+ +"@"
+ link { +elem.key }
+ +"("
+ elem.value.forEach {
+ group {
+ +("$it = ")
+ skipAllNotMatching()
+ }
+ }
+ +")"
}
- +")"
}
data class ParamAttributes(