@@ -7,6 +7,7 @@ import org.eclipse.lsp4j.Range
7
7
import org.eclipse.lsp4j.jsonrpc.messages.Either
8
8
import org.javacs.kt.CompiledFile
9
9
import org.javacs.kt.index.SymbolIndex
10
+ import org.javacs.kt.util.isSubrangeOf
10
11
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
11
12
import org.jetbrains.kotlin.diagnostics.Diagnostic as KotlinDiagnostic
12
13
@@ -16,15 +17,7 @@ interface QuickFix {
16
17
}
17
18
18
19
fun diagnosticMatch (diagnostic : Diagnostic , range : Range , diagnosticTypes : Set <String >): Boolean =
19
- isDiagnosticInRange(diagnostic, range) && diagnosticTypes.contains(diagnostic.code.left)
20
-
21
- // for a diagnostic to be in range the lines should be the same, and
22
- // the input character range should be within the bounds of the diagnostics range.
23
- private fun isDiagnosticInRange (diagnostic : Diagnostic , range : Range ): Boolean {
24
- val diagnosticRange = diagnostic.range
25
- return diagnosticRange.start.line == range.start.line && diagnosticRange.end.line == range.end.line &&
26
- diagnosticRange.start.character <= range.start.character && diagnosticRange.end.character >= range.end.character
27
- }
20
+ range.isSubrangeOf(diagnostic.range) && diagnosticTypes.contains(diagnostic.code.left)
28
21
29
22
fun diagnosticMatch (diagnostic : KotlinDiagnostic , startCursor : Int , endCursor : Int , diagnosticTypes : Set <String >): Boolean =
30
23
diagnostic.textRanges.any { it.startOffset <= startCursor && it.endOffset >= endCursor } && diagnosticTypes.contains(diagnostic.factory.name)
0 commit comments