From 937186da125ffd89c8a56126c5d63349e3a8377f Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 11 Dec 2024 13:21:40 -0500 Subject: [PATCH] gpui: Don't export named `Context` from prelude (#21869) This PR updates the `gpui::prelude` to not export the `Context` trait named. This prevents some naming clashes in downstream consumers. Release Notes: - N/A --- crates/assistant/src/context/context_tests.rs | 4 ++-- crates/copilot/src/copilot_chat.rs | 3 +-- crates/editor/src/element.rs | 1 - crates/editor/src/git/project_diff.rs | 5 +---- crates/editor/src/inline_completion_tests.rs | 3 +-- crates/editor/src/test/editor_test_context.rs | 6 ++---- crates/gpui/src/prelude.rs | 2 +- crates/language_model/src/registry.rs | 3 +-- crates/language_models/src/provider/copilot_chat.rs | 6 +----- crates/project_panel/src/project_panel.rs | 1 - crates/workspace/src/workspace.rs | 9 ++------- 11 files changed, 12 insertions(+), 31 deletions(-) diff --git a/crates/assistant/src/context/context_tests.rs b/crates/assistant/src/context/context_tests.rs index 7f058cc9e765c5687bc97f5a91b267c5a1e83cbf..95b77d47217c6f6ac2e8746c37450cf480c2a8ff 100644 --- a/crates/assistant/src/context/context_tests.rs +++ b/crates/assistant/src/context/context_tests.rs @@ -17,7 +17,7 @@ use futures::{ channel::mpsc, stream::{self, StreamExt}, }; -use gpui::{AppContext, Model, SharedString, Task, TestAppContext, WeakView}; +use gpui::{prelude::*, AppContext, Model, SharedString, Task, TestAppContext, WeakView}; use language::{Buffer, BufferSnapshot, LanguageRegistry, LspAdapterDelegate}; use language_model::{LanguageModelCacheConfiguration, LanguageModelRegistry, Role}; use parking_lot::Mutex; @@ -35,7 +35,7 @@ use std::{ sync::{atomic::AtomicBool, Arc}, }; use text::{network::Network, OffsetRangeExt as _, ReplicaId, ToOffset}; -use ui::{Context as _, IconName, WindowContext}; +use ui::{IconName, WindowContext}; use unindent::Unindent; use util::{ test::{generate_marked_text, marked_text_ranges}, diff --git a/crates/copilot/src/copilot_chat.rs b/crates/copilot/src/copilot_chat.rs index daddefb579f907ff9dfaf384b3702a1e57984cb7..cb35b44a077b22ea9f84c5b38e8094464aab68a7 100644 --- a/crates/copilot/src/copilot_chat.rs +++ b/crates/copilot/src/copilot_chat.rs @@ -6,13 +6,12 @@ use anyhow::{anyhow, Result}; use chrono::DateTime; use fs::Fs; use futures::{io::BufReader, stream::BoxStream, AsyncBufReadExt, AsyncReadExt, StreamExt}; -use gpui::{AppContext, AsyncAppContext, Global}; +use gpui::{prelude::*, AppContext, AsyncAppContext, Global}; use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest}; use paths::home_dir; use serde::{Deserialize, Serialize}; use settings::watch_config_file; use strum::EnumIter; -use ui::Context; pub const COPILOT_CHAT_COMPLETION_URL: &str = "https://api.githubcopilot.com/chat/completions"; pub const COPILOT_CHAT_AUTH_URL: &str = "https://api.github.com/copilot_internal/v2/token"; diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index e1c8147d2783e30e953f408e126ee9e2eb0d9c4b..25c419fa62eca2e696bae816219cbd0bd8608d31 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -6661,7 +6661,6 @@ mod tests { use language::language_settings; use log::info; use std::num::NonZeroU32; - use ui::Context; use util::test::sample_text; #[gpui::test] diff --git a/crates/editor/src/git/project_diff.rs b/crates/editor/src/git/project_diff.rs index c1fbbee8b2b27ed48020b030f5f0799f3d436740..e76e5922dbe9a8230fa728e6b1233082262b8349 100644 --- a/crates/editor/src/git/project_diff.rs +++ b/crates/editor/src/git/project_diff.rs @@ -22,10 +22,7 @@ use multi_buffer::{ExcerptId, ExcerptRange, ExpandExcerptDirection, MultiBuffer} use project::{Project, ProjectEntryId, ProjectPath, WorktreeId}; use text::{OffsetRangeExt, ToPoint}; use theme::ActiveTheme; -use ui::{ - div, h_flex, Color, Context, FluentBuilder, Icon, IconName, IntoElement, Label, LabelCommon, - ParentElement, SharedString, Styled, ViewContext, VisualContext, WindowContext, -}; +use ui::prelude::*; use util::{paths::compare_paths, ResultExt}; use workspace::{ item::{BreadcrumbText, Item, ItemEvent, ItemHandle, TabContentParams}, diff --git a/crates/editor/src/inline_completion_tests.rs b/crates/editor/src/inline_completion_tests.rs index b136f8ab1a590283378fcc4ecce8aa94f7a28705..bb6807552605d8a5ee6951b534bd0e3bc7e49e05 100644 --- a/crates/editor/src/inline_completion_tests.rs +++ b/crates/editor/src/inline_completion_tests.rs @@ -1,10 +1,9 @@ -use gpui::Model; +use gpui::{prelude::*, Model}; use indoc::indoc; use inline_completion::InlineCompletionProvider; use multi_buffer::{Anchor, MultiBufferSnapshot, ToPoint}; use std::ops::Range; use text::{Point, ToOffset}; -use ui::Context; use crate::{ editor_tests::init_test, test::editor_test_context::EditorTestContext, InlineCompletion, diff --git a/crates/editor/src/test/editor_test_context.rs b/crates/editor/src/test/editor_test_context.rs index 11b14e812210de4d5956f712319b92bc10518b97..aecdfa91c27eb70f10129df8317069f9b4ef4340 100644 --- a/crates/editor/src/test/editor_test_context.rs +++ b/crates/editor/src/test/editor_test_context.rs @@ -6,8 +6,8 @@ use collections::BTreeMap; use futures::Future; use git::diff::DiffHunkStatus; use gpui::{ - AnyWindowHandle, AppContext, Keystroke, ModelContext, Pixels, Point, View, ViewContext, - VisualTestContext, WindowHandle, + prelude::*, AnyWindowHandle, AppContext, Keystroke, ModelContext, Pixels, Point, View, + ViewContext, VisualTestContext, WindowHandle, }; use itertools::Itertools; use language::{Buffer, BufferSnapshot, LanguageRegistry}; @@ -23,8 +23,6 @@ use std::{ Arc, }, }; - -use ui::Context; use util::{ assert_set_eq, test::{generate_marked_text, marked_text_ranges}, diff --git a/crates/gpui/src/prelude.rs b/crates/gpui/src/prelude.rs index e1cc14e93efa969a00c09465f6a19f1199e70d81..f00b4e958b8bf8e3df4631ff1c5ce06fcc5bd31d 100644 --- a/crates/gpui/src/prelude.rs +++ b/crates/gpui/src/prelude.rs @@ -3,7 +3,7 @@ //! application to avoid having to import each trait individually. pub use crate::{ - util::FluentBuilder, BorrowAppContext, BorrowWindow, Context, Element, FocusableElement, + util::FluentBuilder, BorrowAppContext, BorrowWindow, Context as _, Element, FocusableElement, InteractiveElement, IntoElement, ParentElement, Refineable, Render, RenderOnce, StatefulInteractiveElement, Styled, StyledImage, VisualContext, }; diff --git a/crates/language_model/src/registry.rs b/crates/language_model/src/registry.rs index 88b2e8301c71fab07de844b5db011ea79361196c..94999731a6bf3c4e9581707c9b425428803e507e 100644 --- a/crates/language_model/src/registry.rs +++ b/crates/language_model/src/registry.rs @@ -3,9 +3,8 @@ use crate::{ LanguageModelProviderState, }; use collections::BTreeMap; -use gpui::{AppContext, EventEmitter, Global, Model, ModelContext}; +use gpui::{prelude::*, AppContext, EventEmitter, Global, Model, ModelContext}; use std::sync::Arc; -use ui::Context; pub fn init(cx: &mut AppContext) { let registry = cx.new_model(|_cx| LanguageModelRegistry::default()); diff --git a/crates/language_models/src/provider/copilot_chat.rs b/crates/language_models/src/provider/copilot_chat.rs index 5ae1ad56c5cbfd07e3f6e0b3afa899e879e99e06..e35322d7552bc07aff45f0f8db439dae34509470 100644 --- a/crates/language_models/src/provider/copilot_chat.rs +++ b/crates/language_models/src/provider/copilot_chat.rs @@ -22,11 +22,7 @@ use language_model::{ use settings::SettingsStore; use std::time::Duration; use strum::IntoEnumIterator; -use ui::{ - div, h_flex, v_flex, Button, ButtonCommon, Clickable, Color, Context, FixedWidth, Icon, - IconName, IconPosition, IconSize, IntoElement, Label, LabelCommon, ParentElement, Styled, - ViewContext, VisualContext, WindowContext, -}; +use ui::prelude::*; use super::anthropic::count_anthropic_tokens; use super::open_ai::count_open_ai_tokens; diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 52bbc26111c836500de5ce15a67eacb1a49dcdd5..03a85f74f36e3912bacb43191ae8f22e9e0eac63 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -4262,7 +4262,6 @@ mod tests { use serde_json::json; use settings::SettingsStore; use std::path::{Path, PathBuf}; - use ui::Context; use workspace::{ item::{Item, ProjectItem}, register_project_item, AppState, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index ec6e9015d4ad9fe7148a75cf7bf794ab5b6c4e6d..1569e93094dd557d10efa5babd210399a279efab 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -92,11 +92,7 @@ use task::SpawnInTerminal; use theme::{ActiveTheme, SystemAppearance, ThemeSettings}; pub use toolbar::{Toolbar, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView}; pub use ui; -use ui::{ - div, h_flex, px, BorrowAppContext, Context as _, Div, FluentBuilder, InteractiveElement as _, - IntoElement, ParentElement as _, Pixels, SharedString, Styled as _, ViewContext, - VisualContext as _, WindowContext, -}; +use ui::prelude::*; use util::{paths::SanitizedPath, ResultExt, TryFutureExt}; use uuid::Uuid; pub use workspace_settings::{ @@ -597,7 +593,6 @@ impl AppState { use node_runtime::NodeRuntime; use session::Session; use settings::SettingsStore; - use ui::Context as _; if !cx.has_global::() { let settings_store = SettingsStore::test(cx); @@ -7856,7 +7851,7 @@ mod tests { } mod register_project_item_tests { - use ui::Context as _; + use gpui::Context as _; use super::*;