@@ -379,6 +379,11 @@ pub struct ItemTreeDescription<'id> {
379
379
/// Map of all exported global singletons and their index in the compiled_globals vector. The key
380
380
/// is the normalized name of the global.
381
381
exported_globals_by_name : BTreeMap < String , usize > ,
382
+
383
+ /// The type loader, which will be available only on the top-most `ItemTreeDescription`.
384
+ /// All other `ItemTreeDescription`s have `None` here.
385
+ #[ cfg( feature = "highlight" ) ]
386
+ pub ( crate ) type_loader : Option < std:: rc:: Rc < i_slint_compiler:: typeloader:: TypeLoader > > ,
382
387
}
383
388
384
389
fn internal_properties_to_public < ' a > (
@@ -786,7 +791,7 @@ pub async fn load(
786
791
if diag. has_error ( ) {
787
792
return ( Err ( ( ) ) , diag) ;
788
793
}
789
- let ( doc, mut diag, _ ) = compile_syntax_node ( syntax_node, diag, compiler_config) . await ;
794
+ let ( doc, mut diag, loader ) = compile_syntax_node ( syntax_node, diag, compiler_config) . await ;
790
795
if diag. has_error ( ) {
791
796
return ( Err ( ( ) ) , diag) ;
792
797
}
@@ -798,11 +803,12 @@ pub async fn load(
798
803
return ( Err ( ( ) ) , diag) ;
799
804
}
800
805
801
- ( Ok ( generate_item_tree ( & doc. root_component , guard) ) , diag)
806
+ ( Ok ( generate_item_tree ( & doc. root_component , Some ( std :: rc :: Rc :: new ( loader ) ) , guard) ) , diag)
802
807
}
803
808
804
809
pub ( crate ) fn generate_item_tree < ' id > (
805
810
component : & Rc < object_tree:: Component > ,
811
+ _type_loader : Option < std:: rc:: Rc < i_slint_compiler:: typeloader:: TypeLoader > > ,
806
812
guard : generativity:: Guard < ' id > ,
807
813
) -> Rc < ItemTreeDescription < ' id > > {
808
814
//dbg!(&*component.root_element.borrow());
@@ -884,7 +890,7 @@ pub(crate) fn generate_item_tree<'id>(
884
890
generativity:: make_guard!( guard) ;
885
891
self . repeater . push (
886
892
RepeaterWithinItemTree {
887
- item_tree_to_repeat : generate_item_tree ( base_component, guard) ,
893
+ item_tree_to_repeat : generate_item_tree ( base_component, None , guard) ,
888
894
offset : self . type_builder . add_field_type :: < Repeater < ErasedItemTreeBox > > ( ) ,
889
895
model : item. repeated . as_ref ( ) . unwrap ( ) . model . clone ( ) ,
890
896
}
@@ -1167,6 +1173,8 @@ pub(crate) fn generate_item_tree<'id>(
1167
1173
public_properties,
1168
1174
compiled_globals,
1169
1175
exported_globals_by_name,
1176
+ #[ cfg( feature = "highlight" ) ]
1177
+ type_loader : _type_loader,
1170
1178
} ;
1171
1179
1172
1180
Rc :: new ( t)
@@ -2061,7 +2069,7 @@ pub fn show_popup(
2061
2069
) {
2062
2070
generativity:: make_guard!( guard) ;
2063
2071
// FIXME: we should compile once and keep the cached compiled component
2064
- let compiled = generate_item_tree ( & popup. component , guard) ;
2072
+ let compiled = generate_item_tree ( & popup. component , None , guard) ;
2065
2073
let inst = instantiate (
2066
2074
compiled,
2067
2075
Some ( parent_comp) ,
0 commit comments