Add support for namespace changes in action deprecations (#23086)

cc @cole-miller 

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-13 13:56:22 -07:00 committed by GitHub
parent b633f62aa6
commit d4e91c1898
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 14 deletions

View file

@ -1,6 +1,6 @@
//! This module contains all actions supported by [`Editor`]. //! This module contains all actions supported by [`Editor`].
use super::*; use super::*;
use gpui::{action_aliases, action_as}; use gpui::{action_as, action_with_deprecated_aliases};
use schemars::JsonSchema; use schemars::JsonSchema;
use util::serde::default_true; use util::serde::default_true;
@ -394,4 +394,4 @@ gpui::actions!(
action_as!(go_to_line, ToggleGoToLine as Toggle); action_as!(go_to_line, ToggleGoToLine as Toggle);
action_aliases!(editor, OpenSelectedFilename, [OpenFile]); action_with_deprecated_aliases!(editor, OpenSelectedFilename, ["editor::OpenFile"]);

View file

@ -286,7 +286,9 @@ macro_rules! action_as {
// https://github.com/rust-lang/rust-analyzer/issues/8092 // https://github.com/rust-lang/rust-analyzer/issues/8092
#[doc = stringify!($name)] #[doc = stringify!($name)]
#[doc = "action generated by `gpui::action_as!`"] #[doc = "action generated by `gpui::action_as!`"]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)] #[derive(
::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug, ::std::cmp::PartialEq,
)]
pub struct $name; pub struct $name;
gpui::__impl_action!( gpui::__impl_action!(
@ -311,21 +313,15 @@ macro_rules! action_as {
/// Defines and registers a unit struct that can be used as an action, with some deprecated aliases. /// Defines and registers a unit struct that can be used as an action, with some deprecated aliases.
#[macro_export] #[macro_export]
macro_rules! action_aliases { macro_rules! action_with_deprecated_aliases {
($namespace:path, $name:ident, [$($alias:ident),* $(,)?]) => { ($namespace:path, $name:ident, [$($alias:literal),* $(,)?]) => {
// Unfortunately rust-analyzer doesn't display the name due to // Unfortunately rust-analyzer doesn't display the name due to
// https://github.com/rust-lang/rust-analyzer/issues/8092 // https://github.com/rust-lang/rust-analyzer/issues/8092
#[doc = stringify!($name)] #[doc = stringify!($name)]
#[doc = "action, generated by `gpui::action_aliases!`"] #[doc = "action, generated by `gpui::action_with_deprecated_aliases!`"]
#[derive( #[derive(
::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug, ::std::cmp::PartialEq,
::std::clone::Clone,
::std::default::Default,
::std::fmt::Debug,
gpui::private::serde_derive::Deserialize,
gpui::private::schemars::JsonSchema,
)] )]
#[serde(crate = "gpui::private::serde")]
pub struct $name; pub struct $name;
gpui::__impl_action!( gpui::__impl_action!(
@ -345,7 +341,7 @@ macro_rules! action_aliases {
}, },
fn deprecated_aliases() -> &'static [&'static str] { fn deprecated_aliases() -> &'static [&'static str] {
&[ &[
$(concat!(stringify!($namespace), "::", stringify!($alias))),* $($alias),*
] ]
} }
); );