Skip to content

Commit d5c79e2

Browse files
committed
Fix failing tests
1 parent 005ec35 commit d5c79e2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

semanticdb-kotlinc/src/main/kotlin/com/sourcegraph/semanticdb_kotlinc/SemanticdbTextDocumentBuilder.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class SemanticdbTextDocumentBuilder(
134134
val out = StringBuilder().append("\n\n").append("----").append("\n")
135135
kdoc.lineSequence().forEach { line ->
136136
var start = 0
137-
while (start < line.length && Character.isWhitespace(line[start])) {
137+
while (start < line.length && line[start].isWhitespace()) {
138138
start++
139139
}
140140
if (start < line.length && line[start] == '/') {
@@ -143,14 +143,20 @@ class SemanticdbTextDocumentBuilder(
143143
while (start < line.length && line[start] == '*') {
144144
start++
145145
}
146-
while (start < line.length && Character.isWhitespace(line[start])) {
147-
start++
146+
var end = line.length - 1
147+
if (end > start && line[end] == '/') {
148+
end--
148149
}
149-
var end = if (line.endsWith("*/")) line.length - 3 else line.length - 1
150-
end = maxOf(start, end)
151-
while (end > start && Character.isWhitespace(line[end])) {
150+
while (end > start && line[end] == '*') {
152151
end--
153152
}
153+
while (end > start && line[end].isWhitespace()) {
154+
end--
155+
}
156+
start = minOf(start, line.length - 1)
157+
if (end > start) {
158+
end++
159+
}
154160
out.append("\n").append(line, start, end)
155161
}
156162
return out.toString()

semanticdb-kotlinc/src/test/kotlin/com/sourcegraph/semanticdb_kotlinc/test/AnalyzerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class AnalyzerTest {
105105
documentation =
106106
Documentation {
107107
format = Semanticdb.Documentation.Format.MARKDOWN
108-
message = "```kt\nclass Banana\n```"
108+
message = "```kt\npublic final class Banana\n```"
109109
}
110110
},
111111
SymbolInformation {
@@ -115,7 +115,7 @@ class AnalyzerTest {
115115
documentation =
116116
Documentation {
117117
format = Semanticdb.Documentation.Format.MARKDOWN
118-
message = "```kt\nfun foo(): kotlin.Unit\n```"
118+
message = "```kt\npublic final fun foo()\n```"
119119
}
120120
})
121121
assertSoftly(document.symbolsList) { withClue(this) { symbols.forEach(::shouldContain) } }

0 commit comments

Comments
 (0)