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
+33 -31

No files matched your search

+2 -2
View File
@@ -22,13 +22,13 @@ enum ShortOptimization {
impl Buffer {
pub fn write_component(
&mut self,
Component {
ComponentNode {
name,
fields,
children,
manual_props,
prop_gen_args,
}: &Component,
}: &ComponentNode,
) -> Result {
self.write_component_name(name, prop_gen_args)?;
+2 -2
View File
@@ -22,13 +22,13 @@ enum ShortOptimization {
impl Buffer {
pub fn write_element(
&mut self,
Element {
ElementNode {
name,
key,
attributes,
children,
_is_static,
}: &Element,
}: &ElementNode,
) -> Result {
/*
1. Write the tag
+12 -13
View File
@@ -4,18 +4,16 @@ use crate::AttributeDiscription;
macro_rules! trait_methods {
(
$trait:ident;
@base
$(
$(#[$attr:meta])*
$name:ident $(: $($arg:literal),*)*;
)+
) => {
pub trait $trait {
$(
$(#[$attr])*
const $name: AttributeDiscription = trait_methods! { $name $(: $($arg),*)*; };
)*
}
};
// Rename the incoming ident and apply a custom namespace
@@ -27,9 +25,9 @@ macro_rules! trait_methods {
// Don't rename the incoming ident
( $name:ident; ) => { (stringify!($name), None, false) };
}
trait_methods! {
GlobalAttributes;
pub trait GlobalAttributes {
trait_methods! {
@base
/// Prevent the default action for this element.
///
@@ -1410,7 +1408,7 @@ trait_methods! {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-roledescription>
aria_roledescription: "aria-roledescription";
// Widget Attributes
// Widget Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-autocomplete>
aria_autocomplete: "aria-autocomplete";
@@ -1469,7 +1467,7 @@ trait_methods! {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-valuetext>
aria_valuetext: "aria-valuetext";
// Live Region Attributes
// Live Region Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-atomic>
aria_atomic: "aria-atomic";
@@ -1489,7 +1487,7 @@ trait_methods! {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-grabbed>
aria_grabbed: "aria-grabbed";
// Relationship Attributes
// Relationship Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-activedescendant>
aria_activedescendant: "aria-activedescendant";
@@ -1535,12 +1533,12 @@ trait_methods! {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-setsize>
aria_setsize: "aria-setsize";
}
}
trait_methods! {
SvgAttributes;
map_svg_attributes;
pub trait SvgAttributes {
trait_methods! {
@base
/// Prevent the default action for this element.
///
@@ -2295,4 +2293,5 @@ map_svg_attributes;
/// <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/zoomAndPan>
zoomAndPan: "zoomAndPan";
}
}
+5 -5
View File
@@ -24,7 +24,7 @@ use syn::{
};
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub struct Component {
pub struct ComponentNode {
pub name: syn::Path,
pub prop_gen_args: Option<AngleBracketedGenericArguments>,
pub fields: Vec<ComponentField>,
@@ -32,7 +32,7 @@ pub struct Component {
pub manual_props: Option<Expr>,
}
impl Component {
impl ComponentNode {
pub fn validate_component_path(path: &syn::Path) -> Result<()> {
// ensure path segments doesn't have PathArguments, only the last
// 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> {
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
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) {
let name = &self.name;
let prop_gen_args = &self.prop_gen_args;
+3 -3
View File
@@ -11,7 +11,7 @@ use syn::{
// Parse the VNode::Element type
// =======================================
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub struct Element {
pub struct ElementNode {
pub name: Ident,
pub key: Option<IfmtInput>,
pub attributes: Vec<ElementAttrNamed>,
@@ -19,7 +19,7 @@ pub struct Element {
pub _is_static: bool,
}
impl Parse for Element {
impl Parse for ElementNode {
fn parse(stream: ParseStream) -> Result<Self> {
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) {
let name = &self.name;
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 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)| {
context.current_path.push(idx as u8);
@@ -148,7 +152,6 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
key: #key_tokens,
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 [::dioxus::core::ElementId]).as_slice_of_cells(),
dynamic_nodes: __cx.bump().alloc([ #( #node_printer ),* ]),
dynamic_attrs: __cx.bump().alloc([ #( #dyn_attr_printer ),* ]),
}
+4 -4
View File
@@ -21,8 +21,8 @@ Parse
*/
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub enum BodyNode {
Element(Element),
Component(Component),
Element(ElementNode),
Component(ComponentNode),
ForLoop(ForLoop),
IfChain(ExprIf),
Text(IfmtInput),
@@ -71,7 +71,7 @@ impl Parse for BodyNode {
&& first_char.is_ascii_lowercase()
&& !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> {}
// crate::Input::<InputProps<'_, i32> {}
if body_stream.peek(token::Brace) {
Component::validate_component_path(&path)?;
ComponentNode::validate_component_path(&path)?;
return Ok(BodyNode::Component(stream.parse()?));
}
}