diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt | 3 | ||||
-rw-r--r-- | core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt index ca857aaa..7ac43184 100644 --- a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt +++ b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt @@ -5,6 +5,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.impl.source.tree.LeafPsiElement import org.jetbrains.dokka.* import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.allChildren import org.jetbrains.kotlin.resolve.ImportPath open class KotlinWebsiteSampleProcessingService @@ -70,7 +71,7 @@ open class KotlinWebsiteSampleProcessingService return ContentBlockCode("kotlin").apply { append(ContentText("\n")) psiFile.importList?.let { - it.children.filter { + it.allChildren.filter { it !is KtImportDirective || it.importPath !in importsToIgnore }.forEach { append(ContentText(it.text)) } } diff --git a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt index 3e46ead7..0d586814 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt @@ -24,6 +24,10 @@ class KotlinWebSiteRunnableSamplesFormatTest { verifyKWSNodeByName("newLinesInSamples", "foo") } + @Test fun newLinesInImportList() { + verifyKWSNodeByName("newLinesInImportList", "foo") + } + private fun verifyKWSNodeByName(fileName: String, name: String) { verifyOutput("testdata/format/website-samples/$fileName.kt", ".md", format = "kotlin-website-samples") { model, output -> kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name }) |