"""Convert CENTVRION parse failures into LSP-style diagnostic dicts. Returns a list of plain dicts so the server layer can map them to lsprotocol types without this module importing pygls. Runtime errors are explicitly out of scope: we only catch lex and parse failures. """ from centvrion.lsp.analysis import ParseFailure, parse def build_diagnostics(source: str) -> list[dict]: result = parse(source) if not isinstance(result, ParseFailure): return [] return [{ "line": result.line, "character": result.character, "length": result.length, "message": result.message, "severity": 1, # Error "source": "centvrion", }]