mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
compiler: Add a snapshotter to help create snapshots of compiler state
Use this snapshot to keep a unoptimized typeloader around, so that the preview does not need to do another parsing run. Move the document cache in the preview over to use the snapshot.
This commit is contained in:
parent
d657ee65af
commit
c55f0a9b0e
12 changed files with 791 additions and 130 deletions
|
@ -57,14 +57,15 @@ use crate::namedreference::NamedReference;
|
|||
pub async fn run_passes(
|
||||
doc: &crate::object_tree::Document,
|
||||
type_loader: &mut crate::typeloader::TypeLoader,
|
||||
keep_raw: bool,
|
||||
diag: &mut crate::diagnostics::BuildDiagnostics,
|
||||
) {
|
||||
) -> Option<crate::typeloader::TypeLoader> {
|
||||
if matches!(
|
||||
doc.root_component.root_element.borrow().base_type,
|
||||
ElementType::Error | ElementType::Global
|
||||
) {
|
||||
// If there isn't a root component, we shouldn't do any of these passes
|
||||
return;
|
||||
return None;
|
||||
}
|
||||
|
||||
let style_metrics = {
|
||||
|
@ -82,6 +83,8 @@ pub async fn run_passes(
|
|||
run_import_passes(doc, type_loader, diag);
|
||||
check_public_api::check_public_api(doc, diag);
|
||||
|
||||
let raw_type_loader = keep_raw.then(|| crate::typeloader::snapshot(type_loader).unwrap());
|
||||
|
||||
collect_subcomponents::collect_subcomponents(root_component);
|
||||
for component in (root_component.used_types.borrow().sub_components.iter())
|
||||
.chain(std::iter::once(root_component))
|
||||
|
@ -271,7 +274,9 @@ pub async fn run_passes(
|
|||
== crate::EmbedResourcesKind::EmbedAllResources,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
raw_type_loader
|
||||
}
|
||||
|
||||
/// Run the passes on imported documents
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue