gpui-macros: Hide autogenerated action types/functions (#10417)
I've found it a bit annoying that autogenerated code shows up in completions when working on Zed, so I've moved them into an associated function of a struct we're "implementing" Action on. That way, neither a generated function nor a static show up in completions. Note that this change only affects Zed codebase! I'm pushing it up right after last Preview to give it some time on Nightly. Before:   After:   Release Notes: - N/A
This commit is contained in:
parent
15758c10bf
commit
ea165e134d
2 changed files with 23 additions and 13 deletions
|
@ -22,19 +22,27 @@ pub(crate) fn register_action(type_name: &Ident) -> proc_macro2::TokenStream {
|
|||
);
|
||||
|
||||
quote! {
|
||||
#[doc(hidden)]
|
||||
#[gpui::private::linkme::distributed_slice(gpui::__GPUI_ACTIONS)]
|
||||
#[linkme(crate = gpui::private::linkme)]
|
||||
static #static_slice_name: gpui::MacroActionBuilder = #action_builder_fn_name;
|
||||
|
||||
/// This is an auto generated function, do not use.
|
||||
#[doc(hidden)]
|
||||
fn #action_builder_fn_name() -> gpui::ActionData {
|
||||
gpui::ActionData {
|
||||
name: <#type_name as gpui::Action>::debug_name(),
|
||||
type_id: ::std::any::TypeId::of::<#type_name>(),
|
||||
build: <#type_name as gpui::Action>::build,
|
||||
impl #type_name {
|
||||
/// This is an auto generated function, do not use.
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
fn __autogenerated() {
|
||||
/// This is an auto generated function, do not use.
|
||||
#[doc(hidden)]
|
||||
fn #action_builder_fn_name() -> gpui::ActionData {
|
||||
gpui::ActionData {
|
||||
name: <#type_name as gpui::Action>::debug_name(),
|
||||
type_id: ::std::any::TypeId::of::<#type_name>(),
|
||||
build: <#type_name as gpui::Action>::build,
|
||||
}
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[gpui::private::linkme::distributed_slice(gpui::__GPUI_ACTIONS)]
|
||||
#[linkme(crate = gpui::private::linkme)]
|
||||
static #static_slice_name: gpui::MacroActionBuilder = #action_builder_fn_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue