Skip to content

Commit

Permalink
Dequalify WindowContext and ViewContext references (#22477)
Browse files Browse the repository at this point in the history
Release Notes:

- N/A
  • Loading branch information
mgsloan authored Dec 28, 2024
1 parent 016b5d6 commit a15360b
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 51 deletions.
2 changes: 1 addition & 1 deletion crates/assistant/src/slash_command/tab_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn tab_items_for_queries(

fn active_item_buffer(
workspace: &mut Workspace,
cx: &mut ui::ViewContext<Workspace>,
cx: &mut ViewContext<Workspace>,
) -> anyhow::Result<BufferSnapshot> {
let active_editor = workspace
.active_item(cx)
Expand Down
2 changes: 1 addition & 1 deletion crates/auto_update_ui/src/update_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct UpdateNotification {
impl EventEmitter<DismissEvent> for UpdateNotification {}

impl Render for UpdateNotification {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let app_name = ReleaseChannel::global(cx).display_name();

v_flex()
Expand Down
4 changes: 2 additions & 2 deletions crates/collab_ui/src/chat_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ impl FocusableView for ChatPanel {
}

impl Panel for ChatPanel {
fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
fn position(&self, cx: &WindowContext) -> DockPosition {
ChatPanelSettings::get_global(cx).dock
}

Expand All @@ -1112,7 +1112,7 @@ impl Panel for ChatPanel {
);
}

fn size(&self, cx: &gpui::WindowContext) -> Pixels {
fn size(&self, cx: &WindowContext) -> Pixels {
self.width
.unwrap_or_else(|| ChatPanelSettings::get_global(cx).default_width)
}
Expand Down
6 changes: 3 additions & 3 deletions crates/collab_ui/src/collab_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,7 @@ impl Render for CollabPanel {
impl EventEmitter<PanelEvent> for CollabPanel {}

impl Panel for CollabPanel {
fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
fn position(&self, cx: &WindowContext) -> DockPosition {
CollaborationPanelSettings::get_global(cx).dock
}

Expand All @@ -2735,7 +2735,7 @@ impl Panel for CollabPanel {
);
}

fn size(&self, cx: &gpui::WindowContext) -> Pixels {
fn size(&self, cx: &WindowContext) -> Pixels {
self.width
.unwrap_or_else(|| CollaborationPanelSettings::get_global(cx).default_width)
}
Expand All @@ -2746,7 +2746,7 @@ impl Panel for CollabPanel {
cx.notify();
}

fn icon(&self, cx: &gpui::WindowContext) -> Option<ui::IconName> {
fn icon(&self, cx: &WindowContext) -> Option<ui::IconName> {
CollaborationPanelSettings::get_global(cx)
.button
.then_some(ui::IconName::UserGroup)
Expand Down
6 changes: 3 additions & 3 deletions crates/collab_ui/src/notification_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ impl Panel for NotificationPanel {
"NotificationPanel"
}

fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
fn position(&self, cx: &WindowContext) -> DockPosition {
NotificationPanelSettings::get_global(cx).dock
}

Expand All @@ -678,7 +678,7 @@ impl Panel for NotificationPanel {
);
}

fn size(&self, cx: &gpui::WindowContext) -> Pixels {
fn size(&self, cx: &WindowContext) -> Pixels {
self.width
.unwrap_or_else(|| NotificationPanelSettings::get_global(cx).default_width)
}
Expand All @@ -702,7 +702,7 @@ impl Panel for NotificationPanel {
}
}

fn icon(&self, cx: &gpui::WindowContext) -> Option<IconName> {
fn icon(&self, cx: &WindowContext) -> Option<IconName> {
let show_button = NotificationPanelSettings::get_global(cx).button;
if !show_button {
return None;
Expand Down
4 changes: 2 additions & 2 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ impl Panel for GitPanel {
"GitPanel"
}

fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
fn position(&self, cx: &WindowContext) -> DockPosition {
GitPanelSettings::get_global(cx).dock
}

Expand All @@ -1215,7 +1215,7 @@ impl Panel for GitPanel {
);
}

fn size(&self, cx: &gpui::WindowContext) -> Pixels {
fn size(&self, cx: &WindowContext) -> Pixels {
self.width
.unwrap_or_else(|| GitPanelSettings::get_global(cx).default_width)
}
Expand Down
8 changes: 4 additions & 4 deletions crates/gpui/src/elements/animation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::{Duration, Instant};

use crate::{AnyElement, Element, ElementId, GlobalElementId, IntoElement};
use crate::{AnyElement, Element, ElementId, GlobalElementId, IntoElement, WindowContext};

pub use easing::*;

Expand Down Expand Up @@ -104,7 +104,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
fn request_layout(
&mut self,
global_id: Option<&GlobalElementId>,
cx: &mut crate::WindowContext,
cx: &mut WindowContext,
) -> (crate::LayoutId, Self::RequestLayoutState) {
cx.with_element_state(global_id.unwrap(), |state, cx| {
let state = state.unwrap_or_else(|| AnimationState {
Expand Down Expand Up @@ -145,7 +145,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
_id: Option<&GlobalElementId>,
_bounds: crate::Bounds<crate::Pixels>,
element: &mut Self::RequestLayoutState,
cx: &mut crate::WindowContext,
cx: &mut WindowContext,
) -> Self::PrepaintState {
element.prepaint(cx);
}
Expand All @@ -156,7 +156,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
_bounds: crate::Bounds<crate::Pixels>,
element: &mut Self::RequestLayoutState,
_: &mut Self::PrepaintState,
cx: &mut crate::WindowContext,
cx: &mut WindowContext,
) {
element.paint(cx);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui/src/elements/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ impl Element for List {
fn request_layout(
&mut self,
_id: Option<&GlobalElementId>,
cx: &mut crate::WindowContext,
cx: &mut WindowContext,
) -> (crate::LayoutId, Self::RequestLayoutState) {
let layout_id = match self.sizing_behavior {
ListSizingBehavior::Infer => {
Expand Down Expand Up @@ -827,7 +827,7 @@ impl Element for List {
bounds: Bounds<crate::Pixels>,
_: &mut Self::RequestLayoutState,
prepaint: &mut Self::PrepaintState,
cx: &mut crate::WindowContext,
cx: &mut WindowContext,
) {
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
for item in &mut prepaint.layout.item_layouts {
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui/src/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ mod test {

use crate::{
self as gpui, div, FocusHandle, InteractiveElement, IntoElement, KeyBinding, Keystroke,
ParentElement, Render, TestAppContext, VisualContext,
ParentElement, Render, TestAppContext, ViewContext, VisualContext,
};

struct TestView {
Expand All @@ -480,7 +480,7 @@ mod test {
actions!(test, [TestAction]);

impl Render for TestView {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div().id("testview").child(
div()
.key_context("parent")
Expand Down
2 changes: 1 addition & 1 deletion crates/gpui_macros/src/derive_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn derive_render(input: TokenStream) -> TokenStream {
impl #impl_generics gpui::Render for #type_name #type_generics
#where_clause
{
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> impl gpui::Element {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl gpui::Element {
gpui::Empty
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/language_tools/src/syntax_tree_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl SyntaxTreeView {
}

impl Render for SyntaxTreeView {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let mut rendered = div().flex_1();

if let Some(layer) = self
Expand Down
2 changes: 1 addition & 1 deletion crates/project_panel/src/project_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3810,7 +3810,7 @@ fn item_width_estimate(depth: usize, item_text_chars: usize, is_symlink: bool) -
}

impl Render for ProjectPanel {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let has_worktree = !self.visible_entries.is_empty();
let project = self.project.read(cx);
let indent_size = ProjectPanelSettings::get_global(cx).indent_size;
Expand Down
2 changes: 1 addition & 1 deletion crates/recent_projects/src/ssh_connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ impl RenderOnce for SshConnectionHeader {
}

impl Render for SshConnectionModal {
fn render(&mut self, cx: &mut ui::ViewContext<Self>) -> impl ui::IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl ui::IntoElement {
let nickname = self.prompt.read(cx).nickname.clone();
let connection_string = self.prompt.read(cx).connection_string.clone();

Expand Down
2 changes: 1 addition & 1 deletion crates/semantic_index/src/project_index_debug_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl ProjectIndexDebugView {
}

impl Render for ProjectIndexDebugView {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
if let Some(selected_path) = self.selected_path.as_ref() {
v_flex()
.child(
Expand Down
2 changes: 1 addition & 1 deletion crates/storybook/src/stories/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl FocusStory {
}

impl Render for FocusStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let theme = cx.theme();
let color_1 = theme.status().created;
let color_2 = theme.status().modified;
Expand Down
16 changes: 6 additions & 10 deletions crates/storybook/src/stories/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl PickerDelegate for Delegate {
&self,
ix: usize,
selected: bool,
_cx: &mut gpui::ViewContext<Picker<Self>>,
_cx: &mut ViewContext<Picker<Self>>,
) -> Option<Self::ListItem> {
let candidate_ix = self.matches.get(ix)?;
// TASK: Make StringMatchCandidate::string a SharedString
Expand All @@ -64,12 +64,12 @@ impl PickerDelegate for Delegate {
self.selected_ix
}

fn set_selected_index(&mut self, ix: usize, cx: &mut gpui::ViewContext<Picker<Self>>) {
fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Picker<Self>>) {
self.selected_ix = ix;
cx.notify();
}

fn confirm(&mut self, secondary: bool, _cx: &mut gpui::ViewContext<Picker<Self>>) {
fn confirm(&mut self, secondary: bool, _cx: &mut ViewContext<Picker<Self>>) {
let candidate_ix = self.matches[self.selected_ix];
let candidate = self.candidates[candidate_ix].string.clone();

Expand All @@ -80,15 +80,11 @@ impl PickerDelegate for Delegate {
}
}

fn dismissed(&mut self, cx: &mut gpui::ViewContext<Picker<Self>>) {
fn dismissed(&mut self, cx: &mut ViewContext<Picker<Self>>) {
cx.quit();
}

fn update_matches(
&mut self,
query: String,
cx: &mut gpui::ViewContext<Picker<Self>>,
) -> Task<()> {
fn update_matches(&mut self, query: String, cx: &mut ViewContext<Picker<Self>>) -> Task<()> {
let candidates = self.candidates.clone();
self.matches = cx
.background_executor()
Expand Down Expand Up @@ -194,7 +190,7 @@ impl PickerStory {
}

impl Render for PickerStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
.bg(cx.theme().styles.colors.background)
.size_full()
Expand Down
2 changes: 1 addition & 1 deletion crates/storybook/src/stories/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl ScrollStory {
}

impl Render for ScrollStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let theme = cx.theme();
let color_1 = theme.status().created;
let color_2 = theme.status().modified;
Expand Down
4 changes: 2 additions & 2 deletions crates/storybook/src/stories/text.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gpui::{
div, green, red, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, Styled,
StyledText, View, VisualContext, WindowContext,
StyledText, View, ViewContext, VisualContext, WindowContext,
};
use indoc::indoc;
use story::*;
Expand All @@ -14,7 +14,7 @@ impl TextStory {
}

impl Render for TextStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container()
.child(Story::title("Text"))
.children(vec![
Expand Down
2 changes: 1 addition & 1 deletion crates/terminal_view/src/terminal_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl TerminalView {
cx.notify();
}

pub fn should_show_cursor(&self, focused: bool, cx: &mut gpui::ViewContext<Self>) -> bool {
pub fn should_show_cursor(&self, focused: bool, cx: &mut ViewContext<Self>) -> bool {
//Don't blink the cursor when not focused, blinking is disabled, or paused
if !focused
|| self.blinking_paused
Expand Down
2 changes: 1 addition & 1 deletion crates/welcome/src/base_keymap_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
&self,
ix: usize,
selected: bool,
_cx: &mut gpui::ViewContext<Picker<Self>>,
_cx: &mut ViewContext<Picker<Self>>,
) -> Option<Self::ListItem> {
let keymap_match = &self.matches[ix];

Expand Down
2 changes: 1 addition & 1 deletion crates/welcome/src/welcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct WelcomePage {
}

impl Render for WelcomePage {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
h_flex()
.size_full()
.bg(cx.theme().colors().editor_background)
Expand Down
2 changes: 1 addition & 1 deletion crates/workspace/src/dock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ pub mod test {
"TestPanel"
}

fn position(&self, _: &gpui::WindowContext) -> super::DockPosition {
fn position(&self, _: &WindowContext) -> super::DockPosition {
self.position
}

Expand Down
6 changes: 1 addition & 5 deletions crates/workspace/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,11 +1239,7 @@ pub mod test {
None
}

fn tab_content(
&self,
params: TabContentParams,
_cx: &ui::prelude::WindowContext,
) -> AnyElement {
fn tab_content(&self, params: TabContentParams, _cx: &WindowContext) -> AnyElement {
self.tab_detail.set(params.detail);
gpui::div().into_any_element()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/workspace/src/pane_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ mod element {
fn request_layout(
&mut self,
_global_id: Option<&GlobalElementId>,
cx: &mut ui::prelude::WindowContext,
cx: &mut WindowContext,
) -> (gpui::LayoutId, Self::RequestLayoutState) {
let style = Style {
flex_grow: 1.,
Expand Down Expand Up @@ -1119,7 +1119,7 @@ mod element {
bounds: gpui::Bounds<ui::prelude::Pixels>,
_: &mut Self::RequestLayoutState,
layout: &mut Self::PrepaintState,
cx: &mut ui::prelude::WindowContext,
cx: &mut WindowContext,
) {
for child in &mut layout.children {
child.element.paint(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/zed/src/zed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ fn initialize_pane(workspace: &Workspace, pane: &View<Pane>, cx: &mut ViewContex
});
}

fn about(_: &mut Workspace, _: &zed_actions::About, cx: &mut gpui::ViewContext<Workspace>) {
fn about(_: &mut Workspace, _: &zed_actions::About, cx: &mut ViewContext<Workspace>) {
let release_channel = ReleaseChannel::global(cx).display_name();
let version = env!("CARGO_PKG_VERSION");
let message = format!("{release_channel} {version}");
Expand Down

0 comments on commit a15360b

Please sign in to comment.