aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers/pages/samples
diff options
context:
space:
mode:
authorGoooler <wangzongler@gmail.com>2022-02-21 22:01:06 +0800
committerGitHub <noreply@github.com>2022-02-21 17:01:06 +0300
commitf5b7797255576e5f1c230e2ca3fcb5f4e602387c (patch)
tree25fd98250066c4ed6c2fff1104be533604bbf1b9 /plugins/base/src/main/kotlin/transformers/pages/samples
parentdf4780c31026aaa626746f49f0e6fa3fa0278a05 (diff)
downloaddokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.gz
dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.bz2
dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.zip
Code cleanups (#2165)
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers/pages/samples')
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt3
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt6
2 files changed, 4 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt
index cadd3de0..c5b0f221 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/samples/DefaultSamplesTransformer.kt
@@ -19,8 +19,7 @@ class DefaultSamplesTransformer(context: DokkaContext) : SamplesTransformer(cont
private fun processSampleBody(psiElement: PsiElement): String = when (psiElement) {
is KtDeclarationWithBody -> {
- val bodyExpression = psiElement.bodyExpression
- when (bodyExpression) {
+ when (val bodyExpression = psiElement.bodyExpression) {
is KtBlockExpression -> bodyExpression.text.removeSurrounding("{", "}")
else -> bodyExpression!!.text
}
diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
index 43252be3..3ff7a77d 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
@@ -46,8 +46,8 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer {
}
}
- private fun setUpAnalysis(context: DokkaContext) = context.configuration.sourceSets.map { sourceSet ->
- sourceSet to if (sourceSet.samples.isEmpty()) context.plugin<DokkaBase>()
+ private fun setUpAnalysis(context: DokkaContext) = context.configuration.sourceSets.associateWith { sourceSet ->
+ if (sourceSet.samples.isEmpty()) context.plugin<DokkaBase>()
.querySingle { kotlinAnalysis }[sourceSet] // from sourceSet.sourceRoots
else AnalysisEnvironment(DokkaMessageCollector(context.logger), sourceSet.analysisPlatform).run {
if (analysisPlatform == Platform.jvm) {
@@ -63,7 +63,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer {
val (facade, _) = createResolutionFacade(environment)
EnvironmentAndFacade(environment, facade)
}
- }.toMap()
+ }
private fun ContentNode.addSample(
contentPage: ContentPage,