File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
common/src/com/jetbrains/ls/api/features/impl/common/documentaiton
kotlin/src/com/jetbrains/ls/api/features/impl/common/kotlin/hover Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
2
+ package com.jetbrains.ls.api.features.impl.common.documentaiton
3
+
4
+ /* *
5
+ * Formats a given documentation comment string by cleaning up any extra spaces
6
+ * and ensuring proper alignment for each line. Java/Kotlin-style comments are
7
+ * expected.
8
+ */
9
+ fun formatDocComment (docComment : String ): String {
10
+ val trimmedLines = docComment.trim().lines().map { it.trim() }.filter { it.isNotEmpty() }
11
+ return trimmedLines.joinToString(separator = " \n " ) { if (it.startsWith(" /*" )) it else " $it " }
12
+ }
Original file line number Diff line number Diff line change 2
2
package com.jetbrains.ls.api.features.impl.common.kotlin.hover
3
3
4
4
import com.intellij.psi.PsiElement
5
+ import com.jetbrains.ls.api.features.impl.common.documentaiton.formatDocComment
5
6
import com.jetbrains.ls.api.features.impl.common.hover.AbstractLSHoverProvider
6
7
import com.jetbrains.ls.api.features.impl.common.hover.markdownMultilineCode
7
8
import com.jetbrains.ls.api.features.impl.common.kotlin.language.LSKotlinLanguage
@@ -13,13 +14,8 @@ internal class LSMarkdownDocProviderKotlinImpl : AbstractLSHoverProvider.LSMarkd
13
14
val ktElement = element.unwrapped as ? KtDeclaration ? : return null
14
15
val kdDocText = ktElement.docComment?.text ? : return null
15
16
return markdownMultilineCode(
16
- kdDocText.formatKdoc( ),
17
+ formatDocComment(kdDocText ),
17
18
language = LSKotlinLanguage .lspName
18
19
)
19
20
}
20
-
21
- private fun String.formatKdoc (): String {
22
- val trimmedLines = trim().lines().map { it.trim() }.filter { it.isNotEmpty() }
23
- return trimmedLines.joinToString(separator = " \n " ) { if (it.startsWith(" /*" )) it else " $it " }
24
- }
25
21
}
You can’t perform that action at this time.
0 commit comments