diff --git a/internal/compiler/object_tree.rs b/internal/compiler/object_tree.rs index 3c126af64..4db9be725 100644 --- a/internal/compiler/object_tree.rs +++ b/internal/compiler/object_tree.rs @@ -252,7 +252,7 @@ impl Document { if !local_compo.used.get() { diag.push_warning( "Component is neither used nor exported".into(), - &local_compo.node, + &local_compo.node.as_ref().map(|n| n.to_source_location()), ) } } @@ -376,7 +376,7 @@ impl InitCode { /// Or is materialized for repeated expression. #[derive(Default, Debug)] pub struct Component { - pub node: Option, + pub node: Option, pub id: SmolStr, pub root_element: ElementRc, @@ -424,7 +424,7 @@ impl Component { let mut child_insertion_point = None; let is_legacy_syntax = node.child_token(SyntaxKind::ColonEqual).is_some(); let c = Component { - node: Some(node.clone().into()), + node: Some(node.clone()), id: parser::identifier_text(&node.DeclaredIdentifier()).unwrap_or_default(), root_element: Element::from_node( node.Element(), @@ -2724,7 +2724,7 @@ impl Exports { let name = last_compo.id.clone(); if last_compo.is_global() { if sorted_deduped_exports.is_empty() { - diag.push_warning("Global singleton is implicitly marked for export. This is deprecated and it should be explicitly exported".into(), &last_compo.node); + diag.push_warning("Global singleton is implicitly marked for export. This is deprecated and it should be explicitly exported".into(), &last_compo.node.as_ref().map(|n| n.to_source_location())); sorted_deduped_exports.push(( ExportedName { name, name_ident: doc.clone().into() }, Either::Left(last_compo.clone()), @@ -2734,7 +2734,7 @@ impl Exports { .iter() .any(|e| e.1.as_ref().left().is_some_and(|c| !c.is_global())) { - diag.push_warning("Component is implicitly marked for export. This is deprecated and it should be explicitly exported".into(), &last_compo.node); + diag.push_warning("Component is implicitly marked for export. This is deprecated and it should be explicitly exported".into(), &last_compo.node.as_ref().map(|n| n.to_source_location())); let insert_pos = sorted_deduped_exports .partition_point(|(existing_export, _)| existing_export.name <= name); sorted_deduped_exports.insert( diff --git a/internal/compiler/passes/check_public_api.rs b/internal/compiler/passes/check_public_api.rs index 9550eaba4..49f6a9e82 100644 --- a/internal/compiler/passes/check_public_api.rs +++ b/internal/compiler/passes/check_public_api.rs @@ -69,7 +69,7 @@ pub fn check_public_api( if doc.last_exported_component().is_none() { // We maybe requested to preview a non-exported component. if let Ok(ElementType::Component(c)) = doc.local_registry.lookup_element(name) { - if let Some(name_ident) = c.node.clone() { + if let Some(name_ident) = c.node.as_ref().map(|n| n.DeclaredIdentifier().into()) { doc.exports.add_reexports( [(ExportedName{ name: name.into(), name_ident }, Either::Left(c))], diag, diff --git a/internal/compiler/passes/lower_component_container.rs b/internal/compiler/passes/lower_component_container.rs index f0a559606..a45d51cdf 100644 --- a/internal/compiler/passes/lower_component_container.rs +++ b/internal/compiler/passes/lower_component_container.rs @@ -74,7 +74,6 @@ fn process_component_container(element: &ElementRc, empty_type: &ElementType) { })); Component { - node: element.borrow().debug.first().map(|n| n.node.clone().into()), id: smol_str::format_smolstr!("ComponentContainerInternal_{}", suffix), root_element, ..Default::default() diff --git a/internal/compiler/passes/lower_menus.rs b/internal/compiler/passes/lower_menus.rs index 7de00ace5..610a9059d 100644 --- a/internal/compiler/passes/lower_menus.rs +++ b/internal/compiler/passes/lower_menus.rs @@ -638,7 +638,6 @@ fn lower_menu_items( false }); Component { - node: parent.borrow().debug.first().map(|n| n.node.clone().into()), id: SmolStr::default(), root_element, parent_element: Rc::downgrade(parent), diff --git a/tools/lsp/common/rename_component.rs b/tools/lsp/common/rename_component.rs index 57bd9ae63..cf227233f 100644 --- a/tools/lsp/common/rename_component.rs +++ b/tools/lsp/common/rename_component.rs @@ -611,8 +611,7 @@ impl TokenInformation { i_slint_compiler::langtype::ElementType::Component(c), ), ) => { - if let Some(ce) = c.node.as_ref().and_then(|cn| cn.child_node(SyntaxKind::Element)) - { + if let Some(ce) = c.node.as_ref().map(|cn| cn.Element()) { e.borrow().debug.iter().any(|di| { Some(di.node.source_file.path()) == ce.source_file().map(|sf| sf.path()) && di.node.text_range() == ce.text_range() @@ -862,10 +861,7 @@ impl DeclarationNodeQuery { i_slint_compiler::langtype::ElementType::Component(component) => { find_declared_identifier_in_element( &self, - &syntax_nodes::Component::from( - component.node.as_ref()?.clone(), - ) - .Element(), + &component.node.as_ref()?.Element(), ) } _ => None,