@@ -7,6 +7,7 @@ import org.eclipse.lsp4j.Range
77import org.eclipse.lsp4j.jsonrpc.messages.Either
88import org.javacs.kt.CompiledFile
99import org.javacs.kt.index.SymbolIndex
10+ import org.javacs.kt.util.isSubrangeOf
1011import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
1112import org.jetbrains.kotlin.diagnostics.Diagnostic as KotlinDiagnostic
1213
@@ -16,15 +17,7 @@ interface QuickFix {
1617}
1718
1819fun 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)
2821
2922fun diagnosticMatch (diagnostic : KotlinDiagnostic , startCursor : Int , endCursor : Int , diagnosticTypes : Set <String >): Boolean =
3023 diagnostic.textRanges.any { it.startOffset <= startCursor && it.endOffset >= endCursor } && diagnosticTypes.contains(diagnostic.factory.name)
0 commit comments