From ec40a94e76d33fb77c58e2b4fe8b9aa150885f0a Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 14 Nov 2017 16:33:41 +0300 Subject: Handle indent correctly, Add tests for assertTrue/False samples --- .../main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core/src') diff --git a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt index 665a687f..b0988c35 100644 --- a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt +++ b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt @@ -2,11 +2,13 @@ package org.jetbrains.dokka.Samples import com.google.inject.Inject import com.intellij.psi.PsiElement +import com.intellij.psi.PsiWhiteSpace import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.dokka.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.allChildren +import org.jetbrains.kotlin.psi.psiUtil.prevLeaf import org.jetbrains.kotlin.resolve.ImportPath open class KotlinWebsiteSampleProcessingService @@ -39,8 +41,9 @@ open class KotlinWebsiteSampleProcessingService val (argument) = expression.valueArguments builder.apply { expression.valueArguments.getOrNull(1)?.let { - appendln("// ${it.extractStringArgumentValue()}") - // TODO: append same amount of whitespace indentation + append("// ${it.extractStringArgumentValue()}") + val ws = expression.prevLeaf { it is PsiWhiteSpace } + append(ws?.text ?: "\n") } append("println(\"") append(argument.text) -- cgit