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
@@ -7,7 +7,7 @@ use dioxus_html_internal_macro::impl_extension_attributes;
|
||||
use crate::AttributeDiscription;
|
||||
|
||||
#[cfg(feature = "hot-reload-context")]
|
||||
macro_rules! trait_method_mapping {
|
||||
macro_rules! mod_method_mapping {
|
||||
(
|
||||
$matching:ident;
|
||||
$(#[$attr:meta])*
|
||||
@@ -68,11 +68,11 @@ macro_rules! html_to_rsx_attribute_mapping {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! trait_methods {
|
||||
macro_rules! mod_methods {
|
||||
(
|
||||
@base
|
||||
$(#[$trait_attr:meta])*
|
||||
$trait:ident;
|
||||
$(#[$mod_attr:meta])*
|
||||
$mod:ident;
|
||||
$fn:ident;
|
||||
$fn_html_to_rsx:ident;
|
||||
$(
|
||||
@@ -80,18 +80,19 @@ macro_rules! trait_methods {
|
||||
$name:ident $(: $($arg:literal),*)*;
|
||||
)+
|
||||
) => {
|
||||
$(#[$trait_attr])*
|
||||
pub trait $trait {
|
||||
$(#[$mod_attr])*
|
||||
pub mod $mod {
|
||||
use super::*;
|
||||
$(
|
||||
$(#[$attr])*
|
||||
const $name: AttributeDiscription = trait_methods! { $name $(: $($arg),*)*; };
|
||||
pub const $name: AttributeDiscription = mod_methods! { $name $(: $($arg),*)*; };
|
||||
)*
|
||||
}
|
||||
|
||||
#[cfg(feature = "hot-reload-context")]
|
||||
pub(crate) fn $fn(attr: &str) -> Option<(&'static str, Option<&'static str>)> {
|
||||
$(
|
||||
trait_method_mapping! {
|
||||
mod_method_mapping! {
|
||||
attr;
|
||||
$name$(: $($arg),*)*;
|
||||
}
|
||||
@@ -111,7 +112,7 @@ macro_rules! trait_methods {
|
||||
None
|
||||
}
|
||||
|
||||
impl_extension_attributes![GLOBAL $trait { $($name,)* }];
|
||||
impl_extension_attributes![$mod { $($name,)* }];
|
||||
};
|
||||
|
||||
// Rename the incoming ident and apply a custom namespace
|
||||
@@ -124,10 +125,10 @@ macro_rules! trait_methods {
|
||||
( $name:ident; ) => { (stringify!($name), None, false) };
|
||||
}
|
||||
|
||||
trait_methods! {
|
||||
mod_methods! {
|
||||
@base
|
||||
|
||||
GlobalAttributes;
|
||||
global_attributes;
|
||||
map_global_attributes;
|
||||
map_html_global_attributes_to_rsx;
|
||||
|
||||
@@ -1640,9 +1641,9 @@ trait_methods! {
|
||||
aria_setsize: "aria-setsize";
|
||||
}
|
||||
|
||||
trait_methods! {
|
||||
mod_methods! {
|
||||
@base
|
||||
SvgAttributes;
|
||||
svg_attributes;
|
||||
map_svg_attributes;
|
||||
map_html_svg_attributes_to_rsx;
|
||||
|
||||
@@ -8,7 +8,6 @@ use dioxus_rsx::HotReloadingContext;
|
||||
|
||||
#[cfg(feature = "hot-reload-context")]
|
||||
use crate::{map_global_attributes, map_svg_attributes};
|
||||
use crate::{GlobalAttributes, SvgAttributes};
|
||||
|
||||
pub type AttributeDiscription = (&'static str, Option<&'static str>, bool);
|
||||
|
||||
@@ -115,9 +114,11 @@ macro_rules! impl_element {
|
||||
) => {
|
||||
#[allow(non_camel_case_types)]
|
||||
$(#[$attr])*
|
||||
pub struct $name;
|
||||
pub mod $name {
|
||||
#[allow(unused)]
|
||||
use super::*;
|
||||
pub use crate::attribute_groups::global_attributes::*;
|
||||
|
||||
impl $name {
|
||||
pub const TAG_NAME: &'static str = stringify!($name);
|
||||
pub const NAME_SPACE: Option<&'static str> = None;
|
||||
|
||||
@@ -128,8 +129,6 @@ macro_rules! impl_element {
|
||||
);
|
||||
)*
|
||||
}
|
||||
|
||||
impl GlobalAttributes for $name {}
|
||||
};
|
||||
|
||||
(
|
||||
@@ -141,13 +140,12 @@ macro_rules! impl_element {
|
||||
)*
|
||||
}
|
||||
) => {
|
||||
#[allow(non_camel_case_types)]
|
||||
$(#[$attr])*
|
||||
pub struct $name;
|
||||
pub mod $name {
|
||||
#[allow(unused)]
|
||||
use super::*;
|
||||
pub use crate::attribute_groups::svg_attributes::*;
|
||||
|
||||
impl SvgAttributes for $name {}
|
||||
|
||||
impl $name {
|
||||
pub const TAG_NAME: &'static str = stringify!($name);
|
||||
pub const NAME_SPACE: Option<&'static str> = Some($namespace);
|
||||
|
||||
@@ -171,11 +169,11 @@ macro_rules! impl_element {
|
||||
) => {
|
||||
#[allow(non_camel_case_types)]
|
||||
$(#[$attr])*
|
||||
pub struct $element;
|
||||
pub mod $element {
|
||||
#[allow(unused)]
|
||||
use super::*;
|
||||
pub use crate::attribute_groups::svg_attributes::*;
|
||||
|
||||
impl SvgAttributes for $element {}
|
||||
|
||||
impl $element {
|
||||
pub const TAG_NAME: &'static str = $name;
|
||||
pub const NAME_SPACE: Option<&'static str> = Some($namespace);
|
||||
|
||||
@@ -384,10 +382,23 @@ macro_rules! builder_constructors {
|
||||
);
|
||||
)*
|
||||
|
||||
/// This module contains helpers for rust analyzer autocompletion
|
||||
#[doc(hidden)]
|
||||
pub mod completions {
|
||||
/// This helper tells rust analyzer that it should autocomplete the element name with braces.
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum CompleteWithBraces {
|
||||
$(
|
||||
$(#[$attr])*
|
||||
$name {}
|
||||
),*
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod extensions {
|
||||
use super::*;
|
||||
$(
|
||||
impl_extension_attributes![ELEMENT $name { $($fil,)* }];
|
||||
impl_extension_attributes![$name { $($fil,)* }];
|
||||
)*
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
//!
|
||||
//! Currently, we don't validate for structures, but do validate attributes.
|
||||
|
||||
mod elements;
|
||||
pub mod elements;
|
||||
#[cfg(feature = "hot-reload-context")]
|
||||
pub use elements::HtmlCtx;
|
||||
#[cfg(feature = "html-to-rsx")]
|
||||
@@ -24,8 +24,8 @@ pub use elements::{map_html_attribute_to_rsx, map_html_element_to_rsx};
|
||||
pub mod events;
|
||||
pub(crate) mod file_data;
|
||||
pub use file_data::*;
|
||||
mod attribute_groups;
|
||||
pub mod geometry;
|
||||
mod global_attributes;
|
||||
pub mod input_data;
|
||||
#[cfg(feature = "native-bind")]
|
||||
pub mod native_bind;
|
||||
@@ -40,25 +40,25 @@ mod transit;
|
||||
#[cfg(feature = "serialize")]
|
||||
pub use transit::*;
|
||||
|
||||
pub use attribute_groups::*;
|
||||
pub use elements::*;
|
||||
pub use events::*;
|
||||
pub use global_attributes::*;
|
||||
pub use render_template::*;
|
||||
|
||||
#[cfg(feature = "eval")]
|
||||
pub mod eval;
|
||||
|
||||
pub mod extensions {
|
||||
pub use crate::attribute_groups::{GlobalAttributesExtension, SvgAttributesExtension};
|
||||
pub use crate::elements::extensions::*;
|
||||
pub use crate::global_attributes::{GlobalAttributesExtension, SvgAttributesExtension};
|
||||
}
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::attribute_groups::{GlobalAttributesExtension, SvgAttributesExtension};
|
||||
pub use crate::elements::extensions::*;
|
||||
#[cfg(feature = "eval")]
|
||||
pub use crate::eval::*;
|
||||
pub use crate::events::*;
|
||||
pub use crate::global_attributes::{GlobalAttributesExtension, SvgAttributesExtension};
|
||||
pub use crate::point_interaction::*;
|
||||
pub use keyboard_types::{self, Code, Key, Location, Modifiers};
|
||||
}
|
||||
Reference in new issue
Block a user