mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 20:31:27 +00:00
Compiler refactor: Make the Component Node a syntax_nodes::Component
This commit is contained in:
parent
8561022c53
commit
e38f564f09
5 changed files with 8 additions and 14 deletions
|
|
@ -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<SyntaxNode>,
|
||||
pub node: Option<syntax_nodes::Component>,
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue