gpui: Further docs refinement & moved some reexports into 'private' module (#3935)

This commit mostly fixes invalid URLs in docstrings. It also
encapsulates crates we reexport (serde stuff + linkme) into a public
module named "private" in order to reduce the API surfaced through docs.
Moreover, I fixed up a bunch of crates that were pulling serde_json in
through gpui explicitly instead of using Cargo manifest.

Release Notes:
- N/A
This commit is contained in:
Piotr Osiewicz 2024-01-07 14:14:21 +01:00 committed by GitHub
parent eb9ddef083
commit d475f1373a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 91 additions and 72 deletions

7
Cargo.lock generated
View file

@ -1380,6 +1380,7 @@ dependencies = [
"schemars", "schemars",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json",
"settings", "settings",
"smol", "smol",
"sum_tree", "sum_tree",
@ -1545,6 +1546,7 @@ dependencies = [
"schemars", "schemars",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json",
"settings", "settings",
"smallvec", "smallvec",
"theme", "theme",
@ -2490,6 +2492,7 @@ dependencies = [
"regex", "regex",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json",
"settings", "settings",
"smallvec", "smallvec",
"smol", "smol",
@ -3784,6 +3787,7 @@ dependencies = [
"lsp", "lsp",
"project", "project",
"serde", "serde",
"serde_json",
"settings", "settings",
"theme", "theme",
"tree-sitter", "tree-sitter",
@ -5511,6 +5515,7 @@ dependencies = [
"picker", "picker",
"postage", "postage",
"project", "project",
"serde_json",
"settings", "settings",
"smol", "smol",
"text", "text",
@ -7764,6 +7769,7 @@ dependencies = [
"search", "search",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json",
"settings", "settings",
"shellexpand", "shellexpand",
"smallvec", "smallvec",
@ -7844,6 +7850,7 @@ dependencies = [
"pathfinder_color", "pathfinder_color",
"rust-embed", "rust-embed",
"serde", "serde",
"serde_json",
"simplelog", "simplelog",
"strum", "strum",
"theme", "theme",

View file

@ -1,8 +1,8 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use async_trait::async_trait; use async_trait::async_trait;
use futures::AsyncReadExt; use futures::AsyncReadExt;
use gpui::AppContext;
use gpui::BackgroundExecutor; use gpui::BackgroundExecutor;
use gpui::{serde_json, AppContext};
use isahc::http::StatusCode; use isahc::http::StatusCode;
use isahc::prelude::Configurable; use isahc::prelude::Configurable;
use isahc::{AsyncBody, Response}; use isahc::{AsyncBody, Response};
@ -11,6 +11,7 @@ use parking_lot::{Mutex, RwLock};
use parse_duration::parse; use parse_duration::parse;
use postage::watch; use postage::watch;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json;
use std::env; use std::env;
use std::ops::Add; use std::ops::Add;
use std::sync::Arc; use std::sync::Arc;

View file

@ -36,6 +36,7 @@ rand.workspace = true
schemars.workspace = true schemars.workspace = true
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
serde_json.workspace = true
smol.workspace = true smol.workspace = true
sysinfo.workspace = true sysinfo.workspace = true
tempfile = "3" tempfile = "3"

View file

@ -15,8 +15,8 @@ use futures::{
TryFutureExt as _, TryStreamExt, TryFutureExt as _, TryStreamExt,
}; };
use gpui::{ use gpui::{
actions, serde_json, AnyModel, AnyWeakModel, AppContext, AsyncAppContext, Model, actions, AnyModel, AnyWeakModel, AppContext, AsyncAppContext, Model, SemanticVersion, Task,
SemanticVersion, Task, WeakModel, WeakModel,
}; };
use lazy_static::lazy_static; use lazy_static::lazy_static;
use parking_lot::RwLock; use parking_lot::RwLock;
@ -25,6 +25,7 @@ use rand::prelude::*;
use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, PeerId, RequestMessage}; use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, PeerId, RequestMessage};
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json;
use settings::Settings; use settings::Settings;
use std::{ use std::{
any::TypeId, any::TypeId,

View file

@ -1,10 +1,11 @@
use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL}; use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL};
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use futures::Future; use futures::Future;
use gpui::{serde_json, AppContext, AppMetadata, BackgroundExecutor, Task}; use gpui::{AppContext, AppMetadata, BackgroundExecutor, Task};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use parking_lot::Mutex; use parking_lot::Mutex;
use serde::Serialize; use serde::Serialize;
use serde_json;
use settings::{Settings, SettingsStore}; use settings::{Settings, SettingsStore};
use std::{env, io::Write, mem, path::PathBuf, sync::Arc, time::Duration}; use std::{env, io::Write, mem, path::PathBuf, sync::Arc, time::Duration};
use sysinfo::{ use sysinfo::{

View file

@ -61,6 +61,7 @@ schemars.workspace = true
postage.workspace = true postage.workspace = true
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
serde_json.workspace = true
time.workspace = true time.workspace = true
smallvec.workspace = true smallvec.workspace = true

View file

@ -7,9 +7,9 @@ use collections::HashMap;
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use editor::Editor; use editor::Editor;
use gpui::{ use gpui::{
actions, div, list, prelude::*, px, serde_json, AnyElement, AppContext, AsyncWindowContext, actions, div, list, prelude::*, px, AnyElement, AppContext, AsyncWindowContext, ClickEvent,
ClickEvent, ElementId, EventEmitter, FocusableView, ListOffset, ListScrollEvent, ListState, ElementId, EventEmitter, FocusableView, ListOffset, ListScrollEvent, ListState, Model, Render,
Model, Render, Subscription, Task, View, ViewContext, VisualContext, WeakView, Subscription, Task, View, ViewContext, VisualContext, WeakView,
}; };
use language::LanguageRegistry; use language::LanguageRegistry;
use menu::Confirm; use menu::Confirm;

View file

@ -15,12 +15,12 @@ use editor::{Editor, EditorElement, EditorStyle};
use feature_flags::{ChannelsAlpha, FeatureFlagAppExt, FeatureFlagViewExt}; use feature_flags::{ChannelsAlpha, FeatureFlagAppExt, FeatureFlagViewExt};
use fuzzy::{match_strings, StringMatchCandidate}; use fuzzy::{match_strings, StringMatchCandidate};
use gpui::{ use gpui::{
actions, canvas, div, fill, list, overlay, point, prelude::*, px, serde_json, AnyElement, actions, canvas, div, fill, list, overlay, point, prelude::*, px, AnyElement, AppContext,
AppContext, AsyncWindowContext, Bounds, ClipboardItem, DismissEvent, Div, EventEmitter, AsyncWindowContext, Bounds, ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle,
FocusHandle, FocusableView, FontStyle, FontWeight, InteractiveElement, IntoElement, ListOffset, FocusableView, FontStyle, FontWeight, InteractiveElement, IntoElement, ListOffset, ListState,
ListState, Model, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, Render, Model, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, Render, RenderOnce,
RenderOnce, SharedString, Styled, Subscription, Task, TextStyle, View, ViewContext, SharedString, Styled, Subscription, Task, TextStyle, View, ViewContext, VisualContext,
VisualContext, WeakView, WhiteSpace, WeakView, WhiteSpace,
}; };
use menu::{Cancel, Confirm, SelectNext, SelectPrev}; use menu::{Cancel, Confirm, SelectNext, SelectPrev};
use project::{Fs, Project}; use project::{Fs, Project};

View file

@ -6,11 +6,11 @@ use collections::HashMap;
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use futures::StreamExt; use futures::StreamExt;
use gpui::{ use gpui::{
actions, div, img, list, px, serde_json, AnyElement, AppContext, AsyncWindowContext, actions, div, img, list, px, AnyElement, AppContext, AsyncWindowContext, CursorStyle,
CursorStyle, DismissEvent, Element, EventEmitter, FocusHandle, FocusableView, DismissEvent, Element, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
InteractiveElement, IntoElement, ListAlignment, ListScrollEvent, ListState, Model, IntoElement, ListAlignment, ListScrollEvent, ListState, Model, ParentElement, Render,
ParentElement, Render, StatefulInteractiveElement, Styled, Task, View, ViewContext, StatefulInteractiveElement, Styled, Task, View, ViewContext, VisualContext, WeakView,
VisualContext, WeakView, WindowContext, WindowContext,
}; };
use notifications::{NotificationEntry, NotificationEvent, NotificationStore}; use notifications::{NotificationEntry, NotificationEvent, NotificationStore};
use project::Fs; use project::Fs;

View file

@ -9,11 +9,7 @@ use crate::{
}; };
use futures::StreamExt; use futures::StreamExt;
use gpui::{ use gpui::{div, TestAppContext, VisualTestContext, WindowBounds, WindowOptions};
div,
serde_json::{self, json},
TestAppContext, VisualTestContext, WindowBounds, WindowOptions,
};
use indoc::indoc; use indoc::indoc;
use language::{ use language::{
language_settings::{AllLanguageSettings, AllLanguageSettingsContent, LanguageSettingsContent}, language_settings::{AllLanguageSettings, AllLanguageSettingsContent, LanguageSettingsContent},
@ -24,6 +20,7 @@ use language::{
use parking_lot::Mutex; use parking_lot::Mutex;
use project::project_settings::{LspSettings, ProjectSettings}; use project::project_settings::{LspSettings, ProjectSettings};
use project::FakeFs; use project::FakeFs;
use serde_json::{self, json};
use std::sync::atomic; use std::sync::atomic;
use std::sync::atomic::AtomicUsize; use std::sync::atomic::AtomicUsize;
use std::{cell::RefCell, future::Future, rc::Rc, time::Instant}; use std::{cell::RefCell, future::Future, rc::Rc, time::Instant};

View file

@ -39,7 +39,7 @@ impl EditorTestContext {
// fs.insert_file("/file", "".to_owned()).await; // fs.insert_file("/file", "".to_owned()).await;
fs.insert_tree( fs.insert_tree(
"/root", "/root",
gpui::serde_json::json!({ serde_json::json!({
"file": "", "file": "",
}), }),
) )

View file

@ -36,6 +36,7 @@ postage.workspace = true
regex.workspace = true regex.workspace = true
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
serde_json.workspace = true
smallvec.workspace = true smallvec.workspace = true
smol.workspace = true smol.workspace = true
sysinfo.workspace = true sysinfo.workspace = true

View file

@ -7,8 +7,8 @@ use db::kvp::KEY_VALUE_STORE;
use editor::{Editor, EditorEvent}; use editor::{Editor, EditorEvent};
use futures::AsyncReadExt; use futures::AsyncReadExt;
use gpui::{ use gpui::{
div, red, rems, serde_json, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, div, red, rems, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, Model,
Model, PromptLevel, Render, Task, View, ViewContext, PromptLevel, Render, Task, View, ViewContext,
}; };
use isahc::Request; use isahc::Request;
use language::Buffer; use language::Buffer;

View file

@ -29,7 +29,7 @@ use std::any::{Any, TypeId};
/// macro, which only generates the code needed to register your action before `main`. /// macro, which only generates the code needed to register your action before `main`.
/// ///
/// ``` /// ```
/// #[derive(gpui::serde::Deserialize, std::cmp::PartialEq, std::clone::Clone)] /// #[derive(gpui::private::serde::Deserialize, std::cmp::PartialEq, std::clone::Clone)]
/// pub struct Paste { /// pub struct Paste {
/// pub content: SharedString, /// pub content: SharedString,
/// } /// }
@ -158,12 +158,12 @@ impl ActionRegistry {
macro_rules! actions { macro_rules! actions {
($namespace:path, [ $($name:ident),* $(,)? ]) => { ($namespace:path, [ $($name:ident),* $(,)? ]) => {
$( $(
#[derive(::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, gpui::serde_derive::Deserialize)] #[derive(::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, gpui::private::serde_derive::Deserialize)]
#[serde(crate = "gpui::serde")] #[serde(crate = "gpui::private::serde")]
pub struct $name; pub struct $name;
gpui::__impl_action!($namespace, $name, gpui::__impl_action!($namespace, $name,
fn build(_: gpui::serde_json::Value) -> gpui::Result<::std::boxed::Box<dyn gpui::Action>> { fn build(_: gpui::private::serde_json::Value) -> gpui::Result<::std::boxed::Box<dyn gpui::Action>> {
Ok(Box::new(Self)) Ok(Box::new(Self))
} }
); );
@ -179,8 +179,8 @@ macro_rules! impl_actions {
($namespace:path, [ $($name:ident),* $(,)? ]) => { ($namespace:path, [ $($name:ident),* $(,)? ]) => {
$( $(
gpui::__impl_action!($namespace, $name, gpui::__impl_action!($namespace, $name,
fn build(value: gpui::serde_json::Value) -> gpui::Result<::std::boxed::Box<dyn gpui::Action>> { fn build(value: gpui::private::serde_json::Value) -> gpui::Result<::std::boxed::Box<dyn gpui::Action>> {
Ok(std::boxed::Box::new(gpui::serde_json::from_value::<Self>(value)?)) Ok(std::boxed::Box::new(gpui::private::serde_json::from_value::<Self>(value)?))
} }
); );

View file

@ -43,7 +43,7 @@ use util::{
ResultExt, ResultExt,
}; };
/// Temporary(?) wrapper around RefCell<AppContext> to help us debug any double borrows. /// Temporary(?) wrapper around [`RefCell<AppContext>`] to help us debug any double borrows.
/// Strongly consider removing after stabilization. /// Strongly consider removing after stabilization.
pub struct AppCell { pub struct AppCell {
app: RefCell<AppContext>, app: RefCell<AppContext>,
@ -964,7 +964,7 @@ impl AppContext {
/// Event handlers propagate events by default. Call this method to stop dispatching to /// Event handlers propagate events by default. Call this method to stop dispatching to
/// event handlers with a lower z-index (mouse) or higher in the tree (keyboard). This is /// event handlers with a lower z-index (mouse) or higher in the tree (keyboard). This is
/// the opposite of [propagate]. It's also possible to cancel a call to [propagate] by /// the opposite of [`Self::propagate`]. It's also possible to cancel a call to [`Self::propagate`] by
/// calling this method before effects are flushed. /// calling this method before effects are flushed.
pub fn stop_propagation(&mut self) { pub fn stop_propagation(&mut self) {
self.propagate_event = false; self.propagate_event = false;
@ -972,7 +972,7 @@ impl AppContext {
/// Action handlers stop propagation by default during the bubble phase of action dispatch /// Action handlers stop propagation by default during the bubble phase of action dispatch
/// dispatching to action handlers higher in the element tree. This is the opposite of /// dispatching to action handlers higher in the element tree. This is the opposite of
/// [stop_propagation]. It's also possible to cancel a call to [stop_propagate] by calling /// [`Self::stop_propagation`]. It's also possible to cancel a call to [`Self::stop_propagation`] by calling
/// this method before effects are flushed. /// this method before effects are flushed.
pub fn propagate(&mut self) { pub fn propagate(&mut self) {
self.propagate_event = true; self.propagate_event = true;

View file

@ -1,4 +1,4 @@
use crate::{private::Sealed, AppContext, Context, Entity, ModelContext}; use crate::{seal::Sealed, AppContext, Context, Entity, ModelContext};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use parking_lot::{RwLock, RwLockUpgradableReadGuard}; use parking_lot::{RwLock, RwLockUpgradableReadGuard};

View file

@ -1582,7 +1582,6 @@ impl From<f32> for Edges<Pixels> {
/// Represents the corners of a box in a 2D space, such as border radius. /// Represents the corners of a box in a 2D space, such as border radius.
/// ///
/// Each field represents the size of the corner on one side of the box: `top_left`, `top_right`, `bottom_right`, and `bottom_left`. /// Each field represents the size of the corner on one side of the box: `top_left`, `top_right`, `bottom_right`, and `bottom_left`.
/// ```
#[derive(Refineable, Clone, Default, Debug, Eq, PartialEq)] #[derive(Refineable, Clone, Default, Debug, Eq, PartialEq)]
#[refineable(Debug)] #[refineable(Debug)]
#[repr(C)] #[repr(C)]
@ -2263,7 +2262,7 @@ impl From<f64> for GlobalPixels {
} }
} }
/// Represents a length in rems, a unit based on the font-size of the window, which can be assigned with [WindowContext::set_rem_size]. /// Represents a length in rems, a unit based on the font-size of the window, which can be assigned with [`WindowContext::set_rem_size`][set_rem_size].
/// ///
/// Rems are used for defining lengths that are scalable and consistent across different UI elements. /// Rems are used for defining lengths that are scalable and consistent across different UI elements.
/// The value of `1rem` is typically equal to the font-size of the root element (often the `<html>` element in browsers), /// The value of `1rem` is typically equal to the font-size of the root element (often the `<html>` element in browsers),
@ -2271,6 +2270,8 @@ impl From<f64> for GlobalPixels {
/// purpose, allowing for scalable and accessible design that can adjust to different display settings or user preferences. /// purpose, allowing for scalable and accessible design that can adjust to different display settings or user preferences.
/// ///
/// For example, if the root element's font-size is `16px`, then `1rem` equals `16px`. A length of `2rems` would then be `32px`. /// For example, if the root element's font-size is `16px`, then `1rem` equals `16px`. A length of `2rems` would then be `32px`.
///
/// [set_rem_size]: crate::WindowContext::set_rem_size
#[derive(Clone, Copy, Default, Add, Sub, Mul, Div, Neg)] #[derive(Clone, Copy, Default, Add, Sub, Mul, Div, Neg)]
pub struct Rems(pub f32); pub struct Rems(pub f32);

View file

@ -30,7 +30,16 @@ mod util;
mod view; mod view;
mod window; mod window;
mod private { /// Do not touch, here be dragons for use by gpui_macros and such.
#[doc(hidden)]
pub mod private {
pub use linkme;
pub use serde;
pub use serde_derive;
pub use serde_json;
}
mod seal {
/// A mechanism for restricting implementations of a trait to only those in GPUI. /// A mechanism for restricting implementations of a trait to only those in GPUI.
/// See: https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/ /// See: https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/
pub trait Sealed {} pub trait Sealed {}
@ -53,16 +62,11 @@ pub use input::*;
pub use interactive::*; pub use interactive::*;
pub use key_dispatch::*; pub use key_dispatch::*;
pub use keymap::*; pub use keymap::*;
pub use linkme;
pub use platform::*; pub use platform::*;
use private::Sealed;
pub use refineable::*; pub use refineable::*;
pub use scene::*; pub use scene::*;
pub use serde; use seal::Sealed;
pub use serde_derive;
pub use serde_json;
pub use shared_string::*; pub use shared_string::*;
pub use smallvec;
pub use smol::Timer; pub use smol::Timer;
pub use style::*; pub use style::*;
pub use styled::*; pub use styled::*;

View file

@ -5,8 +5,8 @@ use std::ops::Range;
/// Implement this trait to allow views to handle textual input when implementing an editor, field, etc. /// Implement this trait to allow views to handle textual input when implementing an editor, field, etc.
/// ///
/// Once your view `V` implements this trait, you can use it to construct an [ElementInputHandler<V>]. /// Once your view `V` implements this trait, you can use it to construct an [`ElementInputHandler<V>`].
/// This input handler can then be assigned during paint by calling [WindowContext::handle_input]. /// This input handler can then be assigned during paint by calling [`WindowContext::handle_input`].
pub trait InputHandler: 'static + Sized { pub trait InputHandler: 'static + Sized {
fn text_for_range(&mut self, range: Range<usize>, cx: &mut ViewContext<Self>) fn text_for_range(&mut self, range: Range<usize>, cx: &mut ViewContext<Self>)
-> Option<String>; -> Option<String>;
@ -43,8 +43,10 @@ pub struct ElementInputHandler<V> {
} }
impl<V: 'static> ElementInputHandler<V> { impl<V: 'static> ElementInputHandler<V> {
/// Used in [Element::paint] with the element's bounds and a view context for its /// Used in [`Element::paint`][element_paint] with the element's bounds and a view context for its
/// containing view. /// containing view.
///
/// [element_paint]: crate::Element::paint
pub fn new(element_bounds: Bounds<Pixels>, view: View<V>, cx: &mut WindowContext) -> Self { pub fn new(element_bounds: Bounds<Pixels>, view: View<V>, cx: &mut WindowContext) -> Self {
ElementInputHandler { ElementInputHandler {
view, view,

View file

@ -94,7 +94,7 @@ unsafe extern "C" fn trampoline(
mod sys { mod sys {
//! Derived from display-link crate under the fololwing license: //! Derived from display-link crate under the fololwing license:
//! https://github.com/BrainiumLLC/display-link/blob/master/LICENSE-MIT //! <https://github.com/BrainiumLLC/display-link/blob/master/LICENSE-MIT>
//! Apple docs: [CVDisplayLink](https://developer.apple.com/documentation/corevideo/cvdisplaylinkoutputcallback?language=objc) //! Apple docs: [CVDisplayLink](https://developer.apple.com/documentation/corevideo/cvdisplaylinkoutputcallback?language=objc)
#![allow(dead_code, non_upper_case_globals)] #![allow(dead_code, non_upper_case_globals)]

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
private::Sealed, AnyElement, AnyModel, AnyWeakModel, AppContext, AvailableSpace, BorrowWindow, seal::Sealed, AnyElement, AnyModel, AnyWeakModel, AppContext, AvailableSpace, BorrowWindow,
Bounds, Element, ElementId, Entity, EntityId, Flatten, FocusHandle, FocusableView, IntoElement, Bounds, Element, ElementId, Entity, EntityId, Flatten, FocusHandle, FocusableView, IntoElement,
LayoutId, Model, Pixels, Point, Render, Size, ViewContext, VisualContext, WeakModel, LayoutId, Model, Pixels, Point, Render, Size, ViewContext, VisualContext, WeakModel,
WindowContext, WindowContext,

View file

@ -1826,9 +1826,11 @@ impl<'a> WindowContext<'a> {
result result
} }
/// Set an input handler, such as [ElementInputHandler], which interfaces with the /// Set an input handler, such as [`ElementInputHandler`][element_input_handler], which interfaces with the
/// platform to receive textual input with proper integration with concerns such /// platform to receive textual input with proper integration with concerns such
/// as IME interactions. /// as IME interactions.
///
/// [element_input_handler]: crate::ElementInputHandler
pub fn handle_input( pub fn handle_input(
&mut self, &mut self,
focus_handle: &FocusHandle, focus_handle: &FocusHandle,
@ -2500,8 +2502,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
} }
/// Register a listener to be called when the given focus handle receives focus. /// Register a listener to be called when the given focus handle receives focus.
/// Unlike [on_focus_changed], returns a subscription and persists until the subscription /// Returns a subscription and persists until the subscription is dropped.
/// is dropped.
pub fn on_focus( pub fn on_focus(
&mut self, &mut self,
handle: &FocusHandle, handle: &FocusHandle,
@ -2527,8 +2528,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
} }
/// Register a listener to be called when the given focus handle or one of its descendants receives focus. /// Register a listener to be called when the given focus handle or one of its descendants receives focus.
/// Unlike [on_focus_changed], returns a subscription and persists until the subscription /// Returns a subscription and persists until the subscription is dropped.
/// is dropped.
pub fn on_focus_in( pub fn on_focus_in(
&mut self, &mut self,
handle: &FocusHandle, handle: &FocusHandle,
@ -2554,8 +2554,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
} }
/// Register a listener to be called when the given focus handle loses focus. /// Register a listener to be called when the given focus handle loses focus.
/// Unlike [on_focus_changed], returns a subscription and persists until the subscription /// Returns a subscription and persists until the subscription is dropped.
/// is dropped.
pub fn on_blur( pub fn on_blur(
&mut self, &mut self,
handle: &FocusHandle, handle: &FocusHandle,
@ -2581,8 +2580,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
} }
/// Register a listener to be called when the window loses focus. /// Register a listener to be called when the window loses focus.
/// Unlike [on_focus_changed], returns a subscription and persists until the subscription /// Returns a subscription and persists until the subscription is dropped.
/// is dropped.
pub fn on_blur_window( pub fn on_blur_window(
&mut self, &mut self,
mut listener: impl FnMut(&mut V, &mut ViewContext<V>) + 'static, mut listener: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
@ -2597,8 +2595,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
} }
/// Register a listener to be called when the given focus handle or one of its descendants loses focus. /// Register a listener to be called when the given focus handle or one of its descendants loses focus.
/// Unlike [on_focus_changed], returns a subscription and persists until the subscription /// Returns a subscription and persists until the subscription is dropped.
/// is dropped.
pub fn on_focus_out( pub fn on_focus_out(
&mut self, &mut self,
handle: &FocusHandle, handle: &FocusHandle,

View file

@ -11,7 +11,7 @@ fn test_action_macros() {
impl_actions!(test, [AnotherTestAction]); impl_actions!(test, [AnotherTestAction]);
#[derive(PartialEq, Clone, gpui::serde_derive::Deserialize)] #[derive(PartialEq, Clone, gpui::private::serde_derive::Deserialize)]
struct RegisterableAction {} struct RegisterableAction {}
register_action!(RegisterableAction); register_action!(RegisterableAction);

View file

@ -36,8 +36,8 @@ pub(crate) fn register_action(type_name: &Ident) -> proc_macro2::TokenStream {
quote! { quote! {
#[doc(hidden)] #[doc(hidden)]
#[gpui::linkme::distributed_slice(gpui::__GPUI_ACTIONS)] #[gpui::private::linkme::distributed_slice(gpui::__GPUI_ACTIONS)]
#[linkme(crate = gpui::linkme)] #[linkme(crate = gpui::private::linkme)]
static #static_slice_name: gpui::MacroActionBuilder = #action_builder_fn_name; 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.

View file

@ -24,6 +24,7 @@ futures.workspace = true
serde.workspace = true serde.workspace = true
anyhow.workspace = true anyhow.workspace = true
tree-sitter.workspace = true tree-sitter.workspace = true
serde_json.workspace = true
[dev-dependencies] [dev-dependencies]
client = { path = "../client", features = ["test-support"] } client = { path = "../client", features = ["test-support"] }

View file

@ -4,9 +4,10 @@ use crate::lsp_log::LogMenuItem;
use super::*; use super::*;
use futures::StreamExt; use futures::StreamExt;
use gpui::{serde_json::json, Context, TestAppContext, VisualTestContext}; use gpui::{Context, TestAppContext, VisualTestContext};
use language::{tree_sitter_rust, FakeLspAdapter, Language, LanguageConfig, LanguageServerName}; use language::{tree_sitter_rust, FakeLspAdapter, Language, LanguageConfig, LanguageServerName};
use project::{FakeFs, Project}; use project::{FakeFs, Project};
use serde_json::json;
use settings::SettingsStore; use settings::SettingsStore;
#[gpui::test] #[gpui::test]

View file

@ -24,6 +24,7 @@ anyhow.workspace = true
ordered-float.workspace = true ordered-float.workspace = true
postage.workspace = true postage.workspace = true
smol.workspace = true smol.workspace = true
serde_json.workspace = true
[dev-dependencies] [dev-dependencies]
futures.workspace = true futures.workspace = true

View file

@ -260,9 +260,10 @@ impl PickerDelegate for ProjectSymbolsDelegate {
mod tests { mod tests {
use super::*; use super::*;
use futures::StreamExt; use futures::StreamExt;
use gpui::{serde_json::json, TestAppContext, VisualContext}; use gpui::{TestAppContext, VisualContext};
use language::{FakeLspAdapter, Language, LanguageConfig}; use language::{FakeLspAdapter, Language, LanguageConfig};
use project::FakeFs; use project::FakeFs;
use serde_json::json;
use settings::SettingsStore; use settings::SettingsStore;
use std::{path::Path, sync::Arc}; use std::{path::Path, sync::Arc};

View file

@ -36,6 +36,7 @@ thiserror.workspace = true
lazy_static.workspace = true lazy_static.workspace = true
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
serde_json.workspace = true
[dev-dependencies] [dev-dependencies]
editor = { path = "../editor", features = ["test-support"] } editor = { path = "../editor", features = ["test-support"] }

View file

@ -3,9 +3,9 @@ use std::{ops::ControlFlow, path::PathBuf, sync::Arc};
use crate::TerminalView; use crate::TerminalView;
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use gpui::{ use gpui::{
actions, serde_json, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths, actions, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths, FocusHandle,
FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription, Task, View,
Task, View, ViewContext, VisualContext, WeakView, WindowContext, ViewContext, VisualContext, WeakView, WindowContext,
}; };
use itertools::Itertools; use itertools::Itertools;
use project::{Fs, ProjectEntryId}; use project::{Fs, ProjectEntryId};

View file

@ -18,6 +18,7 @@ palette = { version = "0.7.3", default-features = false, features = ["std"] }
pathfinder_color = "0.5" pathfinder_color = "0.5"
rust-embed.workspace = true rust-embed.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true
simplelog = "0.9" simplelog = "0.9"
strum = { version = "0.25.0", features = ["derive"] } strum = { version = "0.25.0", features = ["derive"] }
theme = { path = "../theme", features = ["importing-themes"] } theme = { path = "../theme", features = ["importing-themes"] }

View file

@ -16,7 +16,6 @@ use any_ascii::any_ascii;
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use clap::Parser; use clap::Parser;
use convert_case::{Case, Casing}; use convert_case::{Case, Casing};
use gpui::serde_json;
use indexmap::IndexMap; use indexmap::IndexMap;
use indoc::formatdoc; use indoc::formatdoc;
use json_comments::StripComments; use json_comments::StripComments;

View file

@ -1,5 +1,5 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use gpui::{serde_json, Hsla, Rgba}; use gpui::{Hsla, Rgba};
use theme::{ use theme::{
color_alpha, Appearance, PlayerColor, PlayerColors, StatusColorsRefinement, color_alpha, Appearance, PlayerColor, PlayerColors, StatusColorsRefinement,
ThemeColorsRefinement, UserFontStyle, UserFontWeight, UserHighlightStyle, UserSyntaxTheme, ThemeColorsRefinement, UserFontStyle, UserFontWeight, UserHighlightStyle, UserSyntaxTheme,

View file

@ -6,10 +6,10 @@ use std::fmt;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::sync::Arc; use std::sync::Arc;
use gpui::serde_json::{self, Value};
use pathfinder_color::ColorU; use pathfinder_color::ColorU;
use serde::de::{self, DeserializeOwned, Unexpected}; use serde::de::{self, DeserializeOwned, Unexpected};
use serde::{Deserialize, Deserializer}; use serde::{Deserialize, Deserializer};
use serde_json::{self, Value};
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(transparent)] #[repr(transparent)]