Skip to main content

diagnostics_for_source

Function diagnostics_for_source 

Source
pub fn diagnostics_for_source(source: &str) -> Vec<Diagnostic>
Expand description

Parses and checks one complete Adam module without executing its expressions.

Returns every recovered syntax error. Checks syntactically clean modules, including local component definitions and named bindings, with [check_module]. A single root without component uses retains [check_sheet]’s recovered syntax/type diagnostics and expression-level ranges. External imports require the explicit source collection accepted by diagnostics_for_module; this convenience checker does no source discovery.

The environment explicitly includes the standard library and optional Euclid geometry, matching the executing web/book hosts. Unresolved call-result shapes remain best-effort. Diagnostic columns count UTF-16 code units in the supplied text.

  • Complexity: parsing, environment setup and module checking costs plus O(en + b) diagnostic projection time for source bytes n, e errors and b message bytes; space for parsed/checker state and returned diagnostics, with no caching.

§Examples

use adam_lsp::diagnostics::diagnostics_for_source;

assert!(diagnostics_for_source("sheet s { cell x: i32 = 1; }").is_empty());
assert_eq!(diagnostics_for_source("sheet s { cell x: i32 = 1.0; }").len(), 1);