code housekeeping

This commit is contained in:
りき萌 2025-08-26 12:46:50 +02:00
parent e1b6578b2a
commit d3c3ff8e4e
10 changed files with 108 additions and 100 deletions

View file

@ -11,7 +11,7 @@ use crate::{
html::navmap::NavigationMap,
import_map::ImportMap,
parse::parse_tree_with_diagnostics,
state::{Source, Tag, Treehouse, report_diagnostics},
state::{Source, Treehouse, report_diagnostics},
tree::SemaRoots,
vfs::{self, Cd, Content, VPath, VPathBuf},
};
@ -142,7 +142,7 @@ fn load_trees(config: &Config, dirs: &Dirs) -> anyhow::Result<Treehouse> {
for path in &doc_paths {
if let Some(input) =
vfs::query::<Content>(&dirs.content, &path).and_then(|c| c.string().ok())
vfs::query::<Content>(&dirs.content, path).and_then(|c| c.string().ok())
{
let file_id = treehouse.add_file(path.clone(), Source::Other(input));
treehouse.files_by_doc_path.insert(path.clone(), file_id);
@ -155,31 +155,25 @@ fn load_trees(config: &Config, dirs: &Dirs) -> anyhow::Result<Treehouse> {
}
for file_id in doc_file_ids {
let (doc, mut doc_diagnostics) = Doc::parse(&mut treehouse, file_id);
let (doc, mut doc_diagnostics) = Doc::parse(&mut treehouse, config, file_id);
treehouse.docs.insert(file_id, doc);
diagnostics.append(&mut doc_diagnostics);
}
// Tags
for (_, file_id) in &treehouse.files_by_tree_path {
for file_id in treehouse.files_by_tree_path.values() {
let roots = &treehouse.roots[file_id];
for tag_name in &roots.attributes.tags {
let tag = treehouse
.tags
.entry(tag_name.clone())
.or_insert_with(Tag::default);
let tag = treehouse.tags.entry(tag_name.clone()).or_default();
tag.files.push(*file_id);
}
}
for (_, file_id) in &treehouse.files_by_doc_path {
for file_id in treehouse.files_by_doc_path.values() {
let doc = &treehouse.docs[file_id];
for tag_name in &doc.attributes.tags {
let tag = treehouse
.tags
.entry(tag_name.clone())
.or_insert_with(Tag::default);
let tag = treehouse.tags.entry(tag_name.clone()).or_default();
tag.files.push(*file_id);
}
}