Rust: extract syntax errors

This commit is contained in:
Arthur Baars
2024-09-23 16:41:34 +02:00
parent 4dbb15ddda
commit b04abc09f0
3 changed files with 58 additions and 11 deletions

View File

@@ -27,15 +27,14 @@ fn extract(
let parse = ra_ap_syntax::ast::SourceFile::parse(&input, Edition::CURRENT);
for err in parse.errors() {
let (start, _) = translator.location(err.range());
log::warn!("{}:{}:{}: {}", display_path, start.line, start.col, err);
translator.emit_parse_error(display_path.as_ref(), err);
}
if let Some(ast) = SourceFile::cast(parse.syntax_node()) {
translator.emit_source_file(ast);
translator.trap.commit()?
} else {
log::warn!("Skipped {}", display_path);
}
translator.trap.commit()?;
Ok(())
}
fn main() -> anyhow::Result<()> {