Dequalify WindowContext and AsyncWindowContext identifiers (#22444)

Michael Sloan created

This makes a WIP automated refactoring a bit easier to write

Release Notes:

- N/A

Change summary

Cargo.lock                                                   | 1 -
crates/assistant/src/slash_command/auto_command.rs           | 6 +++---
crates/assistant2/src/context_picker/fetch_context_picker.rs | 2 +-
crates/context_server/Cargo.toml                             | 1 -
crates/context_server/src/context_server_tool.rs             | 4 ++--
crates/editor/src/proposed_changes_editor.rs                 | 2 +-
crates/editor/src/scroll/actions.rs                          | 4 ++--
crates/feedback/src/system_specs.rs                          | 3 +--
crates/language_model/src/fake_provider.rs                   | 5 ++---
crates/repl/src/notebook/notebook_ui.rs                      | 2 +-
crates/vim/src/command.rs                                    | 3 +--
crates/workspace/src/item.rs                                 | 5 ++---
12 files changed, 16 insertions(+), 22 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -2928,7 +2928,6 @@ dependencies = [
  "serde_json",
  "settings",
  "smol",
- "ui",
  "url",
  "util",
  "workspace",

crates/assistant/src/slash_command/auto_command.rs 🔗

@@ -5,7 +5,7 @@ use assistant_slash_command::{
 };
 use feature_flags::FeatureFlag;
 use futures::StreamExt;
-use gpui::{AppContext, AsyncAppContext, Task, WeakView};
+use gpui::{AppContext, AsyncAppContext, AsyncWindowContext, Task, WeakView, WindowContext};
 use language::{CodeLabel, LspAdapterDelegate};
 use language_model::{
     LanguageModelCompletionEvent, LanguageModelRegistry, LanguageModelRequest,
@@ -14,7 +14,7 @@ use language_model::{
 use semantic_index::{FileSummary, SemanticDb};
 use smol::channel;
 use std::sync::{atomic::AtomicBool, Arc};
-use ui::{prelude::*, BorrowAppContext, WindowContext};
+use ui::{prelude::*, BorrowAppContext};
 use util::ResultExt;
 use workspace::Workspace;
 
@@ -115,7 +115,7 @@ impl SlashCommand for AutoCommand {
             return Task::ready(Err(anyhow!("no project indexer")));
         };
 
-        let task = cx.spawn(|cx: gpui::AsyncWindowContext| async move {
+        let task = cx.spawn(|cx: AsyncWindowContext| async move {
             let summaries = project_index
                 .read_with(&cx, |project_index, cx| project_index.all_summaries(cx))?
                 .await?;

crates/assistant2/src/context_picker/fetch_context_picker.rs 🔗

@@ -176,7 +176,7 @@ impl PickerDelegate for FetchContextPickerDelegate {
 
     fn set_selected_index(&mut self, _ix: usize, _cx: &mut ViewContext<Picker<Self>>) {}
 
-    fn placeholder_text(&self, _cx: &mut ui::WindowContext) -> Arc<str> {
+    fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc<str> {
         "Enter a URL…".into()
     }
 

crates/context_server/Cargo.toml 🔗

@@ -28,7 +28,6 @@ serde.workspace = true
 serde_json.workspace = true
 settings.workspace = true
 smol.workspace = true
-ui.workspace = true
 url = { workspace = true, features = ["serde"] }
 util.workspace = true
 workspace.workspace = true

crates/context_server/src/context_server_tool.rs 🔗

@@ -2,7 +2,7 @@ use std::sync::Arc;
 
 use anyhow::{anyhow, bail};
 use assistant_tool::Tool;
-use gpui::{Model, Task};
+use gpui::{Model, Task, WindowContext};
 
 use crate::manager::ContextServerManager;
 use crate::types;
@@ -52,7 +52,7 @@ impl Tool for ContextServerTool {
         self: std::sync::Arc<Self>,
         input: serde_json::Value,
         _workspace: gpui::WeakView<workspace::Workspace>,
-        cx: &mut ui::WindowContext,
+        cx: &mut WindowContext,
     ) -> gpui::Task<gpui::Result<String>> {
         if let Some(server) = self.server_manager.read(cx).get_server(&self.server_id) {
             cx.foreground_executor().spawn({

crates/editor/src/proposed_changes_editor.rs 🔗

@@ -288,7 +288,7 @@ impl EventEmitter<EditorEvent> for ProposedChangesEditor {}
 impl Item for ProposedChangesEditor {
     type Event = EditorEvent;
 
-    fn tab_icon(&self, _cx: &ui::WindowContext) -> Option<Icon> {
+    fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {
         Some(Icon::new(IconName::Diff))
     }
 

crates/editor/src/scroll/actions.rs 🔗

@@ -4,7 +4,7 @@ use crate::{
     ScrollAnchor, ScrollCursorBottom, ScrollCursorCenter, ScrollCursorCenterTopBottom,
     ScrollCursorTop, SCROLL_CENTER_TOP_BOTTOM_DEBOUNCE_TIMEOUT,
 };
-use gpui::{Point, ViewContext};
+use gpui::{AsyncWindowContext, Point, ViewContext};
 
 impl Editor {
     pub fn next_screen(&mut self, _: &NextScreen, cx: &mut ViewContext<Editor>) {
@@ -75,7 +75,7 @@ impl Editor {
 
         self.next_scroll_position = self.next_scroll_position.next();
         self._scroll_cursor_center_top_bottom_task =
-            cx.spawn(|editor, mut cx: gpui::AsyncWindowContext| async move {
+            cx.spawn(|editor, mut cx: AsyncWindowContext| async move {
                 cx.background_executor()
                     .timer(SCROLL_CENTER_TOP_BOTTOM_DEBOUNCE_TIMEOUT)
                     .await;

crates/feedback/src/system_specs.rs 🔗

@@ -1,11 +1,10 @@
 use client::telemetry;
-use gpui::Task;
+use gpui::{Task, WindowContext};
 use human_bytes::human_bytes;
 use release_channel::{AppCommitSha, AppVersion, ReleaseChannel};
 use serde::Serialize;
 use std::{env, fmt::Display};
 use sysinfo::{MemoryRefreshKind, RefreshKind, System};
-use ui::WindowContext;
 
 #[derive(Clone, Debug, Serialize)]
 pub struct SystemSpecs {

crates/language_model/src/fake_provider.rs 🔗

@@ -4,12 +4,11 @@ use crate::{
     LanguageModelProviderState, LanguageModelRequest,
 };
 use futures::{channel::mpsc, future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
-use gpui::{AnyView, AppContext, AsyncAppContext, Task};
+use gpui::{AnyView, AppContext, AsyncAppContext, Model, Task, WindowContext};
 use http_client::Result;
 use parking_lot::Mutex;
 use serde::Serialize;
 use std::sync::Arc;
-use ui::WindowContext;
 
 pub fn language_model_id() -> LanguageModelId {
     LanguageModelId::from("fake".to_string())
@@ -33,7 +32,7 @@ pub struct FakeLanguageModelProvider;
 impl LanguageModelProviderState for FakeLanguageModelProvider {
     type ObservableEntity = ();
 
-    fn observable_entity(&self) -> Option<gpui::Model<Self::ObservableEntity>> {
+    fn observable_entity(&self) -> Option<Model<Self::ObservableEntity>> {
         None
     }
 }

crates/repl/src/notebook/notebook_ui.rs 🔗

@@ -673,7 +673,7 @@ impl Item for NotebookEditor {
             .into_any_element()
     }
 
-    fn tab_icon(&self, _cx: &ui::WindowContext) -> Option<Icon> {
+    fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {
         Some(IconName::Book.into())
     }
 

crates/vim/src/command.rs 🔗

@@ -13,13 +13,12 @@ use editor::{
     display_map::ToDisplayPoint,
     Bias, Editor, ToPoint,
 };
-use gpui::{actions, impl_actions, Action, AppContext, Global, ViewContext};
+use gpui::{actions, impl_actions, Action, AppContext, Global, ViewContext, WindowContext};
 use language::Point;
 use multi_buffer::MultiBufferRow;
 use regex::Regex;
 use search::{BufferSearchBar, SearchOptions};
 use serde::Deserialize;
-use ui::WindowContext;
 use util::ResultExt;
 use workspace::{notifications::NotifyResultExt, SaveIntent};
 

crates/workspace/src/item.rs 🔗

@@ -1057,11 +1057,10 @@ pub mod test {
     use gpui::{
         AnyElement, AppContext, Context as _, EntityId, EventEmitter, FocusableView,
         InteractiveElement, IntoElement, Model, Render, SharedString, Task, View, ViewContext,
-        VisualContext, WeakView,
+        VisualContext, WeakView, WindowContext,
     };
     use project::{Project, ProjectEntryId, ProjectPath, WorktreeId};
     use std::{any::Any, cell::Cell, path::Path};
-    use ui::WindowContext;
 
     pub struct TestProjectItem {
         pub entry_id: Option<ProjectEntryId>,
@@ -1376,7 +1375,7 @@ pub mod test {
         fn cleanup(
             _workspace_id: WorkspaceId,
             _alive_items: Vec<ItemId>,
-            _cx: &mut ui::WindowContext,
+            _cx: &mut WindowContext,
         ) -> Task<anyhow::Result<()>> {
             Task::ready(Ok(()))
         }