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
@@ -51,11 +51,15 @@ impl ToTokens for ComponentBody {
|
||||
}
|
||||
};
|
||||
|
||||
let completion_hints = self.completion_hints();
|
||||
|
||||
tokens.append_all(quote! {
|
||||
#props_struct
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#comp_fn
|
||||
|
||||
#completion_hints
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -221,6 +225,31 @@ impl ComponentBody {
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
// We generate an extra enum to help us autocomplete the braces after the component.
|
||||
// This is a bit of a hack, but it's the only way to get the braces to autocomplete.
|
||||
fn completion_hints(&self) -> TokenStream {
|
||||
let comp_fn = &self.item_fn.sig.ident;
|
||||
let completions_mod = Ident::new(&format!("{}_completions", comp_fn), comp_fn.span());
|
||||
|
||||
let vis = &self.item_fn.vis;
|
||||
|
||||
quote! {
|
||||
#[allow(non_snake_case)]
|
||||
#[doc(hidden)]
|
||||
mod #completions_mod {
|
||||
#[doc(hidden)]
|
||||
#[allow(non_camel_case_types)]
|
||||
/// This enum is generated to help autocomplete the braces after the component. It does nothing
|
||||
pub enum Component {
|
||||
#comp_fn {}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#vis use #completions_mod::Component::#comp_fn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DocField<'a> {
|
||||
|
||||
Reference in new issue
Block a user