File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
server/src/main/kotlin/org/javacs/kt Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import com.google.gson.JsonDeserializer
6
6
import com.google.gson.JsonElement
7
7
import com.google.gson.JsonParseException
8
8
import org.eclipse.lsp4j.InitializeParams
9
+ import org.eclipse.lsp4j.DiagnosticSeverity
9
10
import java.lang.reflect.Type
10
11
import java.nio.file.InvalidPathException
11
12
import java.nio.file.Path
@@ -21,6 +22,10 @@ public data class CompletionConfiguration(
21
22
)
22
23
23
24
public data class DiagnosticsConfiguration (
25
+ /* * Whether diagnostics are enabled. */
26
+ var enabled : Boolean = true ,
27
+ /* * The minimum severity of enabled diagnostics. */
28
+ var level : DiagnosticSeverity = DiagnosticSeverity .Hint ,
24
29
/* * The time interval between subsequent lints in ms. */
25
30
var debounceTime : Long = 250L
26
31
)
Original file line number Diff line number Diff line change @@ -305,7 +305,9 @@ class KotlinTextDocumentService(
305
305
}
306
306
307
307
private fun reportDiagnostics (compiled : Collection <URI >, kotlinDiagnostics : Diagnostics ) {
308
- val langServerDiagnostics = kotlinDiagnostics.flatMap(::convertDiagnostic)
308
+ val langServerDiagnostics = kotlinDiagnostics
309
+ .flatMap(::convertDiagnostic)
310
+ .filter { config.diagnostics.enabled && it.second.severity <= config.diagnostics.level }
309
311
val byFile = langServerDiagnostics.groupBy({ it.first }, { it.second })
310
312
311
313
for ((uri, diagnostics) in byFile) {
Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ class KotlinWorkspaceService(
116
116
for (diagnosticsKey in listOf (" linting" , " diagnostics" )) {
117
117
get(diagnosticsKey)?.asJsonObject?.apply {
118
118
val diagnostics = config.diagnostics
119
+ get(" enabled" )?.asBoolean?.let {
120
+ diagnostics.enabled = it
121
+ }
122
+ get(" level" )?.asString?.let {
123
+ diagnostics.level = when (it.lowercase()) {
124
+ " error" -> DiagnosticSeverity .Error
125
+ " warning" -> DiagnosticSeverity .Warning
126
+ " information" -> DiagnosticSeverity .Information
127
+ else -> DiagnosticSeverity .Hint
128
+ }
129
+ }
119
130
get(" debounceTime" )?.asLong?.let {
120
131
diagnostics.debounceTime = it
121
132
docService.updateDebouncer()
You can’t perform that action at this time.
0 commit comments