Dequalify WindowContext and ViewContext references (#22477)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2024-12-28 16:09:55 -07:00 committed by GitHub
parent 016b5d60e1
commit a15360bcc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 43 additions and 51 deletions

View file

@ -281,7 +281,7 @@ fn tab_items_for_queries(
fn active_item_buffer( fn active_item_buffer(
workspace: &mut Workspace, workspace: &mut Workspace,
cx: &mut ui::ViewContext<Workspace>, cx: &mut ViewContext<Workspace>,
) -> anyhow::Result<BufferSnapshot> { ) -> anyhow::Result<BufferSnapshot> {
let active_editor = workspace let active_editor = workspace
.active_item(cx) .active_item(cx)

View file

@ -18,7 +18,7 @@ pub struct UpdateNotification {
impl EventEmitter<DismissEvent> for UpdateNotification {} impl EventEmitter<DismissEvent> for UpdateNotification {}
impl Render 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(); let app_name = ReleaseChannel::global(cx).display_name();
v_flex() v_flex()

View file

@ -1096,7 +1096,7 @@ impl FocusableView for ChatPanel {
} }
impl Panel for ChatPanel { impl Panel for ChatPanel {
fn position(&self, cx: &gpui::WindowContext) -> DockPosition { fn position(&self, cx: &WindowContext) -> DockPosition {
ChatPanelSettings::get_global(cx).dock ChatPanelSettings::get_global(cx).dock
} }
@ -1112,7 +1112,7 @@ impl Panel for ChatPanel {
); );
} }
fn size(&self, cx: &gpui::WindowContext) -> Pixels { fn size(&self, cx: &WindowContext) -> Pixels {
self.width self.width
.unwrap_or_else(|| ChatPanelSettings::get_global(cx).default_width) .unwrap_or_else(|| ChatPanelSettings::get_global(cx).default_width)
} }

View file

@ -2719,7 +2719,7 @@ impl Render for CollabPanel {
impl EventEmitter<PanelEvent> for CollabPanel {} impl EventEmitter<PanelEvent> for CollabPanel {}
impl Panel for CollabPanel { impl Panel for CollabPanel {
fn position(&self, cx: &gpui::WindowContext) -> DockPosition { fn position(&self, cx: &WindowContext) -> DockPosition {
CollaborationPanelSettings::get_global(cx).dock CollaborationPanelSettings::get_global(cx).dock
} }
@ -2735,7 +2735,7 @@ impl Panel for CollabPanel {
); );
} }
fn size(&self, cx: &gpui::WindowContext) -> Pixels { fn size(&self, cx: &WindowContext) -> Pixels {
self.width self.width
.unwrap_or_else(|| CollaborationPanelSettings::get_global(cx).default_width) .unwrap_or_else(|| CollaborationPanelSettings::get_global(cx).default_width)
} }
@ -2746,7 +2746,7 @@ impl Panel for CollabPanel {
cx.notify(); cx.notify();
} }
fn icon(&self, cx: &gpui::WindowContext) -> Option<ui::IconName> { fn icon(&self, cx: &WindowContext) -> Option<ui::IconName> {
CollaborationPanelSettings::get_global(cx) CollaborationPanelSettings::get_global(cx)
.button .button
.then_some(ui::IconName::UserGroup) .then_some(ui::IconName::UserGroup)

View file

@ -662,7 +662,7 @@ impl Panel for NotificationPanel {
"NotificationPanel" "NotificationPanel"
} }
fn position(&self, cx: &gpui::WindowContext) -> DockPosition { fn position(&self, cx: &WindowContext) -> DockPosition {
NotificationPanelSettings::get_global(cx).dock NotificationPanelSettings::get_global(cx).dock
} }
@ -678,7 +678,7 @@ impl Panel for NotificationPanel {
); );
} }
fn size(&self, cx: &gpui::WindowContext) -> Pixels { fn size(&self, cx: &WindowContext) -> Pixels {
self.width self.width
.unwrap_or_else(|| NotificationPanelSettings::get_global(cx).default_width) .unwrap_or_else(|| NotificationPanelSettings::get_global(cx).default_width)
} }
@ -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; let show_button = NotificationPanelSettings::get_global(cx).button;
if !show_button { if !show_button {
return None; return None;

View file

@ -1199,7 +1199,7 @@ impl Panel for GitPanel {
"GitPanel" "GitPanel"
} }
fn position(&self, cx: &gpui::WindowContext) -> DockPosition { fn position(&self, cx: &WindowContext) -> DockPosition {
GitPanelSettings::get_global(cx).dock GitPanelSettings::get_global(cx).dock
} }
@ -1215,7 +1215,7 @@ impl Panel for GitPanel {
); );
} }
fn size(&self, cx: &gpui::WindowContext) -> Pixels { fn size(&self, cx: &WindowContext) -> Pixels {
self.width self.width
.unwrap_or_else(|| GitPanelSettings::get_global(cx).default_width) .unwrap_or_else(|| GitPanelSettings::get_global(cx).default_width)
} }

View file

@ -1,6 +1,6 @@
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use crate::{AnyElement, Element, ElementId, GlobalElementId, IntoElement}; use crate::{AnyElement, Element, ElementId, GlobalElementId, IntoElement, WindowContext};
pub use easing::*; pub use easing::*;
@ -104,7 +104,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
fn request_layout( fn request_layout(
&mut self, &mut self,
global_id: Option<&GlobalElementId>, global_id: Option<&GlobalElementId>,
cx: &mut crate::WindowContext, cx: &mut WindowContext,
) -> (crate::LayoutId, Self::RequestLayoutState) { ) -> (crate::LayoutId, Self::RequestLayoutState) {
cx.with_element_state(global_id.unwrap(), |state, cx| { cx.with_element_state(global_id.unwrap(), |state, cx| {
let state = state.unwrap_or_else(|| AnimationState { let state = state.unwrap_or_else(|| AnimationState {
@ -145,7 +145,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
_id: Option<&GlobalElementId>, _id: Option<&GlobalElementId>,
_bounds: crate::Bounds<crate::Pixels>, _bounds: crate::Bounds<crate::Pixels>,
element: &mut Self::RequestLayoutState, element: &mut Self::RequestLayoutState,
cx: &mut crate::WindowContext, cx: &mut WindowContext,
) -> Self::PrepaintState { ) -> Self::PrepaintState {
element.prepaint(cx); element.prepaint(cx);
} }
@ -156,7 +156,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
_bounds: crate::Bounds<crate::Pixels>, _bounds: crate::Bounds<crate::Pixels>,
element: &mut Self::RequestLayoutState, element: &mut Self::RequestLayoutState,
_: &mut Self::PrepaintState, _: &mut Self::PrepaintState,
cx: &mut crate::WindowContext, cx: &mut WindowContext,
) { ) {
element.paint(cx); element.paint(cx);
} }

View file

@ -716,7 +716,7 @@ impl Element for List {
fn request_layout( fn request_layout(
&mut self, &mut self,
_id: Option<&GlobalElementId>, _id: Option<&GlobalElementId>,
cx: &mut crate::WindowContext, cx: &mut WindowContext,
) -> (crate::LayoutId, Self::RequestLayoutState) { ) -> (crate::LayoutId, Self::RequestLayoutState) {
let layout_id = match self.sizing_behavior { let layout_id = match self.sizing_behavior {
ListSizingBehavior::Infer => { ListSizingBehavior::Infer => {
@ -827,7 +827,7 @@ impl Element for List {
bounds: Bounds<crate::Pixels>, bounds: Bounds<crate::Pixels>,
_: &mut Self::RequestLayoutState, _: &mut Self::RequestLayoutState,
prepaint: &mut Self::PrepaintState, prepaint: &mut Self::PrepaintState,
cx: &mut crate::WindowContext, cx: &mut WindowContext,
) { ) {
cx.with_content_mask(Some(ContentMask { bounds }), |cx| { cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
for item in &mut prepaint.layout.item_layouts { for item in &mut prepaint.layout.item_layouts {

View file

@ -468,7 +468,7 @@ mod test {
use crate::{ use crate::{
self as gpui, div, FocusHandle, InteractiveElement, IntoElement, KeyBinding, Keystroke, self as gpui, div, FocusHandle, InteractiveElement, IntoElement, KeyBinding, Keystroke,
ParentElement, Render, TestAppContext, VisualContext, ParentElement, Render, TestAppContext, ViewContext, VisualContext,
}; };
struct TestView { struct TestView {
@ -480,7 +480,7 @@ mod test {
actions!(test, [TestAction]); actions!(test, [TestAction]);
impl Render for TestView { 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().id("testview").child(
div() div()
.key_context("parent") .key_context("parent")

View file

@ -11,7 +11,7 @@ pub fn derive_render(input: TokenStream) -> TokenStream {
impl #impl_generics gpui::Render for #type_name #type_generics impl #impl_generics gpui::Render for #type_name #type_generics
#where_clause #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 gpui::Empty
} }
} }

View file

@ -273,7 +273,7 @@ impl SyntaxTreeView {
} }
impl Render for 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(); let mut rendered = div().flex_1();
if let Some(layer) = self if let Some(layer) = self

View file

@ -3810,7 +3810,7 @@ fn item_width_estimate(depth: usize, item_text_chars: usize, is_symlink: bool) -
} }
impl Render for ProjectPanel { 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 has_worktree = !self.visible_entries.is_empty();
let project = self.project.read(cx); let project = self.project.read(cx);
let indent_size = ProjectPanelSettings::get_global(cx).indent_size; let indent_size = ProjectPanelSettings::get_global(cx).indent_size;

View file

@ -357,7 +357,7 @@ impl RenderOnce for SshConnectionHeader {
} }
impl Render for SshConnectionModal { 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 nickname = self.prompt.read(cx).nickname.clone();
let connection_string = self.prompt.read(cx).connection_string.clone(); let connection_string = self.prompt.read(cx).connection_string.clone();

View file

@ -196,7 +196,7 @@ impl ProjectIndexDebugView {
} }
impl Render for 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() { if let Some(selected_path) = self.selected_path.as_ref() {
v_flex() v_flex()
.child( .child(

View file

@ -56,7 +56,7 @@ impl FocusStory {
} }
impl Render for 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 theme = cx.theme();
let color_1 = theme.status().created; let color_1 = theme.status().created;
let color_2 = theme.status().modified; let color_2 = theme.status().modified;

View file

@ -45,7 +45,7 @@ impl PickerDelegate for Delegate {
&self, &self,
ix: usize, ix: usize,
selected: bool, selected: bool,
_cx: &mut gpui::ViewContext<Picker<Self>>, _cx: &mut ViewContext<Picker<Self>>,
) -> Option<Self::ListItem> { ) -> Option<Self::ListItem> {
let candidate_ix = self.matches.get(ix)?; let candidate_ix = self.matches.get(ix)?;
// TASK: Make StringMatchCandidate::string a SharedString // TASK: Make StringMatchCandidate::string a SharedString
@ -64,12 +64,12 @@ impl PickerDelegate for Delegate {
self.selected_ix 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; self.selected_ix = ix;
cx.notify(); 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_ix = self.matches[self.selected_ix];
let candidate = self.candidates[candidate_ix].string.clone(); let candidate = self.candidates[candidate_ix].string.clone();
@ -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(); cx.quit();
} }
fn update_matches( fn update_matches(&mut self, query: String, cx: &mut ViewContext<Picker<Self>>) -> Task<()> {
&mut self,
query: String,
cx: &mut gpui::ViewContext<Picker<Self>>,
) -> Task<()> {
let candidates = self.candidates.clone(); let candidates = self.candidates.clone();
self.matches = cx self.matches = cx
.background_executor() .background_executor()
@ -194,7 +190,7 @@ impl PickerStory {
} }
impl Render for 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() div()
.bg(cx.theme().styles.colors.background) .bg(cx.theme().styles.colors.background)
.size_full() .size_full()

View file

@ -11,7 +11,7 @@ impl ScrollStory {
} }
impl Render for 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 theme = cx.theme();
let color_1 = theme.status().created; let color_1 = theme.status().created;
let color_2 = theme.status().modified; let color_2 = theme.status().modified;

View file

@ -1,6 +1,6 @@
use gpui::{ use gpui::{
div, green, red, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, Styled, div, green, red, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, Styled,
StyledText, View, VisualContext, WindowContext, StyledText, View, ViewContext, VisualContext, WindowContext,
}; };
use indoc::indoc; use indoc::indoc;
use story::*; use story::*;
@ -14,7 +14,7 @@ impl TextStory {
} }
impl Render for 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() Story::container()
.child(Story::title("Text")) .child(Story::title("Text"))
.children(vec![ .children(vec![

View file

@ -420,7 +420,7 @@ impl TerminalView {
cx.notify(); 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 //Don't blink the cursor when not focused, blinking is disabled, or paused
if !focused if !focused
|| self.blinking_paused || self.blinking_paused

View file

@ -194,7 +194,7 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
&self, &self,
ix: usize, ix: usize,
selected: bool, selected: bool,
_cx: &mut gpui::ViewContext<Picker<Self>>, _cx: &mut ViewContext<Picker<Self>>,
) -> Option<Self::ListItem> { ) -> Option<Self::ListItem> {
let keymap_match = &self.matches[ix]; let keymap_match = &self.matches[ix];

View file

@ -69,7 +69,7 @@ pub struct WelcomePage {
} }
impl Render for 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() h_flex()
.size_full() .size_full()
.bg(cx.theme().colors().editor_background) .bg(cx.theme().colors().editor_background)

View file

@ -844,7 +844,7 @@ pub mod test {
"TestPanel" "TestPanel"
} }
fn position(&self, _: &gpui::WindowContext) -> super::DockPosition { fn position(&self, _: &WindowContext) -> super::DockPosition {
self.position self.position
} }

View file

@ -1239,11 +1239,7 @@ pub mod test {
None None
} }
fn tab_content( fn tab_content(&self, params: TabContentParams, _cx: &WindowContext) -> AnyElement {
&self,
params: TabContentParams,
_cx: &ui::prelude::WindowContext,
) -> AnyElement {
self.tab_detail.set(params.detail); self.tab_detail.set(params.detail);
gpui::div().into_any_element() gpui::div().into_any_element()
} }

View file

@ -1018,7 +1018,7 @@ mod element {
fn request_layout( fn request_layout(
&mut self, &mut self,
_global_id: Option<&GlobalElementId>, _global_id: Option<&GlobalElementId>,
cx: &mut ui::prelude::WindowContext, cx: &mut WindowContext,
) -> (gpui::LayoutId, Self::RequestLayoutState) { ) -> (gpui::LayoutId, Self::RequestLayoutState) {
let style = Style { let style = Style {
flex_grow: 1., flex_grow: 1.,
@ -1119,7 +1119,7 @@ mod element {
bounds: gpui::Bounds<ui::prelude::Pixels>, bounds: gpui::Bounds<ui::prelude::Pixels>,
_: &mut Self::RequestLayoutState, _: &mut Self::RequestLayoutState,
layout: &mut Self::PrepaintState, layout: &mut Self::PrepaintState,
cx: &mut ui::prelude::WindowContext, cx: &mut WindowContext,
) { ) {
for child in &mut layout.children { for child in &mut layout.children {
child.element.paint(cx); child.element.paint(cx);

View file

@ -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 release_channel = ReleaseChannel::global(cx).display_name();
let version = env!("CARGO_PKG_VERSION"); let version = env!("CARGO_PKG_VERSION");
let message = format!("{release_channel} {version}"); let message = format!("{release_channel} {version}");