Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Update method name and partially document platform crate
Mikayla9eecda2dae16
diff --git a/crates/collab/src/tests/following_tests.rs b/crates/collab/src/tests/following_tests.rsindex dc5488ebb33..af184d7d02a 100644--- a/crates/collab/src/tests/following_tests.rs+++ b/crates/collab/src/tests/following_tests.rs@@ -249,7 +249,7 @@ async fn test_basic_following(executor.run_until_parked();cx_c.cx.update(|_| {});- weak_workspace_c.assert_dropped();+ weak_workspace_c.assert_released();// Clients A and B see that client B is following A, and client C is not present in the followers.executor.run_until_parked();diff --git a/crates/gpui/src/app/entity_map.rs b/crates/gpui/src/app/entity_map.rsindex d3f8a7ea894..7ab21a54775 100644--- a/crates/gpui/src/app/entity_map.rs+++ b/crates/gpui/src/app/entity_map.rs@@ -281,7 +281,7 @@ impl Drop for AnyModel {entity_map.write().leak_detector- .handle_dropped(self.entity_id, self.handle_id)+ .handle_released(self.entity_id, self.handle_id)}}}@@ -500,15 +500,15 @@ impl AnyWeakModel {})}- /// Assert that model referenced by this weak handle has been dropped.+ /// Assert that model referenced by this weak handle has been released.#[cfg(any(test, feature = "test-support"))]- pub fn assert_dropped(&self) {+ pub fn assert_released(&self) {self.entity_ref_counts.upgrade().unwrap().write().leak_detector- .assert_dropped(self.entity_id);+ .assert_released(self.entity_id);if self.entity_ref_counts@@ -658,12 +658,12 @@ impl LeakDetector {handle_id}- pub fn handle_dropped(&mut self, entity_id: EntityId, handle_id: HandleId) {+ pub fn handle_released(&mut self, entity_id: EntityId, handle_id: HandleId) {let handles = self.entity_handles.entry(entity_id).or_default();handles.remove(&handle_id);}- pub fn assert_dropped(&mut self, entity_id: EntityId) {+ pub fn assert_released(&mut self, entity_id: EntityId) {let handles = self.entity_handles.entry(entity_id).or_default();if !handles.is_empty() {for (_, backtrace) in handles {diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rsindex fc60cb1ec6a..8571c1ee57a 100644--- a/crates/gpui/src/executor.rs+++ b/crates/gpui/src/executor.rs@@ -109,9 +109,10 @@ type AnyFuture<R> = Pin<Box<dyn 'static + Send + Future<Output = R>>>;/// BackgroundExecutor lets you run things on background threads./// In production this is a thread pool with no ordering guarantees.-/// In tests this is simalated by running tasks one by one in a deterministic+/// In tests this is simulated by running tasks one by one in a deterministic/// (but arbitrary) order controlled by the `SEED` environment variable.impl BackgroundExecutor {+ #[doc(hidden)]pub fn new(dispatcher: Arc<dyn PlatformDispatcher>) -> Self {Self { dispatcher }}diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rsindex f165cd9c2b5..7b260f1a7d1 100644--- a/crates/gpui/src/platform.rs+++ b/crates/gpui/src/platform.rs@@ -114,15 +114,20 @@ pub(crate) trait Platform: 'static {fn delete_credentials(&self, url: &str) -> Result<()>;}+/// A handle to a platform's display, e.g. a monitor or laptop screen.pub trait PlatformDisplay: Send + Sync + Debug {+ /// Get the ID for this displayfn id(&self) -> DisplayId;+/// Returns a stable identifier for this display that can be persisted and used/// across system restarts.fn uuid(&self) -> Result<Uuid>;- fn as_any(&self) -> &dyn Any;++ /// Get the bounds for this displayfn bounds(&self) -> Bounds<GlobalPixels>;}+/// An opaque identifier for a hardware display#[derive(PartialEq, Eq, Hash, Copy, Clone)]pub struct DisplayId(pub(crate) u32);@@ -134,7 +139,7 @@ impl Debug for DisplayId {unsafe impl Send for DisplayId {}-pub trait PlatformWindow {+pub(crate) trait PlatformWindow {fn bounds(&self) -> WindowBounds;fn content_size(&self) -> Size<Pixels>;fn scale_factor(&self) -> f32;@@ -175,6 +180,9 @@ pub trait PlatformWindow {}}+/// This type is public so that our test macro can generate and use it, but it should not+/// be considered part of our public API.+#[doc(hidden)]pub trait PlatformDispatcher: Send + Sync {fn is_main_thread(&self) -> bool;fn dispatch(&self, runnable: Runnable, label: Option<TaskLabel>);@@ -190,7 +198,7 @@ pub trait PlatformDispatcher: Send + Sync {}}-pub trait PlatformTextSystem: Send + Sync {+pub(crate) trait PlatformTextSystem: Send + Sync {fn add_fonts(&self, fonts: &[Arc<Vec<u8>>]) -> Result<()>;fn all_font_names(&self) -> Vec<String>;fn font_id(&self, descriptor: &Font) -> Result<FontId>;@@ -214,15 +222,21 @@ pub trait PlatformTextSystem: Send + Sync {) -> Vec<usize>;}+/// Basic metadata about the current application and operating system.#[derive(Clone, Debug)]pub struct AppMetadata {+ /// The name of the current operating systempub os_name: &'static str,++ /// The operating system's versionpub os_version: Option<SemanticVersion>,++ /// The current version of the applicationpub app_version: Option<SemanticVersion>,}#[derive(PartialEq, Eq, Hash, Clone)]-pub enum AtlasKey {+pub(crate) enum AtlasKey {Glyph(RenderGlyphParams),Svg(RenderSvgParams),Image(RenderImageParams),@@ -262,7 +276,7 @@ impl From<RenderImageParams> for AtlasKey {}}-pub trait PlatformAtlas: Send + Sync {+pub(crate) trait PlatformAtlas: Send + Sync {fn get_or_insert_with<'a>(&self,key: &AtlasKey,@@ -274,7 +288,7 @@ pub trait PlatformAtlas: Send + Sync {#[derive(Clone, Debug, PartialEq, Eq)]#[repr(C)]-pub struct AtlasTile {+pub(crate) struct AtlasTile {pub(crate) texture_id: AtlasTextureId,pub(crate) tile_id: TileId,pub(crate) bounds: Bounds<DevicePixels>,diff --git a/crates/gpui/src/platform/mac/display.rs b/crates/gpui/src/platform/mac/display.rsindex 2b72c335c80..95ec83cd5a9 100644--- a/crates/gpui/src/platform/mac/display.rs+++ b/crates/gpui/src/platform/mac/display.rs@@ -11,7 +11,6 @@ use core_graphics::{geometry::{CGPoint, CGRect, CGSize},};use objc::{msg_send, sel, sel_impl};-use std::any::Any;use uuid::Uuid;#[derive(Debug)]@@ -154,10 +153,6 @@ impl PlatformDisplay for MacDisplay {]))}- fn as_any(&self) -> &dyn Any {- self- }-fn bounds(&self) -> Bounds<GlobalPixels> {unsafe {let native_bounds = CGDisplayBounds(self.0);diff --git a/crates/gpui/src/platform/test/display.rs b/crates/gpui/src/platform/test/display.rsindex 68dbb0fdf34..838d600147b 100644--- a/crates/gpui/src/platform/test/display.rs+++ b/crates/gpui/src/platform/test/display.rs@@ -31,10 +31,6 @@ impl PlatformDisplay for TestDisplay {Ok(self.uuid)}- fn as_any(&self) -> &dyn std::any::Any {- unimplemented!()- }-fn bounds(&self) -> crate::Bounds<crate::GlobalPixels> {self.bounds}diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rsindex de031704cd2..b69c10c7522 100644--- a/crates/gpui/src/scene.rs+++ b/crates/gpui/src/scene.rs@@ -93,7 +93,7 @@ impl Scene {}}- pub fn insert(&mut self, order: &StackingOrder, primitive: impl Into<Primitive>) {+ pub(crate) fn insert(&mut self, order: &StackingOrder, primitive: impl Into<Primitive>) {let primitive = primitive.into();let clipped_bounds = primitive.bounds()@@ -440,7 +440,7 @@ pub enum PrimitiveKind {Surface,}-pub enum Primitive {+pub(crate) enum Primitive {Shadow(Shadow),Quad(Quad),Path(Path<ScaledPixels>),@@ -589,7 +589,7 @@ impl From<Shadow> for Primitive {#[derive(Clone, Debug, Eq, PartialEq)]#[repr(C)]-pub struct MonochromeSprite {+pub(crate) struct MonochromeSprite {pub view_id: ViewId,pub layer_id: LayerId,pub order: DrawOrder,@@ -622,7 +622,7 @@ impl From<MonochromeSprite> for Primitive {#[derive(Clone, Debug, Eq, PartialEq)]#[repr(C)]-pub struct PolychromeSprite {+pub(crate) struct PolychromeSprite {pub view_id: ViewId,pub layer_id: LayerId,pub order: DrawOrder,diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rsindex 34470aff021..27d216dd50e 100644--- a/crates/gpui/src/text_system.rs+++ b/crates/gpui/src/text_system.rs@@ -47,7 +47,7 @@ pub struct TextSystem {}impl TextSystem {- pub fn new(platform_text_system: Arc<dyn PlatformTextSystem>) -> Self {+ pub(crate) fn new(platform_text_system: Arc<dyn PlatformTextSystem>) -> Self {TextSystem {line_layout_cache: Arc::new(LineLayoutCache::new(platform_text_system.clone())),platform_text_system,diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rsindex f6963dbfd4e..1c5b2a8f993 100644--- a/crates/gpui/src/text_system/line_wrapper.rs+++ b/crates/gpui/src/text_system/line_wrapper.rs@@ -13,7 +13,7 @@ pub struct LineWrapper {impl LineWrapper {pub const MAX_INDENT: u32 = 256;- pub fn new(+ pub(crate) fn new(font_id: FontId,font_size: Pixels,text_system: Arc<dyn PlatformTextSystem>,diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex bbe5e781094..afc06ad1936 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -1809,9 +1809,9 @@ mod tests {assert!(workspace.active_item(cx).is_none());}).unwrap();- editor_1.assert_dropped();- editor_2.assert_dropped();- buffer.assert_dropped();+ editor_1.assert_released();+ editor_2.assert_released();+ buffer.assert_released();}#[gpui::test]