pub fn format_source(source: &str) -> Result<String, FormatSourceError>Expand description
Parses and formats source as a complete adam-lang sheet, matching adam-lsp’s
textDocument/formatting handler exactly.
§Errors
Returns FormatSourceError::Parse if source fails to parse at all
(crate::AdamAstParser::parse_str returns Err), or FormatSourceError::Recovered if it
parses with one or more recovered syntax errors (Sheet.errors non-empty) — refusing to
format code it can’t fully understand, matching rustfmt.
§Examples
use adam_lang::format_source;
assert_eq!(
format_source("sheet s{cell x:i32=1;}").unwrap(),
"sheet s {\n cell x: i32 = 1;\n}\n"
);
assert!(format_source("not a sheet at all").is_err());