analysis: project document and program facts through one typed encoder
Replace the program-only projection with ADR-0069's typed model: exact source and digest, the public document AST, complete heading scopes with parent/mode origin/range, anchors, functions, imports, references, calls and resources. Project identity now carries the entry, captured manifest/lock digests, stdlib and the static extension identities that participated in preparation. Run and call bind Observation to the same canonical bytes, inspect reuses the same AST, unit and reference projectors, and the retired duplicate link resolver is deleted. Emit refuses to overwrite inputs, directories, symlinks or hard links and publishes through an owner-only exclusive temporary file.
This commit is contained in:
1 parent
1b214d48da
commit
99789616a4
12 files changed
+2017
-915
No files matched your search
@@ -13,28 +13,48 @@ pub fn check(
|
||||
Ok(prepared) => prepared,
|
||||
Err(code) => {
|
||||
// A failed check never leaves a success artifact behind: a consumer
|
||||
// must not be able to bind `run` to a previous Analysis after the
|
||||
// project stopped loading or compiling.
|
||||
// must not bind `run` to a previous Analysis after the project
|
||||
// stopped loading. The input document is never the cleanup target.
|
||||
if let Some(path) = emit {
|
||||
let _ = std::fs::remove_file(path);
|
||||
if let Err(error) = crate::analysis::discard_without_prepare(file, path) {
|
||||
eprintln!("error: {error}");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
};
|
||||
let mut project = prepared.loaded;
|
||||
let mut prepared = prepared;
|
||||
if refs {
|
||||
let ref_diagnostics = validate_refs(&project);
|
||||
project.diagnostics.extend(ref_diagnostics);
|
||||
let report = crate::document_refs::references_for_project(
|
||||
&prepared.loaded,
|
||||
crate::document_refs::ReferenceMode::VerifyLocal,
|
||||
);
|
||||
for issue in report.issues {
|
||||
let Some(file) = prepared.loaded.files.get(&issue.module) else {
|
||||
continue;
|
||||
};
|
||||
prepared.loaded.diagnostics.push(FileDiagnostic {
|
||||
module_id: issue.module,
|
||||
path: file.path.clone(),
|
||||
source: file.source.clone(),
|
||||
diagnostic: issue.diagnostic,
|
||||
});
|
||||
}
|
||||
}
|
||||
let errors = output::error_count(&project.diagnostics);
|
||||
let errors = output::error_count(&prepared.loaded.diagnostics);
|
||||
if let Some(path) = emit {
|
||||
if errors > 0 {
|
||||
let _ = std::fs::remove_file(path);
|
||||
} else if let Err(error) = crate::analysis::write(&project, path) {
|
||||
if let Err(error) = crate::analysis::discard(&prepared, path) {
|
||||
eprintln!("error: {error}");
|
||||
return 2;
|
||||
}
|
||||
} else if let Err(error) = crate::analysis::write(&prepared, path) {
|
||||
eprintln!("error: {error}");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
let project = &prepared.loaded;
|
||||
if json {
|
||||
output::print_json(&json!({
|
||||
"command": "check",
|
||||
|
||||
Reference in new issue
Block a user