rune-langium / visual-editor/src / useDiagnosticsForRange
Function: useDiagnosticsForRange()
ts
function useDiagnosticsForRange(astRange, diagnostics): RangeDiagnostic | undefined;Defined in: packages/visual-editor/src/hooks/useDiagnosticsForRange.ts:51
Returns the highest-severity RangeDiagnostic whose range overlaps the given astRange, or undefined when no overlap exists.
Overlap semantics: two ranges [a.start, a.end) and [b.start, b.end) overlap iff a.start < b.end && b.start < a.end. This matches the standard half-open-interval definition used by CodeMirror and LSP. Zero-length ranges (start === end) never overlap.
Severity ordering: 1 (error) > 2 (warn) > 3 (info) > 4 (hint) — lower numeric value wins.
Parameters
| Parameter | Type | Description |
|---|---|---|
astRange | | { end: number; start: number; } | undefined | Character-offset span of the row being tested. When undefined, returns undefined without inspecting the diagnostics array (nothing to match against). |
diagnostics | readonly RangeDiagnostic[] | Pre-converted diagnostics for the active file. Pass a stable empty array ([]) when there are none. |
Returns
RangeDiagnostic | undefined