diff --git a/semanticdb-kotlinc/src/main/kotlin/com/sourcegraph/semanticdb_kotlinc/SemanticdbTextDocumentBuilder.kt b/semanticdb-kotlinc/src/main/kotlin/com/sourcegraph/semanticdb_kotlinc/SemanticdbTextDocumentBuilder.kt index 1637c15..8488d56 100644 --- a/semanticdb-kotlinc/src/main/kotlin/com/sourcegraph/semanticdb_kotlinc/SemanticdbTextDocumentBuilder.kt +++ b/semanticdb-kotlinc/src/main/kotlin/com/sourcegraph/semanticdb_kotlinc/SemanticdbTextDocumentBuilder.kt @@ -133,6 +133,7 @@ class SemanticdbTextDocumentBuilder( if (kdoc.isEmpty()) return kdoc val out = StringBuilder().append("\n\n").append("----").append("\n") kdoc.lineSequence().forEach { line -> + if (line.isEmpty()) return@forEach var start = 0 while (start < line.length && line[start].isWhitespace()) { start++ diff --git a/semanticdb-kotlinc/src/test/kotlin/com/sourcegraph/semanticdb_kotlinc/test/SemanticdbSymbolsTest.kt b/semanticdb-kotlinc/src/test/kotlin/com/sourcegraph/semanticdb_kotlinc/test/SemanticdbSymbolsTest.kt index 631795c..f52ba59 100644 --- a/semanticdb-kotlinc/src/test/kotlin/com/sourcegraph/semanticdb_kotlinc/test/SemanticdbSymbolsTest.kt +++ b/semanticdb-kotlinc/src/test/kotlin/com/sourcegraph/semanticdb_kotlinc/test/SemanticdbSymbolsTest.kt @@ -1,6 +1,8 @@ package com.sourcegraph.semanticdb_kotlinc.test import com.sourcegraph.semanticdb_kotlinc.* +import com.sourcegraph.semanticdb_kotlinc.Semanticdb.Documentation.Format +import com.sourcegraph.semanticdb_kotlinc.Semanticdb.Language import com.sourcegraph.semanticdb_kotlinc.Semanticdb.SymbolOccurrence.Role import com.sourcegraph.semanticdb_kotlinc.test.ExpectedSymbols.SemanticdbData import com.sourcegraph.semanticdb_kotlinc.test.ExpectedSymbols.SymbolCacheData @@ -590,4 +592,44 @@ class SemanticdbSymbolsTest { } })))) .mapCheckExpectedSymbols() + + @TestFactory + fun kdoc() = + listOf( + ExpectedSymbols( + "empty kdoc line", + SourceFile.testKt( + """ + |/** + | + |hello world + |* test content + |*/ + |val x = "" + |""".trimMargin()), + semanticdb = SemanticdbData( + expectedSymbols = + listOf( + SymbolInformation { + symbol = "TestKt#x." + displayName = "x" + language = Language.KOTLIN + documentation { + message = "```kt\npublic val x: kotlin.String\n```\n\n----\n\n\nhello world\n test content\n" + format = Format.MARKDOWN + } + }, + SymbolInformation { + symbol = "TestKt#getX()." + displayName = "x" + language = Language.KOTLIN + documentation { + message = "```kt\npublic val x: kotlin.String\n```\n\n----\n\n\nhello world\n test content\n" + format = Format.MARKDOWN + } + } + ) + ) + ) + ).mapCheckExpectedSymbols() } diff --git a/settings.gradle.kts b/settings.gradle.kts index 37423ba..c6b6459 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,3 @@ - rootProject.name = "lsif-kotlin" include(