1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::models::{meta::ModuleMeta, Name};
use super::State;
impl State<'_> {
/// Prepares and registers module metadata for all namespaces in the resulting types collection.
///
/// This method iterates through all namespaces in the schema and extracts their metadata
/// to create [`ModuleMeta`] entries. For each namespace, it collects:
/// - The namespace prefix (converted to a [`Name`] if present)
/// - The namespace name (converted to a [`Name`])
/// - The namespace URI
/// - The namespace ID
/// - The count of schemas associated with the namespace
///
/// The prepared module metadata is then inserted into [`MetaTypes::modules`](crate::MetaTypes::modules),
/// making it available for later stages of the schema processing pipeline. This step
/// is essential for maintaining a structured representation of all modules before further
/// compilation and type resolution.
pub(super) fn prepare_modules(&mut self) {
for (id, info) in self.schemas.namespaces() {
let prefix = info
.prefix
.as_ref()
.map(ToString::to_string)
.map(Name::new_named);
let name = info.name().map(Name::new_named);
let namespace = info.namespace.clone();
let schema_count = info.schemas.len();
let module = ModuleMeta {
name,
prefix,
namespace,
namespace_id: *id,
schema_count,
};
self.types.modules.insert(*id, module);
}
}
}