Autocomplete rsx (#2421)
* autocomplete rsx * hide the completions module * fix autocomplete for identifiers that start with a raw identifier * add field completion hints for props * remove extra import * Revert "add field completion hints for props" This reverts commit 194899c73783e0f9b5d601d53365746d838f2048. * fix autocomplete inside raw expressions * fix autofmt * feat: just use regular ifmt if it's compatible reuses the tokens for ifmt so RA provides its HIR lowering on simple formatted strings * fix merging ifmt strings * add a better error message for components called like functions --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
245003a5d4
commit
2523581cf4
21 files changed
+788
-217
No files matched your search
@@ -64,50 +64,46 @@ pub fn rsx_node_from_html(node: &Node) -> Option<BodyNode> {
|
||||
}
|
||||
};
|
||||
|
||||
AttributeType::Named(ElementAttrNamed {
|
||||
el_name: el_name.clone(),
|
||||
attr,
|
||||
})
|
||||
AttributeType::Named(ElementAttrNamed::new(el_name.clone(), attr))
|
||||
})
|
||||
.collect();
|
||||
|
||||
let class = el.classes.join(" ");
|
||||
if !class.is_empty() {
|
||||
attributes.push(AttributeType::Named(ElementAttrNamed {
|
||||
el_name: el_name.clone(),
|
||||
attr: ElementAttr {
|
||||
attributes.push(AttributeType::Named(ElementAttrNamed::new(
|
||||
el_name.clone(),
|
||||
ElementAttr {
|
||||
name: dioxus_rsx::ElementAttrName::BuiltIn(Ident::new(
|
||||
"class",
|
||||
Span::call_site(),
|
||||
)),
|
||||
value: dioxus_rsx::ElementAttrValue::AttrLiteral(ifmt_from_text(&class)),
|
||||
},
|
||||
}));
|
||||
)));
|
||||
}
|
||||
|
||||
if let Some(id) = &el.id {
|
||||
attributes.push(AttributeType::Named(ElementAttrNamed {
|
||||
el_name: el_name.clone(),
|
||||
attr: ElementAttr {
|
||||
attributes.push(AttributeType::Named(ElementAttrNamed::new(
|
||||
el_name.clone(),
|
||||
ElementAttr {
|
||||
name: dioxus_rsx::ElementAttrName::BuiltIn(Ident::new(
|
||||
"id",
|
||||
Span::call_site(),
|
||||
)),
|
||||
value: dioxus_rsx::ElementAttrValue::AttrLiteral(ifmt_from_text(id)),
|
||||
},
|
||||
}));
|
||||
)));
|
||||
}
|
||||
|
||||
let children = el.children.iter().filter_map(rsx_node_from_html).collect();
|
||||
|
||||
Some(BodyNode::Element(Element {
|
||||
name: el_name,
|
||||
children,
|
||||
Some(BodyNode::Element(Element::new(
|
||||
None,
|
||||
el_name,
|
||||
attributes,
|
||||
merged_attributes: Default::default(),
|
||||
key: None,
|
||||
brace: Default::default(),
|
||||
}))
|
||||
children,
|
||||
Default::default(),
|
||||
)))
|
||||
}
|
||||
|
||||
// We ignore comments
|
||||
@@ -132,19 +128,18 @@ pub fn collect_svgs(children: &mut [BodyNode], out: &mut Vec<BodyNode>) {
|
||||
segments.push(new_name.clone().into());
|
||||
|
||||
// Replace this instance with a component
|
||||
let mut new_comp = BodyNode::Component(Component {
|
||||
name: syn::Path {
|
||||
let mut new_comp = BodyNode::Component(Component::new(
|
||||
syn::Path {
|
||||
leading_colon: None,
|
||||
segments,
|
||||
},
|
||||
prop_gen_args: None,
|
||||
fields: vec![],
|
||||
children: vec![],
|
||||
manual_props: None,
|
||||
key: None,
|
||||
brace: Default::default(),
|
||||
location: Default::default(),
|
||||
});
|
||||
None,
|
||||
vec![],
|
||||
vec![],
|
||||
None,
|
||||
None,
|
||||
Default::default(),
|
||||
));
|
||||
|
||||
std::mem::swap(child, &mut new_comp);
|
||||
|
||||
|
||||
Reference in new issue
Block a user