1
1
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
2
2
package com.jetbrains.ls.api.features.impl.common.diagnostics.inspections
3
3
4
+ import com.intellij.codeHighlighting.HighlightDisplayLevel
4
5
import com.intellij.codeInspection.*
5
6
import com.intellij.codeInspection.ex.InspectionManagerEx
6
7
import com.intellij.lang.Language
@@ -61,8 +62,6 @@ class LSInspectionDiagnosticProviderImpl(
61
62
BlackListEntry .InspectionClass (" org.jetbrains.kotlin.idea.k2.codeinsight.inspections.diagnosticBased.VariableNeverReadInspection" , " very slow, uses extended checkers" ),
62
63
BlackListEntry .InspectionClass (" org.jetbrains.kotlin.idea.k2.codeinsight.inspections.diagnosticBased.AssignedValueIsNeverReadInspection" , " very slow, uses extended checkers" ),
63
64
64
- BlackListEntry .InspectionClass (" org.jetbrains.kotlin.idea.k2.codeinsight.inspections.expressions.ExplicitThisInspection" , " too noisy https://github.com/Kotlin/kotlin-lsp/issues/20" ),
65
- BlackListEntry .InspectionClass (" org.jetbrains.kotlin.idea.k2.codeinsight.inspections.ImplicitThisInspection" , " too noisy https://github.com/Kotlin/kotlin-lsp/issues/20" ),
66
65
BlackListEntry .InspectionClass (" org.jetbrains.kotlin.idea.k2.codeinsight.inspections.PublicApiImplicitTypeInspection" , " too noisy https://github.com/Kotlin/kotlin-lsp/issues/4" ),
67
66
68
67
BlackListEntry .InspectionSuperClass (" org.jetbrains.kotlin.idea.codeinsight.api.applicable.inspections.KotlinKtDiagnosticBasedInspectionBase" , " they are slow as calling additional diagnostic collection" ),
@@ -109,6 +108,7 @@ class LSInspectionDiagnosticProviderImpl(
109
108
return LocalInspectionEP .LOCAL_INSPECTION .extensionList
110
109
.filter { it.language == language.id }
111
110
.filter { it.enabledByDefault }
111
+ .filter { HighlightDisplayLevel .find(it.level) != HighlightDisplayLevel .DO_NOT_SHOW }
112
112
.filterNot { blacklist.containsImplementation(it.implementationClass) }
113
113
.mapNotNull { inspection ->
114
114
runCatching {
@@ -120,6 +120,8 @@ class LSInspectionDiagnosticProviderImpl(
120
120
}
121
121
.filterNot { blacklist.containsSuperClass(it) }
122
122
.filterIsInstance<LocalInspectionTool >()
123
+ .takeIf { it.isNotEmpty() }
124
+ ? : emptyList()
123
125
}
124
126
125
127
private fun collectDiagnostics (
@@ -166,18 +168,20 @@ class LSInspectionDiagnosticProviderImpl(
166
168
element : PsiElement
167
169
): List <Diagnostic > {
168
170
val document = file.findDocument() ? : return emptyList()
169
- return results.mapNotNull { result ->
170
- val data = result.createDiagnosticData(localInspectionTool, element, file)
171
- Diagnostic (
172
- range = result.range()?.toLspRange(document) ? : return @mapNotNull null ,
173
- severity = result.highlightType.toLsp(),
174
- // todo handle markers from [com.intellij.codeInspection.CommonProblemDescriptor.getDescriptionTemplate]
175
- message = result.tooltipTemplate,
176
- code = StringOrInt .string(localInspectionTool.id),
177
- tags = result.highlightType.toLspTags(),
178
- data = LSP .json.encodeToJsonElement(data),
179
- )
180
- }
171
+ return results
172
+ .filter { it.highlightType != ProblemHighlightType .INFORMATION }
173
+ .mapNotNull { result ->
174
+ val data = result.createDiagnosticData(localInspectionTool, element, file)
175
+ Diagnostic (
176
+ range = result.range()?.toLspRange(document) ? : return @mapNotNull null ,
177
+ severity = result.highlightType.toLsp(),
178
+ // todo handle markers from [com.intellij.codeInspection.CommonProblemDescriptor.getDescriptionTemplate]
179
+ message = result.tooltipTemplate,
180
+ code = StringOrInt .string(localInspectionTool.id),
181
+ tags = result.highlightType.toLspTags(),
182
+ data = LSP .json.encodeToJsonElement(data),
183
+ )
184
+ }
181
185
}
182
186
183
187
private fun ProblemDescriptor.range (): TextRange ? {
0 commit comments