fix: hovers

This commit is contained in:
Jonathan Kelley committed 2022-12-23 17:39:07 -05:00
1 parent 4e49d71efe
commit fd8015e943
7 files changed
+1549 -1547

No files matched your search

+2 -2
View File
@@ -22,13 +22,13 @@ enum ShortOptimization {
impl Buffer { impl Buffer {
pub fn write_component( pub fn write_component(
&mut self, &mut self,
Component { ComponentNode {
name, name,
fields, fields,
children, children,
manual_props, manual_props,
prop_gen_args, prop_gen_args,
}: &Component, }: &ComponentNode,
) -> Result { ) -> Result {
self.write_component_name(name, prop_gen_args)?; self.write_component_name(name, prop_gen_args)?;
+2 -2
View File
@@ -22,13 +22,13 @@ enum ShortOptimization {
impl Buffer { impl Buffer {
pub fn write_element( pub fn write_element(
&mut self, &mut self,
Element { ElementNode {
name, name,
key, key,
attributes, attributes,
children, children,
_is_static, _is_static,
}: &Element, }: &ElementNode,
) -> Result { ) -> Result {
/* /*
1. Write the tag 1. Write the tag
File diff suppressed because it is too large. Load diff
+5 -5
View File
@@ -24,7 +24,7 @@ use syn::{
}; };
#[derive(PartialEq, Eq, Clone, Debug, Hash)] #[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub struct Component { pub struct ComponentNode {
pub name: syn::Path, pub name: syn::Path,
pub prop_gen_args: Option<AngleBracketedGenericArguments>, pub prop_gen_args: Option<AngleBracketedGenericArguments>,
pub fields: Vec<ComponentField>, pub fields: Vec<ComponentField>,
@@ -32,7 +32,7 @@ pub struct Component {
pub manual_props: Option<Expr>, pub manual_props: Option<Expr>,
} }
impl Component { impl ComponentNode {
pub fn validate_component_path(path: &syn::Path) -> Result<()> { pub fn validate_component_path(path: &syn::Path) -> Result<()> {
// ensure path segments doesn't have PathArguments, only the last // ensure path segments doesn't have PathArguments, only the last
// segment is allowed to have one. // segment is allowed to have one.
@@ -69,10 +69,10 @@ impl Component {
} }
} }
impl Parse for Component { impl Parse for ComponentNode {
fn parse(stream: ParseStream) -> Result<Self> { fn parse(stream: ParseStream) -> Result<Self> {
let mut name = stream.parse::<syn::Path>()?; let mut name = stream.parse::<syn::Path>()?;
Component::validate_component_path(&name)?; ComponentNode::validate_component_path(&name)?;
// extract the path arguments from the path into prop_gen_args // extract the path arguments from the path into prop_gen_args
let prop_gen_args = name.segments.last_mut().and_then(|seg| { let prop_gen_args = name.segments.last_mut().and_then(|seg| {
@@ -124,7 +124,7 @@ impl Parse for Component {
} }
} }
impl ToTokens for Component { impl ToTokens for ComponentNode {
fn to_tokens(&self, tokens: &mut TokenStream2) { fn to_tokens(&self, tokens: &mut TokenStream2) {
let name = &self.name; let name = &self.name;
let prop_gen_args = &self.prop_gen_args; let prop_gen_args = &self.prop_gen_args;
+3 -3
View File
@@ -11,7 +11,7 @@ use syn::{
// Parse the VNode::Element type // Parse the VNode::Element type
// ======================================= // =======================================
#[derive(PartialEq, Eq, Clone, Debug, Hash)] #[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub struct Element { pub struct ElementNode {
pub name: Ident, pub name: Ident,
pub key: Option<IfmtInput>, pub key: Option<IfmtInput>,
pub attributes: Vec<ElementAttrNamed>, pub attributes: Vec<ElementAttrNamed>,
@@ -19,7 +19,7 @@ pub struct Element {
pub _is_static: bool, pub _is_static: bool,
} }
impl Parse for Element { impl Parse for ElementNode {
fn parse(stream: ParseStream) -> Result<Self> { fn parse(stream: ParseStream) -> Result<Self> {
let el_name = Ident::parse(stream)?; let el_name = Ident::parse(stream)?;
@@ -157,7 +157,7 @@ impl Parse for Element {
} }
} }
impl ToTokens for Element { impl ToTokens for ElementNode {
fn to_tokens(&self, tokens: &mut TokenStream2) { fn to_tokens(&self, tokens: &mut TokenStream2) {
let name = &self.name; let name = &self.name;
let children = &self.children; let children = &self.children;
+5 -2
View File
@@ -111,7 +111,11 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
}; };
let spndbg = format!("{:?}", self.roots[0].span()); let spndbg = format!("{:?}", self.roots[0].span());
let root_col = spndbg[9..].split("..").next().unwrap(); let root_col = if spndbg.len() >= 9 {
spndbg[9..].split("..").next().unwrap()
} else {
""
};
let root_printer = self.roots.iter().enumerate().map(|(idx, root)| { let root_printer = self.roots.iter().enumerate().map(|(idx, root)| {
context.current_path.push(idx as u8); context.current_path.push(idx as u8);
@@ -148,7 +152,6 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
key: #key_tokens, key: #key_tokens,
template: TEMPLATE, template: TEMPLATE,
root_ids: std::cell::Cell::from_mut( __cx.bump().alloc([None; #num_roots]) as &mut _).as_slice_of_cells(), root_ids: std::cell::Cell::from_mut( __cx.bump().alloc([None; #num_roots]) as &mut _).as_slice_of_cells(),
// root_ids: std::cell::Cell::from_mut( __cx.bump().alloc([None; #num_roots]) as &mut [::dioxus::core::ElementId]).as_slice_of_cells(),
dynamic_nodes: __cx.bump().alloc([ #( #node_printer ),* ]), dynamic_nodes: __cx.bump().alloc([ #( #node_printer ),* ]),
dynamic_attrs: __cx.bump().alloc([ #( #dyn_attr_printer ),* ]), dynamic_attrs: __cx.bump().alloc([ #( #dyn_attr_printer ),* ]),
} }
+4 -4
View File
@@ -21,8 +21,8 @@ Parse
*/ */
#[derive(PartialEq, Eq, Clone, Debug, Hash)] #[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub enum BodyNode { pub enum BodyNode {
Element(Element), Element(ElementNode),
Component(Component), Component(ComponentNode),
ForLoop(ForLoop), ForLoop(ForLoop),
IfChain(ExprIf), IfChain(ExprIf),
Text(IfmtInput), Text(IfmtInput),
@@ -71,7 +71,7 @@ impl Parse for BodyNode {
&& first_char.is_ascii_lowercase() && first_char.is_ascii_lowercase()
&& !el_name.contains('_') && !el_name.contains('_')
{ {
return Ok(BodyNode::Element(stream.parse::<Element>()?)); return Ok(BodyNode::Element(stream.parse::<ElementNode>()?));
} }
} }
@@ -90,7 +90,7 @@ impl Parse for BodyNode {
// Input::<InputProps<'_, i32> {} // Input::<InputProps<'_, i32> {}
// crate::Input::<InputProps<'_, i32> {} // crate::Input::<InputProps<'_, i32> {}
if body_stream.peek(token::Brace) { if body_stream.peek(token::Brace) {
Component::validate_component_path(&path)?; ComponentNode::validate_component_path(&path)?;
return Ok(BodyNode::Component(stream.parse()?)); return Ok(BodyNode::Component(stream.parse()?));
} }
} }