Skip to content

Commit b4ffc63

Browse files
committed
Automatically clear diagnostics in test fixture
As per the LSP spec, the client is not responsible for merging diagnostics, therefore our publishDiagnostics test implementation should honor this. See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics
1 parent 9557c42 commit b4ffc63

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

server/src/test/kotlin/org/javacs/kt/DiagnosticTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class DiagnosticTest : SingleFileTestFixture("diagnostic", "Diagnostics.kt") {
2121

2222
@Test fun `report only errors`() {
2323
languageServer.config.diagnostics.level = DiagnosticSeverity.Error
24-
diagnostics.clear()
2524

2625
// Trigger a diagnostics update via a dummy change.
2726
// TODO: Use the LSP configuration change notification mechanism instead
@@ -54,7 +53,6 @@ class DiagnosticTest : SingleFileTestFixture("diagnostic", "Diagnostics.kt") {
5453
languageServer.textDocumentService.debounceLint.waitForPendingTask()
5554
languageServer.textDocumentService.lintRecompilationCallback = {
5655
if (callbackCount++ == 0) {
57-
diagnostics.clear()
5856
replace(file, 7, 9, "return 11", "")
5957
languageServer.textDocumentService.documentSymbol(DocumentSymbolParams(TextDocumentIdentifier(uri(file).toString()))).get()
6058
}

server/src/test/kotlin/org/javacs/kt/LanguageServerTestFixture.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ abstract class LanguageServerTestFixture(relativeWorkspaceRoot: String) : Langua
151151
// LanguageClient functions
152152

153153
override fun publishDiagnostics(diagnostics: PublishDiagnosticsParams) {
154+
this.diagnostics.clear()
154155
this.diagnostics.addAll(diagnostics.diagnostics)
155156
}
156157

0 commit comments

Comments
 (0)