mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
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: ![image](https://github.com/zed-industries/zed/assets/24362066/7343201f-f05b-4342-a9f7-97f002d88a48) ![image](https://github.com/zed-industries/zed/assets/24362066/e67f9dcb-e090-40e0-873c-e51bd39e0c7e) After: ![image](https://github.com/zed-industries/zed/assets/24362066/0704211a-73f5-4f12-8583-9e47f092e5b7) ![image](https://github.com/zed-industries/zed/assets/24362066/c6fa00f5-fd8f-4f06-8be7-b74acedccd7c) Release Notes: - N/A
This commit is contained in:
parent
15758c10bf
commit
ea165e134d
@ -182,7 +182,9 @@ impl ActionRegistry {
|
|||||||
macro_rules! actions {
|
macro_rules! actions {
|
||||||
($namespace:path, [ $($name:ident),* $(,)? ]) => {
|
($namespace:path, [ $($name:ident),* $(,)? ]) => {
|
||||||
$(
|
$(
|
||||||
/// The `$name` action see [`gpui::actions!`]
|
#[doc = "The `"]
|
||||||
|
#[doc = stringify!($name)]
|
||||||
|
#[doc = "` action, see [`gpui::actions!`]"]
|
||||||
#[derive(::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug, gpui::private::serde_derive::Deserialize)]
|
#[derive(::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug, gpui::private::serde_derive::Deserialize)]
|
||||||
#[serde(crate = "gpui::private::serde")]
|
#[serde(crate = "gpui::private::serde")]
|
||||||
pub struct $name;
|
pub struct $name;
|
||||||
|
@ -22,11 +22,11 @@ pub(crate) fn register_action(type_name: &Ident) -> proc_macro2::TokenStream {
|
|||||||
);
|
);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
impl #type_name {
|
||||||
|
/// This is an auto generated function, do not use.
|
||||||
|
#[automatically_derived]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[gpui::private::linkme::distributed_slice(gpui::__GPUI_ACTIONS)]
|
fn __autogenerated() {
|
||||||
#[linkme(crate = gpui::private::linkme)]
|
|
||||||
static #static_slice_name: gpui::MacroActionBuilder = #action_builder_fn_name;
|
|
||||||
|
|
||||||
/// This is an auto generated function, do not use.
|
/// This is an auto generated function, do not use.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn #action_builder_fn_name() -> gpui::ActionData {
|
fn #action_builder_fn_name() -> gpui::ActionData {
|
||||||
@ -36,5 +36,13 @@ pub(crate) fn register_action(type_name: &Ident) -> proc_macro2::TokenStream {
|
|||||||
build: <#type_name as gpui::Action>::build,
|
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…
Reference in New Issue
Block a user