wowlab_tidy/languages/toml/rules/manifest/
references.rs1use wowlab_fs::path::Path;
2use wowlab_manifest_schema::ManifestRepository;
3
4use super::{MANIFEST_PREFIX, manifest_repository_root};
5use crate::{Example, TomlCtx, Violation, violation};
6
7const EXAMPLES: &[Example] = &[];
8
9crate::toml_rule!(
10 toml_manifest_references,
11 "Require symbolic aura, spell, talent, and auto-attack references to resolve.",
12 "Broken symbolic references otherwise surface later as generated Rust compilation failures or silently disconnected mechanics.",
13 High,
14);
15
16fn check_toml_manifest_references(ctx: &TomlCtx<'_>) -> Vec<Violation> {
17 if !ctx.file.rel.starts_with(MANIFEST_PREFIX)
18 || Path::new(ctx.file.rel)
19 .file_name()
20 .is_none_or(|name| name != "manifest.toml")
21 || !ctx.parse.errors.is_empty()
22 {
23 return Vec::new();
24 }
25
26 let Some(root) = manifest_repository_root(ctx.file.path) else {
27 return Vec::new();
28 };
29 let Ok(manifest) = ManifestRepository::new(root).load_spec(ctx.file.path) else {
30 return Vec::new();
31 };
32
33 manifest
34 .diagnostics()
35 .into_iter()
36 .map(|diagnostic| violation(ctx.file.rel, 1, diagnostic.to_string()))
37 .collect()
38}