Skip to main content

diagnostics

Function diagnostics 

Source
pub fn diagnostics(text: &str) -> Vec<Diagnostic>
Expand description

Diagnostics for textDocument/publishDiagnostics: both lexer and parser errors. Neither stage ever fails, so this is the set of recovered errors (empty for clean input).

Lexer errors (unterminated literals/comments, stray characters) are surfaced too — they are reported by the tokenizer before the parser runs, so the parser-only error list would otherwise miss them. We read them through the highlighter, which already re-exposes the lexer’s errors. Each diagnostic’s range covers the whole offending token (via its byte range()), not a single character, so editors underline the real span.