Fix missed renames in #22632 (#23688)

Fix a bug where a GPUI macro still used `ModelContext`
Rename `AsyncAppContext` -> `AsyncApp`
Rename update_model, read_model, insert_model, and reserve_model to
update_entity, read_entity, insert_entity, and reserve_entity

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-01-26 15:37:34 -08:00 committed by GitHub
parent 83141d07e9
commit a6b1514246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
118 changed files with 708 additions and 757 deletions

1
Cargo.lock generated
View file

@ -5464,6 +5464,7 @@ dependencies = [
name = "gpui_macros" name = "gpui_macros"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"gpui",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",

View file

@ -4,7 +4,7 @@ use std::sync::Arc;
use anyhow::{anyhow, bail, Result}; use anyhow::{anyhow, bail, Result};
use collections::{BTreeMap, HashMap, HashSet}; use collections::{BTreeMap, HashMap, HashSet};
use futures::{self, future, Future, FutureExt}; use futures::{self, future, Future, FutureExt};
use gpui::{App, AsyncAppContext, Context, Entity, SharedString, Task, WeakEntity}; use gpui::{App, AsyncApp, Context, Entity, SharedString, Task, WeakEntity};
use language::Buffer; use language::Buffer;
use project::{ProjectPath, Worktree}; use project::{ProjectPath, Worktree};
use rope::Rope; use rope::Rope;
@ -447,7 +447,7 @@ fn collect_buffer_info_and_text(
path: Arc<Path>, path: Arc<Path>,
buffer_model: Entity<Buffer>, buffer_model: Entity<Buffer>,
buffer: &Buffer, buffer: &Buffer,
cx: AsyncAppContext, cx: AsyncApp,
) -> (BufferInfo, Task<SharedString>) { ) -> (BufferInfo, Task<SharedString>) {
let buffer_info = BufferInfo { let buffer_info = BufferInfo {
id: buffer.remote_id(), id: buffer.remote_id(),

View file

@ -1217,7 +1217,7 @@ impl ContextEditor {
let project = this.update(&mut cx, |this, _| this.project.clone())?; let project = this.update(&mut cx, |this, _| this.project.clone())?;
let resolved_patch = patch.resolve(project.clone(), &mut cx).await; let resolved_patch = patch.resolve(project.clone(), &mut cx).await;
let editor = cx.new_window_model(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
let editor = ProposedChangesEditor::new( let editor = ProposedChangesEditor::new(
patch.title.clone(), patch.title.clone(),
resolved_patch resolved_patch

View file

@ -13,9 +13,7 @@ use context_server::{ContextServerFactoryRegistry, ContextServerTool};
use fs::Fs; use fs::Fs;
use futures::StreamExt; use futures::StreamExt;
use fuzzy::StringMatchCandidate; use fuzzy::StringMatchCandidate;
use gpui::{ use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Task, WeakEntity,
};
use language::LanguageRegistry; use language::LanguageRegistry;
use paths::contexts_dir; use paths::contexts_dir;
use project::Project; use project::Project;
@ -165,7 +163,7 @@ impl ContextStore {
async fn handle_advertise_contexts( async fn handle_advertise_contexts(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::AdvertiseContexts>, envelope: TypedEnvelope<proto::AdvertiseContexts>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.host_contexts = envelope this.host_contexts = envelope
@ -184,7 +182,7 @@ impl ContextStore {
async fn handle_open_context( async fn handle_open_context(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::OpenContext>, envelope: TypedEnvelope<proto::OpenContext>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenContextResponse> { ) -> Result<proto::OpenContextResponse> {
let context_id = ContextId::from_proto(envelope.payload.context_id); let context_id = ContextId::from_proto(envelope.payload.context_id);
let operations = this.update(&mut cx, |this, cx| { let operations = this.update(&mut cx, |this, cx| {
@ -214,7 +212,7 @@ impl ContextStore {
async fn handle_create_context( async fn handle_create_context(
this: Entity<Self>, this: Entity<Self>,
_: TypedEnvelope<proto::CreateContext>, _: TypedEnvelope<proto::CreateContext>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::CreateContextResponse> { ) -> Result<proto::CreateContextResponse> {
let (context_id, operations) = this.update(&mut cx, |this, cx| { let (context_id, operations) = this.update(&mut cx, |this, cx| {
if this.project.read(cx).is_via_collab() { if this.project.read(cx).is_via_collab() {
@ -242,7 +240,7 @@ impl ContextStore {
async fn handle_update_context( async fn handle_update_context(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateContext>, envelope: TypedEnvelope<proto::UpdateContext>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let context_id = ContextId::from_proto(envelope.payload.context_id); let context_id = ContextId::from_proto(envelope.payload.context_id);
@ -258,7 +256,7 @@ impl ContextStore {
async fn handle_synchronize_contexts( async fn handle_synchronize_contexts(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::SynchronizeContexts>, envelope: TypedEnvelope<proto::SynchronizeContexts>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::SynchronizeContextsResponse> { ) -> Result<proto::SynchronizeContextsResponse> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
if this.project.read(cx).is_via_collab() { if this.project.read(cx).is_via_collab() {
@ -791,7 +789,7 @@ impl ContextStore {
} }
pub fn restart_context_servers(&mut self, cx: &mut Context<Self>) { pub fn restart_context_servers(&mut self, cx: &mut Context<Self>) {
cx.update_model( cx.update_entity(
&self.context_server_manager, &self.context_server_manager,
|context_server_manager, cx| { |context_server_manager, cx| {
for server in context_server_manager.servers() { for server in context_server_manager.servers() {

View file

@ -2,7 +2,7 @@ use anyhow::{anyhow, Context as _, Result};
use collections::HashMap; use collections::HashMap;
use editor::ProposedChangesEditor; use editor::ProposedChangesEditor;
use futures::{future, TryFutureExt as _}; use futures::{future, TryFutureExt as _};
use gpui::{App, AsyncAppContext, Entity, SharedString}; use gpui::{App, AsyncApp, Entity, SharedString};
use language::{AutoindentMode, Buffer, BufferSnapshot}; use language::{AutoindentMode, Buffer, BufferSnapshot};
use project::{Project, ProjectPath}; use project::{Project, ProjectPath};
use std::{cmp, ops::Range, path::Path, sync::Arc}; use std::{cmp, ops::Range, path::Path, sync::Arc};
@ -229,7 +229,7 @@ impl AssistantEdit {
pub async fn resolve( pub async fn resolve(
&self, &self,
project: Entity<Project>, project: Entity<Project>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<(Entity<Buffer>, ResolvedEdit)> { ) -> Result<(Entity<Buffer>, ResolvedEdit)> {
let path = self.path.clone(); let path = self.path.clone();
let kind = self.kind.clone(); let kind = self.kind.clone();
@ -421,11 +421,7 @@ impl AssistantEditKind {
} }
impl AssistantPatch { impl AssistantPatch {
pub async fn resolve( pub async fn resolve(&self, project: Entity<Project>, cx: &mut AsyncApp) -> ResolvedPatch {
&self,
project: Entity<Project>,
cx: &mut AsyncAppContext,
) -> ResolvedPatch {
let mut resolve_tasks = Vec::new(); let mut resolve_tasks = Vec::new();
for (ix, edit) in self.edits.iter().enumerate() { for (ix, edit) in self.edits.iter().enumerate() {
if let Ok(edit) = edit.as_ref() { if let Ok(edit) = edit.as_ref() {

View file

@ -5,7 +5,7 @@ use assistant_slash_command::{
}; };
use feature_flags::FeatureFlag; use feature_flags::FeatureFlag;
use futures::StreamExt; use futures::StreamExt;
use gpui::{App, AsyncAppContext, Task, WeakEntity, Window}; use gpui::{App, AsyncApp, Task, WeakEntity, Window};
use language::{CodeLabel, LspAdapterDelegate}; use language::{CodeLabel, LspAdapterDelegate};
use language_model::{ use language_model::{
LanguageModelCompletionEvent, LanguageModelRegistry, LanguageModelRequest, LanguageModelCompletionEvent, LanguageModelRegistry, LanguageModelRequest,
@ -77,7 +77,7 @@ impl SlashCommand for AutoCommand {
let cx: &mut App = cx; let cx: &mut App = cx;
cx.spawn(|cx: gpui::AsyncAppContext| async move { cx.spawn(|cx: gpui::AsyncApp| async move {
let task = project_index.read_with(&cx, |project_index, cx| { let task = project_index.read_with(&cx, |project_index, cx| {
project_index.flush_summary_backlogs(cx) project_index.flush_summary_backlogs(cx)
})?; })?;
@ -189,7 +189,7 @@ struct CommandToRun {
async fn commands_for_summaries( async fn commands_for_summaries(
summaries: &[FileSummary], summaries: &[FileSummary],
original_prompt: &str, original_prompt: &str,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Result<Vec<CommandToRun>> { ) -> Result<Vec<CommandToRun>> {
if summaries.is_empty() { if summaries.is_empty() {
log::warn!("Inferring no context because there were no summaries available."); log::warn!("Inferring no context because there were no summaries available.");

View file

@ -303,7 +303,7 @@ fn collect_diagnostics(
.await .await
.log_err() .log_err()
{ {
let snapshot = cx.read_model(&buffer, |buffer, _| buffer.snapshot())?; let snapshot = cx.read_entity(&buffer, |buffer, _| buffer.snapshot())?;
collect_buffer_diagnostics(&mut output, &snapshot, options.include_warnings); collect_buffer_diagnostics(&mut output, &snapshot, options.include_warnings);
} }

View file

@ -3,8 +3,7 @@ use client::{Client, TelemetrySettings};
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use db::RELEASE_CHANNEL; use db::RELEASE_CHANNEL;
use gpui::{ use gpui::{
actions, App, AppContext as _, AsyncAppContext, Context, Entity, Global, SemanticVersion, Task, actions, App, AppContext as _, AsyncApp, Context, Entity, Global, SemanticVersion, Task, Window,
Window,
}; };
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl}; use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
use paths::remote_servers_dir; use paths::remote_servers_dir;
@ -303,7 +302,7 @@ impl AutoUpdater {
arch: &str, arch: &str,
release_channel: ReleaseChannel, release_channel: ReleaseChannel,
version: Option<SemanticVersion>, version: Option<SemanticVersion>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
let this = cx.update(|cx| { let this = cx.update(|cx| {
cx.default_global::<GlobalAutoUpdate>() cx.default_global::<GlobalAutoUpdate>()
@ -347,7 +346,7 @@ impl AutoUpdater {
arch: &str, arch: &str,
release_channel: ReleaseChannel, release_channel: ReleaseChannel,
version: Option<SemanticVersion>, version: Option<SemanticVersion>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Option<(String, String)>> { ) -> Result<Option<(String, String)>> {
let this = cx.update(|cx| { let this = cx.update(|cx| {
cx.default_global::<GlobalAutoUpdate>() cx.default_global::<GlobalAutoUpdate>()
@ -380,7 +379,7 @@ impl AutoUpdater {
arch: &str, arch: &str,
version: Option<SemanticVersion>, version: Option<SemanticVersion>,
release_channel: Option<ReleaseChannel>, release_channel: Option<ReleaseChannel>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<JsonRelease> { ) -> Result<JsonRelease> {
let client = this.read_with(cx, |this, _| this.http_client.clone())?; let client = this.read_with(cx, |this, _| this.http_client.clone())?;
@ -429,12 +428,12 @@ impl AutoUpdater {
os: &str, os: &str,
arch: &str, arch: &str,
release_channel: Option<ReleaseChannel>, release_channel: Option<ReleaseChannel>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<JsonRelease> { ) -> Result<JsonRelease> {
Self::get_release(this, asset, os, arch, None, release_channel, cx).await Self::get_release(this, asset, os, arch, None, release_channel, cx).await
} }
async fn update(this: Entity<Self>, mut cx: AsyncAppContext) -> Result<()> { async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
let (client, current_version, release_channel) = this.update(&mut cx, |this, cx| { let (client, current_version, release_channel) = this.update(&mut cx, |this, cx| {
this.status = AutoUpdateStatus::Checking; this.status = AutoUpdateStatus::Checking;
cx.notify(); cx.notify();
@ -544,7 +543,7 @@ async fn download_remote_server_binary(
target_path: &PathBuf, target_path: &PathBuf,
release: JsonRelease, release: JsonRelease,
client: Arc<HttpClientWithUrl>, client: Arc<HttpClientWithUrl>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Result<()> { ) -> Result<()> {
let temp = tempfile::Builder::new().tempfile_in(remote_servers_dir())?; let temp = tempfile::Builder::new().tempfile_in(remote_servers_dir())?;
let mut temp_file = File::create(&temp).await?; let mut temp_file = File::create(&temp).await?;
@ -564,7 +563,7 @@ async fn download_remote_server_binary(
Ok(()) Ok(())
} }
fn build_remote_server_update_request_body(cx: &AsyncAppContext) -> Result<UpdateRequestBody> { fn build_remote_server_update_request_body(cx: &AsyncApp) -> Result<UpdateRequestBody> {
let (installation_id, release_channel, telemetry_enabled, is_staff) = cx.update(|cx| { let (installation_id, release_channel, telemetry_enabled, is_staff) = cx.update(|cx| {
let telemetry = Client::global(cx).telemetry().clone(); let telemetry = Client::global(cx).telemetry().clone();
let is_staff = telemetry.is_staff(); let is_staff = telemetry.is_staff();
@ -594,7 +593,7 @@ async fn download_release(
target_path: &Path, target_path: &Path,
release: JsonRelease, release: JsonRelease,
client: Arc<HttpClientWithUrl>, client: Arc<HttpClientWithUrl>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Result<()> { ) -> Result<()> {
let mut target_file = File::create(&target_path).await?; let mut target_file = File::create(&target_path).await?;
@ -632,7 +631,7 @@ async fn download_release(
async fn install_release_linux( async fn install_release_linux(
temp_dir: &tempfile::TempDir, temp_dir: &tempfile::TempDir,
downloaded_tar_gz: PathBuf, downloaded_tar_gz: PathBuf,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
let channel = cx.update(|cx| ReleaseChannel::global(cx).dev_name())?; let channel = cx.update(|cx| ReleaseChannel::global(cx).dev_name())?;
let home_dir = PathBuf::from(env::var("HOME").context("no HOME env var set")?); let home_dir = PathBuf::from(env::var("HOME").context("no HOME env var set")?);
@ -699,7 +698,7 @@ async fn install_release_linux(
async fn install_release_macos( async fn install_release_macos(
temp_dir: &tempfile::TempDir, temp_dir: &tempfile::TempDir,
downloaded_dmg: PathBuf, downloaded_dmg: PathBuf,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
let running_app_path = cx.update(|cx| cx.app_path())??; let running_app_path = cx.update(|cx| cx.app_path())??;
let running_app_filename = running_app_path let running_app_filename = running_app_path

View file

@ -8,8 +8,8 @@ use client::{proto, ChannelId, Client, TypedEnvelope, User, UserStore, ZED_ALWAY
use collections::HashSet; use collections::HashSet;
use futures::{channel::oneshot, future::Shared, Future, FutureExt}; use futures::{channel::oneshot, future::Shared, Future, FutureExt};
use gpui::{ use gpui::{
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Global, Subscription, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Global, Subscription, Task,
Task, WeakEntity, WeakEntity,
}; };
use postage::watch; use postage::watch;
use project::Project; use project::Project;
@ -48,7 +48,7 @@ impl OneAtATime {
/// otherwise you'll see the result of the task. /// otherwise you'll see the result of the task.
fn spawn<F, Fut, R>(&mut self, cx: &mut App, f: F) -> Task<Result<Option<R>>> fn spawn<F, Fut, R>(&mut self, cx: &mut App, f: F) -> Task<Result<Option<R>>>
where where
F: 'static + FnOnce(AsyncAppContext) -> Fut, F: 'static + FnOnce(AsyncApp) -> Fut,
Fut: Future<Output = Result<R>>, Fut: Future<Output = Result<R>>,
R: 'static, R: 'static,
{ {
@ -120,7 +120,7 @@ impl ActiveCall {
async fn handle_incoming_call( async fn handle_incoming_call(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::IncomingCall>, envelope: TypedEnvelope<proto::IncomingCall>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?; let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
let call = IncomingCall { let call = IncomingCall {
@ -147,7 +147,7 @@ impl ActiveCall {
async fn handle_call_canceled( async fn handle_call_canceled(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::CallCanceled>, envelope: TypedEnvelope<proto::CallCanceled>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, _| {
let mut incoming_call = this.incoming_call.0.borrow_mut(); let mut incoming_call = this.incoming_call.0.borrow_mut();

View file

@ -13,7 +13,7 @@ use client::{
use collections::{BTreeMap, HashMap, HashSet}; use collections::{BTreeMap, HashMap, HashSet};
use fs::Fs; use fs::Fs;
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
use gpui::{App, AppContext, AsyncAppContext, Context, Entity, EventEmitter, Task, WeakEntity}; use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
use language::LanguageRegistry; use language::LanguageRegistry;
#[cfg(not(all(target_os = "windows", target_env = "gnu")))] #[cfg(not(all(target_os = "windows", target_env = "gnu")))]
use livekit::{ use livekit::{
@ -218,7 +218,7 @@ impl Room {
channel_id: ChannelId, channel_id: ChannelId,
client: Arc<Client>, client: Arc<Client>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
Self::from_join_response( Self::from_join_response(
client client
@ -236,7 +236,7 @@ impl Room {
room_id: u64, room_id: u64,
client: Arc<Client>, client: Arc<Client>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
Self::from_join_response( Self::from_join_response(
client.request(proto::JoinRoom { id: room_id }).await?, client.request(proto::JoinRoom { id: room_id }).await?,
@ -277,7 +277,7 @@ impl Room {
response: proto::JoinRoomResponse, response: proto::JoinRoomResponse,
client: Arc<Client>, client: Arc<Client>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?; let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
let room = cx.new(|cx| { let room = cx.new(|cx| {
@ -358,7 +358,7 @@ impl Room {
async fn maintain_connection( async fn maintain_connection(
this: WeakEntity<Self>, this: WeakEntity<Self>,
client: Arc<Client>, client: Arc<Client>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let mut client_status = client.status(); let mut client_status = client.status();
loop { loop {
@ -639,7 +639,7 @@ impl Room {
async fn handle_room_updated( async fn handle_room_updated(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::RoomUpdated>, envelope: TypedEnvelope<proto::RoomUpdated>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let room = envelope let room = envelope
.payload .payload
@ -1318,7 +1318,7 @@ impl Room {
} }
#[cfg(all(target_os = "windows", target_env = "gnu"))] #[cfg(all(target_os = "windows", target_env = "gnu"))]
pub fn share_microphone(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> { pub fn share_microphone(&mut self, cx: &mut Context<Self>) -> Task<Result<()>> {
Task::ready(Err(anyhow!("MinGW is not supported yet"))) Task::ready(Err(anyhow!("MinGW is not supported yet")))
} }
@ -1626,7 +1626,7 @@ impl Room {
#[cfg(all(target_os = "windows", target_env = "gnu"))] #[cfg(all(target_os = "windows", target_env = "gnu"))]
fn spawn_room_connection( fn spawn_room_connection(
livekit_connection_info: Option<proto::LiveKitConnectionInfo>, livekit_connection_info: Option<proto::LiveKitConnectionInfo>,
cx: &mut ModelContext<'_, Room>, cx: &mut Context<'_, Room>,
) { ) {
} }

View file

@ -8,8 +8,8 @@ use client::{proto, ChannelId, Client, TypedEnvelope, User, UserStore, ZED_ALWAY
use collections::HashSet; use collections::HashSet;
use futures::{channel::oneshot, future::Shared, Future, FutureExt}; use futures::{channel::oneshot, future::Shared, Future, FutureExt};
use gpui::{ use gpui::{
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Global, Subscription, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Global, Subscription, Task,
Task, WeakEntity, WeakEntity,
}; };
use postage::watch; use postage::watch;
use project::Project; use project::Project;
@ -41,7 +41,7 @@ impl OneAtATime {
/// otherwise you'll see the result of the task. /// otherwise you'll see the result of the task.
fn spawn<F, Fut, R>(&mut self, cx: &mut App, f: F) -> Task<Result<Option<R>>> fn spawn<F, Fut, R>(&mut self, cx: &mut App, f: F) -> Task<Result<Option<R>>>
where where
F: 'static + FnOnce(AsyncAppContext) -> Fut, F: 'static + FnOnce(AsyncApp) -> Fut,
Fut: Future<Output = Result<R>>, Fut: Future<Output = Result<R>>,
R: 'static, R: 'static,
{ {
@ -113,7 +113,7 @@ impl ActiveCall {
async fn handle_incoming_call( async fn handle_incoming_call(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::IncomingCall>, envelope: TypedEnvelope<proto::IncomingCall>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?; let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
let call = IncomingCall { let call = IncomingCall {
@ -140,7 +140,7 @@ impl ActiveCall {
async fn handle_call_canceled( async fn handle_call_canceled(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::CallCanceled>, envelope: TypedEnvelope<proto::CallCanceled>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, _| {
let mut incoming_call = this.incoming_call.0.borrow_mut(); let mut incoming_call = this.incoming_call.0.borrow_mut();

View file

@ -11,9 +11,7 @@ use client::{
use collections::{BTreeMap, HashMap, HashSet}; use collections::{BTreeMap, HashMap, HashSet};
use fs::Fs; use fs::Fs;
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
use gpui::{ use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Task, WeakEntity,
};
use language::LanguageRegistry; use language::LanguageRegistry;
use livekit_client_macos::{LocalAudioTrack, LocalTrackPublication, LocalVideoTrack, RoomUpdate}; use livekit_client_macos::{LocalAudioTrack, LocalTrackPublication, LocalVideoTrack, RoomUpdate};
use postage::{sink::Sink, stream::Stream, watch}; use postage::{sink::Sink, stream::Stream, watch};
@ -276,7 +274,7 @@ impl Room {
channel_id: ChannelId, channel_id: ChannelId,
client: Arc<Client>, client: Arc<Client>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
Self::from_join_response( Self::from_join_response(
client client
@ -294,7 +292,7 @@ impl Room {
room_id: u64, room_id: u64,
client: Arc<Client>, client: Arc<Client>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
Self::from_join_response( Self::from_join_response(
client.request(proto::JoinRoom { id: room_id }).await?, client.request(proto::JoinRoom { id: room_id }).await?,
@ -335,7 +333,7 @@ impl Room {
response: proto::JoinRoomResponse, response: proto::JoinRoomResponse,
client: Arc<Client>, client: Arc<Client>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?; let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
let room = cx.new(|cx| { let room = cx.new(|cx| {
@ -416,7 +414,7 @@ impl Room {
async fn maintain_connection( async fn maintain_connection(
this: WeakEntity<Self>, this: WeakEntity<Self>,
client: Arc<Client>, client: Arc<Client>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let mut client_status = client.status(); let mut client_status = client.status();
loop { loop {
@ -697,7 +695,7 @@ impl Room {
async fn handle_room_updated( async fn handle_room_updated(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::RoomUpdated>, envelope: TypedEnvelope<proto::RoomUpdated>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let room = envelope let room = envelope
.payload .payload

View file

@ -2,7 +2,7 @@ use crate::{Channel, ChannelStore};
use anyhow::Result; use anyhow::Result;
use client::{ChannelId, Client, Collaborator, UserStore, ZED_ALWAYS_ACTIVE}; use client::{ChannelId, Client, Collaborator, UserStore, ZED_ALWAYS_ACTIVE};
use collections::HashMap; use collections::HashMap;
use gpui::{App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Task}; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Task};
use language::proto::serialize_version; use language::proto::serialize_version;
use rpc::{ use rpc::{
proto::{self, PeerId}, proto::{self, PeerId},
@ -47,7 +47,7 @@ impl ChannelBuffer {
client: Arc<Client>, client: Arc<Client>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
channel_store: Entity<ChannelStore>, channel_store: Entity<ChannelStore>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
let response = client let response = client
.request(proto::JoinChannelBuffer { .request(proto::JoinChannelBuffer {
@ -138,7 +138,7 @@ impl ChannelBuffer {
async fn handle_update_channel_buffer( async fn handle_update_channel_buffer(
this: Entity<Self>, this: Entity<Self>,
update_channel_buffer: TypedEnvelope<proto::UpdateChannelBuffer>, update_channel_buffer: TypedEnvelope<proto::UpdateChannelBuffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let ops = update_channel_buffer let ops = update_channel_buffer
.payload .payload
@ -159,7 +159,7 @@ impl ChannelBuffer {
async fn handle_update_channel_buffer_collaborators( async fn handle_update_channel_buffer_collaborators(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::UpdateChannelBufferCollaborators>, message: TypedEnvelope<proto::UpdateChannelBufferCollaborators>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.replace_collaborators(message.payload.collaborators, cx); this.replace_collaborators(message.payload.collaborators, cx);

View file

@ -7,9 +7,7 @@ use client::{
}; };
use collections::HashSet; use collections::HashSet;
use futures::lock::Mutex; use futures::lock::Mutex;
use gpui::{ use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Task, WeakEntity,
};
use rand::prelude::*; use rand::prelude::*;
use rpc::AnyProtoClient; use rpc::AnyProtoClient;
use std::{ use std::{
@ -108,7 +106,7 @@ impl ChannelChat {
channel_store: Entity<ChannelStore>, channel_store: Entity<ChannelStore>,
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
client: Arc<Client>, client: Arc<Client>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
let channel_id = channel.id; let channel_id = channel.id;
let subscription = client.subscribe_to_entity(channel_id.0).unwrap(); let subscription = client.subscribe_to_entity(channel_id.0).unwrap();
@ -325,7 +323,7 @@ impl ChannelChat {
pub async fn load_history_since_message( pub async fn load_history_since_message(
chat: Entity<Self>, chat: Entity<Self>,
message_id: u64, message_id: u64,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Option<usize> { ) -> Option<usize> {
loop { loop {
let step = chat let step = chat
@ -383,7 +381,7 @@ impl ChannelChat {
rpc: Arc<Client>, rpc: Arc<Client>,
proto_messages: Vec<proto::ChannelMessage>, proto_messages: Vec<proto::ChannelMessage>,
loaded_all_messages: bool, loaded_all_messages: bool,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
let loaded_messages = messages_from_proto(proto_messages, &user_store, cx).await?; let loaded_messages = messages_from_proto(proto_messages, &user_store, cx).await?;
@ -529,7 +527,7 @@ impl ChannelChat {
async fn handle_message_sent( async fn handle_message_sent(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::ChannelMessageSent>, message: TypedEnvelope<proto::ChannelMessageSent>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?; let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
let message = message let message = message
@ -553,7 +551,7 @@ impl ChannelChat {
async fn handle_message_removed( async fn handle_message_removed(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::RemoveChannelMessage>, message: TypedEnvelope<proto::RemoveChannelMessage>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.message_removed(message.payload.message_id, cx) this.message_removed(message.payload.message_id, cx)
@ -564,7 +562,7 @@ impl ChannelChat {
async fn handle_message_updated( async fn handle_message_updated(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::ChannelMessageUpdate>, message: TypedEnvelope<proto::ChannelMessageUpdate>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?; let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
let message = message let message = message
@ -713,7 +711,7 @@ impl ChannelChat {
async fn messages_from_proto( async fn messages_from_proto(
proto_messages: Vec<proto::ChannelMessage>, proto_messages: Vec<proto::ChannelMessage>,
user_store: &Entity<UserStore>, user_store: &Entity<UserStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<SumTree<ChannelMessage>> { ) -> Result<SumTree<ChannelMessage>> {
let messages = ChannelMessage::from_proto_vec(proto_messages, user_store, cx).await?; let messages = ChannelMessage::from_proto_vec(proto_messages, user_store, cx).await?;
let mut result = SumTree::default(); let mut result = SumTree::default();
@ -725,7 +723,7 @@ impl ChannelMessage {
pub async fn from_proto( pub async fn from_proto(
message: proto::ChannelMessage, message: proto::ChannelMessage,
user_store: &Entity<UserStore>, user_store: &Entity<UserStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let sender = user_store let sender = user_store
.update(cx, |user_store, cx| { .update(cx, |user_store, cx| {
@ -770,7 +768,7 @@ impl ChannelMessage {
pub async fn from_proto_vec( pub async fn from_proto_vec(
proto_messages: Vec<proto::ChannelMessage>, proto_messages: Vec<proto::ChannelMessage>,
user_store: &Entity<UserStore>, user_store: &Entity<UserStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Vec<Self>> { ) -> Result<Vec<Self>> {
let unique_user_ids = proto_messages let unique_user_ids = proto_messages
.iter() .iter()

View file

@ -7,8 +7,8 @@ use client::{ChannelId, Client, ClientSettings, Subscription, User, UserId, User
use collections::{hash_map, HashMap, HashSet}; use collections::{hash_map, HashMap, HashSet};
use futures::{channel::mpsc, future::Shared, Future, FutureExt, StreamExt}; use futures::{channel::mpsc, future::Shared, Future, FutureExt, StreamExt};
use gpui::{ use gpui::{
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Global, SharedString, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Global, SharedString, Task,
Task, WeakEntity, WeakEntity,
}; };
use language::Capability; use language::Capability;
use rpc::{ use rpc::{
@ -458,7 +458,7 @@ impl ChannelStore {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Task<Result<Entity<T>>> ) -> Task<Result<Entity<T>>>
where where
F: 'static + FnOnce(Arc<Channel>, AsyncAppContext) -> Fut, F: 'static + FnOnce(Arc<Channel>, AsyncApp) -> Fut,
Fut: Future<Output = Result<Entity<T>>>, Fut: Future<Output = Result<Entity<T>>>,
T: 'static, T: 'static,
{ {
@ -848,7 +848,7 @@ impl ChannelStore {
async fn handle_update_channels( async fn handle_update_channels(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::UpdateChannels>, message: TypedEnvelope<proto::UpdateChannels>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, _| {
this.update_channels_tx this.update_channels_tx
@ -861,7 +861,7 @@ impl ChannelStore {
async fn handle_update_user_channels( async fn handle_update_user_channels(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::UpdateUserChannels>, message: TypedEnvelope<proto::UpdateUserChannels>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
for buffer_version in message.payload.observed_channel_buffer_version { for buffer_version in message.payload.observed_channel_buffer_version {

View file

@ -19,7 +19,7 @@ use futures::{
channel::oneshot, future::BoxFuture, AsyncReadExt, FutureExt, SinkExt, Stream, StreamExt, channel::oneshot, future::BoxFuture, AsyncReadExt, FutureExt, SinkExt, Stream, StreamExt,
TryFutureExt as _, TryStreamExt, TryFutureExt as _, TryStreamExt,
}; };
use gpui::{actions, App, AsyncAppContext, Entity, Global, Task, WeakEntity}; use gpui::{actions, App, AsyncApp, Entity, Global, Task, WeakEntity};
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl}; use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
use parking_lot::RwLock; use parking_lot::RwLock;
use postage::watch; use postage::watch;
@ -199,9 +199,8 @@ pub struct Client {
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
authenticate: RwLock< authenticate:
Option<Box<dyn 'static + Send + Sync + Fn(&AsyncAppContext) -> Task<Result<Credentials>>>>, RwLock<Option<Box<dyn 'static + Send + Sync + Fn(&AsyncApp) -> Task<Result<Credentials>>>>>,
>,
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
@ -213,7 +212,7 @@ pub struct Client {
+ Sync + Sync
+ Fn( + Fn(
&Credentials, &Credentials,
&AsyncAppContext, &AsyncApp,
) -> Task<Result<Connection, EstablishConnectionError>>, ) -> Task<Result<Connection, EstablishConnectionError>>,
>, >,
>, >,
@ -313,7 +312,7 @@ trait CredentialsProvider {
/// Reads the credentials from the provider. /// Reads the credentials from the provider.
fn read_credentials<'a>( fn read_credentials<'a>(
&'a self, &'a self,
cx: &'a AsyncAppContext, cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Option<Credentials>> + 'a>>; ) -> Pin<Box<dyn Future<Output = Option<Credentials>> + 'a>>;
/// Writes the credentials to the provider. /// Writes the credentials to the provider.
@ -321,13 +320,13 @@ trait CredentialsProvider {
&'a self, &'a self,
user_id: u64, user_id: u64,
access_token: String, access_token: String,
cx: &'a AsyncAppContext, cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>; ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>;
/// Deletes the credentials from the provider. /// Deletes the credentials from the provider.
fn delete_credentials<'a>( fn delete_credentials<'a>(
&'a self, &'a self,
cx: &'a AsyncAppContext, cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>; ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>;
} }
@ -380,7 +379,7 @@ pub struct PendingEntitySubscription<T: 'static> {
} }
impl<T: 'static> PendingEntitySubscription<T> { impl<T: 'static> PendingEntitySubscription<T> {
pub fn set_model(mut self, model: &Entity<T>, cx: &AsyncAppContext) -> Subscription { pub fn set_model(mut self, model: &Entity<T>, cx: &AsyncApp) -> Subscription {
self.consumed = true; self.consumed = true;
let mut handlers = self.client.handler_set.lock(); let mut handlers = self.client.handler_set.lock();
let id = (TypeId::of::<T>(), self.remote_id); let id = (TypeId::of::<T>(), self.remote_id);
@ -552,7 +551,7 @@ impl Client {
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
pub fn override_authenticate<F>(&self, authenticate: F) -> &Self pub fn override_authenticate<F>(&self, authenticate: F) -> &Self
where where
F: 'static + Send + Sync + Fn(&AsyncAppContext) -> Task<Result<Credentials>>, F: 'static + Send + Sync + Fn(&AsyncApp) -> Task<Result<Credentials>>,
{ {
*self.authenticate.write() = Some(Box::new(authenticate)); *self.authenticate.write() = Some(Box::new(authenticate));
self self
@ -564,7 +563,7 @@ impl Client {
F: 'static F: 'static
+ Send + Send
+ Sync + Sync
+ Fn(&Credentials, &AsyncAppContext) -> Task<Result<Connection, EstablishConnectionError>>, + Fn(&Credentials, &AsyncApp) -> Task<Result<Connection, EstablishConnectionError>>,
{ {
*self.establish_connection.write() = Some(Box::new(connect)); *self.establish_connection.write() = Some(Box::new(connect));
self self
@ -603,7 +602,7 @@ impl Client {
self.state.read().status.1.clone() self.state.read().status.1.clone()
} }
fn set_status(self: &Arc<Self>, status: Status, cx: &AsyncAppContext) { fn set_status(self: &Arc<Self>, status: Status, cx: &AsyncApp) {
log::info!("set status on client {}: {:?}", self.id(), status); log::info!("set status on client {}: {:?}", self.id(), status);
let mut state = self.state.write(); let mut state = self.state.write();
*state.status.0.borrow_mut() = status; *state.status.0.borrow_mut() = status;
@ -684,7 +683,7 @@ impl Client {
where where
M: EnvelopedMessage, M: EnvelopedMessage,
E: 'static, E: 'static,
H: 'static + Sync + Fn(Entity<E>, TypedEnvelope<M>, AsyncAppContext) -> F + Send + Sync, H: 'static + Sync + Fn(Entity<E>, TypedEnvelope<M>, AsyncApp) -> F + Send + Sync,
F: 'static + Future<Output = Result<()>>, F: 'static + Future<Output = Result<()>>,
{ {
self.add_message_handler_impl(entity, move |model, message, _, cx| { self.add_message_handler_impl(entity, move |model, message, _, cx| {
@ -702,7 +701,7 @@ impl Client {
E: 'static, E: 'static,
H: 'static H: 'static
+ Sync + Sync
+ Fn(Entity<E>, TypedEnvelope<M>, AnyProtoClient, AsyncAppContext) -> F + Fn(Entity<E>, TypedEnvelope<M>, AnyProtoClient, AsyncApp) -> F
+ Send + Send
+ Sync, + Sync,
F: 'static + Future<Output = Result<()>>, F: 'static + Future<Output = Result<()>>,
@ -745,7 +744,7 @@ impl Client {
where where
M: RequestMessage, M: RequestMessage,
E: 'static, E: 'static,
H: 'static + Sync + Fn(Entity<E>, TypedEnvelope<M>, AsyncAppContext) -> F + Send + Sync, H: 'static + Sync + Fn(Entity<E>, TypedEnvelope<M>, AsyncApp) -> F + Send + Sync,
F: 'static + Future<Output = Result<M::Response>>, F: 'static + Future<Output = Result<M::Response>>,
{ {
self.add_message_handler_impl(model, move |handle, envelope, this, cx| { self.add_message_handler_impl(model, move |handle, envelope, this, cx| {
@ -770,7 +769,7 @@ impl Client {
} }
} }
pub async fn has_credentials(&self, cx: &AsyncAppContext) -> bool { pub async fn has_credentials(&self, cx: &AsyncApp) -> bool {
self.credentials_provider self.credentials_provider
.read_credentials(cx) .read_credentials(cx)
.await .await
@ -781,7 +780,7 @@ impl Client {
pub async fn authenticate_and_connect( pub async fn authenticate_and_connect(
self: &Arc<Self>, self: &Arc<Self>,
try_provider: bool, try_provider: bool,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
let was_disconnected = match *self.status().borrow() { let was_disconnected = match *self.status().borrow() {
Status::SignedOut => true, Status::SignedOut => true,
@ -883,11 +882,7 @@ impl Client {
} }
} }
async fn set_connection( async fn set_connection(self: &Arc<Self>, conn: Connection, cx: &AsyncApp) -> Result<()> {
self: &Arc<Self>,
conn: Connection,
cx: &AsyncAppContext,
) -> Result<()> {
let executor = cx.background_executor(); let executor = cx.background_executor();
log::debug!("add connection to peer"); log::debug!("add connection to peer");
let (connection_id, handle_io, mut incoming) = self.peer.add_connection(conn, { let (connection_id, handle_io, mut incoming) = self.peer.add_connection(conn, {
@ -981,7 +976,7 @@ impl Client {
Ok(()) Ok(())
} }
fn authenticate(self: &Arc<Self>, cx: &AsyncAppContext) -> Task<Result<Credentials>> { fn authenticate(self: &Arc<Self>, cx: &AsyncApp) -> Task<Result<Credentials>> {
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
if let Some(callback) = self.authenticate.read().as_ref() { if let Some(callback) = self.authenticate.read().as_ref() {
return callback(cx); return callback(cx);
@ -993,7 +988,7 @@ impl Client {
fn establish_connection( fn establish_connection(
self: &Arc<Self>, self: &Arc<Self>,
credentials: &Credentials, credentials: &Credentials,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Task<Result<Connection, EstablishConnectionError>> { ) -> Task<Result<Connection, EstablishConnectionError>> {
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
if let Some(callback) = self.establish_connection.read().as_ref() { if let Some(callback) = self.establish_connection.read().as_ref() {
@ -1052,7 +1047,7 @@ impl Client {
fn establish_websocket_connection( fn establish_websocket_connection(
self: &Arc<Self>, self: &Arc<Self>,
credentials: &Credentials, credentials: &Credentials,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Task<Result<Connection, EstablishConnectionError>> { ) -> Task<Result<Connection, EstablishConnectionError>> {
let release_channel = cx let release_channel = cx
.update(|cx| ReleaseChannel::try_global(cx)) .update(|cx| ReleaseChannel::try_global(cx))
@ -1174,10 +1169,7 @@ impl Client {
}) })
} }
pub fn authenticate_with_browser( pub fn authenticate_with_browser(self: &Arc<Self>, cx: &AsyncApp) -> Task<Result<Credentials>> {
self: &Arc<Self>,
cx: &AsyncAppContext,
) -> Task<Result<Credentials>> {
let http = self.http.clone(); let http = self.http.clone();
let this = self.clone(); let this = self.clone();
cx.spawn(|cx| async move { cx.spawn(|cx| async move {
@ -1412,7 +1404,7 @@ impl Client {
}) })
} }
pub async fn sign_out(self: &Arc<Self>, cx: &AsyncAppContext) { pub async fn sign_out(self: &Arc<Self>, cx: &AsyncApp) {
self.state.write().credentials = None; self.state.write().credentials = None;
self.disconnect(cx); self.disconnect(cx);
@ -1424,12 +1416,12 @@ impl Client {
} }
} }
pub fn disconnect(self: &Arc<Self>, cx: &AsyncAppContext) { pub fn disconnect(self: &Arc<Self>, cx: &AsyncApp) {
self.peer.teardown(); self.peer.teardown();
self.set_status(Status::SignedOut, cx); self.set_status(Status::SignedOut, cx);
} }
pub fn reconnect(self: &Arc<Self>, cx: &AsyncAppContext) { pub fn reconnect(self: &Arc<Self>, cx: &AsyncApp) {
self.peer.teardown(); self.peer.teardown();
self.set_status(Status::ConnectionLost, cx); self.set_status(Status::ConnectionLost, cx);
} }
@ -1528,11 +1520,7 @@ impl Client {
} }
} }
fn handle_message( fn handle_message(self: &Arc<Client>, message: Box<dyn AnyTypedEnvelope>, cx: &AsyncApp) {
self: &Arc<Client>,
message: Box<dyn AnyTypedEnvelope>,
cx: &AsyncAppContext,
) {
let sender_id = message.sender_id(); let sender_id = message.sender_id();
let request_id = message.message_id(); let request_id = message.message_id();
let type_name = message.payload_type_name(); let type_name = message.payload_type_name();
@ -1640,7 +1628,7 @@ struct DevelopmentCredentialsProvider {
impl CredentialsProvider for DevelopmentCredentialsProvider { impl CredentialsProvider for DevelopmentCredentialsProvider {
fn read_credentials<'a>( fn read_credentials<'a>(
&'a self, &'a self,
_cx: &'a AsyncAppContext, _cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Option<Credentials>> + 'a>> { ) -> Pin<Box<dyn Future<Output = Option<Credentials>> + 'a>> {
async move { async move {
if IMPERSONATE_LOGIN.is_some() { if IMPERSONATE_LOGIN.is_some() {
@ -1663,7 +1651,7 @@ impl CredentialsProvider for DevelopmentCredentialsProvider {
&'a self, &'a self,
user_id: u64, user_id: u64,
access_token: String, access_token: String,
_cx: &'a AsyncAppContext, _cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> { ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> {
async move { async move {
let json = serde_json::to_string(&DevelopmentCredentials { let json = serde_json::to_string(&DevelopmentCredentials {
@ -1680,7 +1668,7 @@ impl CredentialsProvider for DevelopmentCredentialsProvider {
fn delete_credentials<'a>( fn delete_credentials<'a>(
&'a self, &'a self,
_cx: &'a AsyncAppContext, _cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> { ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> {
async move { Ok(std::fs::remove_file(&self.path)?) }.boxed_local() async move { Ok(std::fs::remove_file(&self.path)?) }.boxed_local()
} }
@ -1692,7 +1680,7 @@ struct KeychainCredentialsProvider;
impl CredentialsProvider for KeychainCredentialsProvider { impl CredentialsProvider for KeychainCredentialsProvider {
fn read_credentials<'a>( fn read_credentials<'a>(
&'a self, &'a self,
cx: &'a AsyncAppContext, cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Option<Credentials>> + 'a>> { ) -> Pin<Box<dyn Future<Output = Option<Credentials>> + 'a>> {
async move { async move {
if IMPERSONATE_LOGIN.is_some() { if IMPERSONATE_LOGIN.is_some() {
@ -1717,7 +1705,7 @@ impl CredentialsProvider for KeychainCredentialsProvider {
&'a self, &'a self,
user_id: u64, user_id: u64,
access_token: String, access_token: String,
cx: &'a AsyncAppContext, cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> { ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> {
async move { async move {
cx.update(move |cx| { cx.update(move |cx| {
@ -1734,7 +1722,7 @@ impl CredentialsProvider for KeychainCredentialsProvider {
fn delete_credentials<'a>( fn delete_credentials<'a>(
&'a self, &'a self,
cx: &'a AsyncAppContext, cx: &'a AsyncApp,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> { ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> {
async move { async move {
cx.update(move |cx| cx.delete_credentials(&ClientSettings::get_global(cx).server_url))? cx.update(move |cx| cx.delete_credentials(&ClientSettings::get_global(cx).server_url))?

View file

@ -5,7 +5,7 @@ use collections::{hash_map::Entry, HashMap, HashSet};
use feature_flags::FeatureFlagAppExt; use feature_flags::FeatureFlagAppExt;
use futures::{channel::mpsc, Future, StreamExt}; use futures::{channel::mpsc, Future, StreamExt};
use gpui::{ use gpui::{
App, AsyncAppContext, Context, Entity, EventEmitter, SharedString, SharedUri, Task, WeakEntity, App, AsyncApp, Context, Entity, EventEmitter, SharedString, SharedUri, Task, WeakEntity,
}; };
use postage::{sink::Sink, watch}; use postage::{sink::Sink, watch};
use rpc::proto::{RequestMessage, UsersResponse}; use rpc::proto::{RequestMessage, UsersResponse};
@ -275,7 +275,7 @@ impl UserStore {
async fn handle_update_invite_info( async fn handle_update_invite_info(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::UpdateInviteInfo>, message: TypedEnvelope<proto::UpdateInviteInfo>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.invite_info = Some(InviteInfo { this.invite_info = Some(InviteInfo {
@ -290,7 +290,7 @@ impl UserStore {
async fn handle_show_contacts( async fn handle_show_contacts(
this: Entity<Self>, this: Entity<Self>,
_: TypedEnvelope<proto::ShowContacts>, _: TypedEnvelope<proto::ShowContacts>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |_, cx| cx.emit(Event::ShowContacts))?; this.update(&mut cx, |_, cx| cx.emit(Event::ShowContacts))?;
Ok(()) Ok(())
@ -303,7 +303,7 @@ impl UserStore {
async fn handle_update_contacts( async fn handle_update_contacts(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::UpdateContacts>, message: TypedEnvelope<proto::UpdateContacts>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, _| {
this.update_contacts_tx this.update_contacts_tx
@ -316,7 +316,7 @@ impl UserStore {
async fn handle_update_plan( async fn handle_update_plan(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::UpdateUserPlan>, message: TypedEnvelope<proto::UpdateUserPlan>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.current_plan = Some(message.payload.plan()); this.current_plan = Some(message.payload.plan());
@ -819,7 +819,7 @@ impl Contact {
async fn from_proto( async fn from_proto(
contact: proto::Contact, contact: proto::Contact,
user_store: &Entity<UserStore>, user_store: &Entity<UserStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let user = user_store let user = user_store
.update(cx, |user_store, cx| { .update(cx, |user_store, cx| {

View file

@ -104,7 +104,7 @@ async fn test_host_disconnect(
.unwrap(); .unwrap();
//TODO: focus //TODO: focus
assert!(cx_b.update_window_model(&editor_b, |editor, window, _| editor.is_focused(window))); assert!(cx_b.update_window_entity(&editor_b, |editor, window, _| editor.is_focused(window)));
editor_b.update_in(cx_b, |editor, window, cx| editor.insert("X", window, cx)); editor_b.update_in(cx_b, |editor, window, cx| editor.insert("X", window, cx));
cx_b.update(|_, cx| { cx_b.update(|_, cx| {
@ -208,7 +208,7 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor(
.unwrap(); .unwrap();
let cx_a = cx_a.add_empty_window(); let cx_a = cx_a.add_empty_window();
let editor_a = cx_a let editor_a = cx_a
.new_window_model(|window, cx| Editor::for_buffer(buffer_a, Some(project_a), window, cx)); .new_window_entity(|window, cx| Editor::for_buffer(buffer_a, Some(project_a), window, cx));
let mut editor_cx_a = EditorTestContext { let mut editor_cx_a = EditorTestContext {
cx: cx_a.clone(), cx: cx_a.clone(),
@ -224,7 +224,7 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor(
.await .await
.unwrap(); .unwrap();
let editor_b = cx_b let editor_b = cx_b
.new_window_model(|window, cx| Editor::for_buffer(buffer_b, Some(project_b), window, cx)); .new_window_entity(|window, cx| Editor::for_buffer(buffer_b, Some(project_b), window, cx));
let mut editor_cx_b = EditorTestContext { let mut editor_cx_b = EditorTestContext {
cx: cx_b.clone(), cx: cx_b.clone(),
@ -327,7 +327,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
.await .await
.unwrap(); .unwrap();
let cx_b = cx_b.add_empty_window(); let cx_b = cx_b.add_empty_window();
let editor_b = cx_b.new_window_model(|window, cx| { let editor_b = cx_b.new_window_entity(|window, cx| {
Editor::for_buffer(buffer_b.clone(), Some(project_b.clone()), window, cx) Editor::for_buffer(buffer_b.clone(), Some(project_b.clone()), window, cx)
}); });
@ -1206,7 +1206,7 @@ async fn test_share_project(
.unwrap(); .unwrap();
let editor_b = let editor_b =
cx_b.new_window_model(|window, cx| Editor::for_buffer(buffer_b, None, window, cx)); cx_b.new_window_entity(|window, cx| Editor::for_buffer(buffer_b, None, window, cx));
// Client A sees client B's selection // Client A sees client B's selection
executor.run_until_parked(); executor.run_until_parked();
@ -1313,7 +1313,7 @@ async fn test_on_input_format_from_host_to_guest(
.await .await
.unwrap(); .unwrap();
let cx_a = cx_a.add_empty_window(); let cx_a = cx_a.add_empty_window();
let editor_a = cx_a.new_window_model(|window, cx| { let editor_a = cx_a.new_window_entity(|window, cx| {
Editor::for_buffer(buffer_a, Some(project_a.clone()), window, cx) Editor::for_buffer(buffer_a, Some(project_a.clone()), window, cx)
}); });
@ -1435,7 +1435,7 @@ async fn test_on_input_format_from_guest_to_host(
.await .await
.unwrap(); .unwrap();
let cx_b = cx_b.add_empty_window(); let cx_b = cx_b.add_empty_window();
let editor_b = cx_b.new_window_model(|window, cx| { let editor_b = cx_b.new_window_entity(|window, cx| {
Editor::for_buffer(buffer_b, Some(project_b.clone()), window, cx) Editor::for_buffer(buffer_b, Some(project_b.clone()), window, cx)
}); });
@ -2195,10 +2195,10 @@ async fn test_collaborating_with_editorconfig(
.await .await
.unwrap(); .unwrap();
let cx_a = cx_a.add_empty_window(); let cx_a = cx_a.add_empty_window();
let main_editor_a = cx_a.new_window_model(|window, cx| { let main_editor_a = cx_a.new_window_entity(|window, cx| {
Editor::for_buffer(main_buffer_a, Some(project_a.clone()), window, cx) Editor::for_buffer(main_buffer_a, Some(project_a.clone()), window, cx)
}); });
let other_editor_a = cx_a.new_window_model(|window, cx| { let other_editor_a = cx_a.new_window_entity(|window, cx| {
Editor::for_buffer(other_buffer_a, Some(project_a), window, cx) Editor::for_buffer(other_buffer_a, Some(project_a), window, cx)
}); });
let mut main_editor_cx_a = EditorTestContext { let mut main_editor_cx_a = EditorTestContext {
@ -2229,10 +2229,10 @@ async fn test_collaborating_with_editorconfig(
.await .await
.unwrap(); .unwrap();
let cx_b = cx_b.add_empty_window(); let cx_b = cx_b.add_empty_window();
let main_editor_b = cx_b.new_window_model(|window, cx| { let main_editor_b = cx_b.new_window_entity(|window, cx| {
Editor::for_buffer(main_buffer_b, Some(project_b.clone()), window, cx) Editor::for_buffer(main_buffer_b, Some(project_b.clone()), window, cx)
}); });
let other_editor_b = cx_b.new_window_model(|window, cx| { let other_editor_b = cx_b.new_window_entity(|window, cx| {
Editor::for_buffer(other_buffer_b, Some(project_b.clone()), window, cx) Editor::for_buffer(other_buffer_b, Some(project_b.clone()), window, cx)
}); });
let mut main_editor_cx_b = EditorTestContext { let mut main_editor_cx_b = EditorTestContext {

View file

@ -180,7 +180,7 @@ impl ChannelView {
}) })
})?; })?;
cx.new_window_model(|window, cx| { cx.new_window_entity(|window, cx| {
let mut this = Self::new( let mut this = Self::new(
project, project,
weak_workspace, weak_workspace,

View file

@ -5,7 +5,7 @@ use collections::HashSet;
use editor::{AnchorRangeExt, CompletionProvider, Editor, EditorElement, EditorStyle}; use editor::{AnchorRangeExt, CompletionProvider, Editor, EditorElement, EditorStyle};
use fuzzy::{StringMatch, StringMatchCandidate}; use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{ use gpui::{
AsyncAppContext, AsyncWindowContext, Context, Entity, Focusable, FontStyle, FontWeight, AsyncApp, AsyncWindowContext, Context, Entity, Focusable, FontStyle, FontWeight,
HighlightStyle, IntoElement, Render, Task, TextStyle, WeakEntity, Window, HighlightStyle, IntoElement, Render, Task, TextStyle, WeakEntity, Window,
}; };
use language::{ use language::{
@ -285,7 +285,7 @@ impl MessageEditor {
} }
async fn resolve_completions_for_candidates( async fn resolve_completions_for_candidates(
cx: &AsyncAppContext, cx: &AsyncApp,
query: &str, query: &str,
candidates: &[StringMatchCandidate], candidates: &[StringMatchCandidate],
range: Range<Anchor>, range: Range<Anchor>,

View file

@ -516,7 +516,7 @@ mod tests {
let (workspace, cx) = let (workspace, cx) =
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
let editor = cx.new_window_model(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
let mut editor = Editor::single_line(window, cx); let mut editor = Editor::single_line(window, cx);
editor.set_text("abc", window, cx); editor.set_text("abc", window, cx);
editor editor
@ -587,7 +587,7 @@ mod tests {
let (workspace, cx) = let (workspace, cx) =
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
let editor = cx.new_window_model(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
let mut editor = Editor::single_line(window, cx); let mut editor = Editor::single_line(window, cx);
editor.set_text("abc", window, cx); editor.set_text("abc", window, cx);
editor editor

View file

@ -1,7 +1,7 @@
use anyhow::{anyhow, Context as _, Result}; use anyhow::{anyhow, Context as _, Result};
use collections::HashMap; use collections::HashMap;
use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, FutureExt}; use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, FutureExt};
use gpui::{AsyncAppContext, BackgroundExecutor, Task}; use gpui::{AsyncApp, BackgroundExecutor, Task};
use parking_lot::Mutex; use parking_lot::Mutex;
use postage::barrier; use postage::barrier;
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::{de::DeserializeOwned, Deserialize, Serialize};
@ -33,7 +33,7 @@ pub const INVALID_PARAMS: i32 = -32602;
pub const INTERNAL_ERROR: i32 = -32603; pub const INTERNAL_ERROR: i32 = -32603;
type ResponseHandler = Box<dyn Send + FnOnce(Result<String, Error>)>; type ResponseHandler = Box<dyn Send + FnOnce(Result<String, Error>)>;
type NotificationHandler = Box<dyn Send + FnMut(Value, AsyncAppContext)>; type NotificationHandler = Box<dyn Send + FnMut(Value, AsyncApp)>;
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] #[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(untagged)] #[serde(untagged)]
@ -144,7 +144,7 @@ impl Client {
pub fn new( pub fn new(
server_id: ContextServerId, server_id: ContextServerId,
binary: ModelContextServerBinary, binary: ModelContextServerBinary,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
log::info!( log::info!(
"starting context server (executable={:?}, args={:?})", "starting context server (executable={:?}, args={:?})",
@ -232,7 +232,7 @@ impl Client {
stdout: Stdout, stdout: Stdout,
notification_handlers: Arc<Mutex<HashMap<&'static str, NotificationHandler>>>, notification_handlers: Arc<Mutex<HashMap<&'static str, NotificationHandler>>>,
response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>, response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>,
cx: AsyncAppContext, cx: AsyncApp,
) -> anyhow::Result<()> ) -> anyhow::Result<()>
where where
Stdout: AsyncRead + Unpin + Send + 'static, Stdout: AsyncRead + Unpin + Send + 'static,
@ -400,7 +400,7 @@ impl Client {
pub fn on_notification<F>(&self, method: &'static str, f: F) pub fn on_notification<F>(&self, method: &'static str, f: F)
where where
F: 'static + Send + FnMut(Value, AsyncAppContext), F: 'static + Send + FnMut(Value, AsyncApp),
{ {
self.notification_handlers self.notification_handlers
.lock() .lock()

View file

@ -20,7 +20,7 @@ use std::sync::Arc;
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use collections::HashMap; use collections::HashMap;
use command_palette_hooks::CommandPaletteFilter; use command_palette_hooks::CommandPaletteFilter;
use gpui::{AsyncAppContext, Context, Entity, EventEmitter, Subscription, Task, WeakEntity}; use gpui::{AsyncApp, Context, Entity, EventEmitter, Subscription, Task, WeakEntity};
use log; use log;
use parking_lot::RwLock; use parking_lot::RwLock;
use project::Project; use project::Project;
@ -61,7 +61,7 @@ impl ContextServer {
self.client.read().clone() self.client.read().clone()
} }
pub async fn start(self: Arc<Self>, cx: &AsyncAppContext) -> Result<()> { pub async fn start(self: Arc<Self>, cx: &AsyncApp) -> Result<()> {
log::info!("starting context server {}", self.id); log::info!("starting context server {}", self.id);
let Some(command) = &self.config.command else { let Some(command) = &self.config.command else {
bail!("no command specified for server {}", self.id); bail!("no command specified for server {}", self.id);
@ -214,7 +214,7 @@ impl ContextServerManager {
.collect() .collect()
} }
async fn maintain_servers(this: WeakEntity<Self>, mut cx: AsyncAppContext) -> Result<()> { async fn maintain_servers(this: WeakEntity<Self>, mut cx: AsyncApp) -> Result<()> {
let mut desired_servers = HashMap::default(); let mut desired_servers = HashMap::default();
let (registry, project) = this.update(&mut cx, |this, cx| { let (registry, project) = this.update(&mut cx, |this, cx| {

View file

@ -2,17 +2,13 @@ use std::sync::Arc;
use anyhow::Result; use anyhow::Result;
use collections::HashMap; use collections::HashMap;
use gpui::{App, AppContext as _, AsyncAppContext, Entity, Global, ReadGlobal, Task}; use gpui::{App, AppContext as _, AsyncApp, Entity, Global, ReadGlobal, Task};
use project::Project; use project::Project;
use crate::ServerCommand; use crate::ServerCommand;
pub type ContextServerFactory = Arc< pub type ContextServerFactory =
dyn Fn(Entity<Project>, &AsyncAppContext) -> Task<Result<ServerCommand>> Arc<dyn Fn(Entity<Project>, &AsyncApp) -> Task<Result<ServerCommand>> + Send + Sync + 'static>;
+ Send
+ Sync
+ 'static,
>;
struct GlobalContextServerFactoryRegistry(Entity<ContextServerFactoryRegistry>); struct GlobalContextServerFactoryRegistry(Entity<ContextServerFactoryRegistry>);

View file

@ -11,8 +11,8 @@ use collections::{HashMap, HashSet};
use command_palette_hooks::CommandPaletteFilter; use command_palette_hooks::CommandPaletteFilter;
use futures::{channel::oneshot, future::Shared, Future, FutureExt, TryFutureExt}; use futures::{channel::oneshot, future::Shared, Future, FutureExt, TryFutureExt};
use gpui::{ use gpui::{
actions, App, AppContext as _, AsyncAppContext, Context, Entity, EntityId, EventEmitter, actions, App, AppContext as _, AsyncApp, Context, Entity, EntityId, EventEmitter, Global, Task,
Global, Task, WeakEntity, WeakEntity,
}; };
use http_client::github::get_release_by_tag_name; use http_client::github::get_release_by_tag_name;
use http_client::HttpClient; use http_client::HttpClient;
@ -424,7 +424,7 @@ impl Copilot {
http: Arc<dyn HttpClient>, http: Arc<dyn HttpClient>,
node_runtime: NodeRuntime, node_runtime: NodeRuntime,
this: WeakEntity<Self>, this: WeakEntity<Self>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) { ) {
let start_language_server = async { let start_language_server = async {
let server_path = get_copilot_lsp(http).await?; let server_path = get_copilot_lsp(http).await?;

View file

@ -6,7 +6,7 @@ use anyhow::{anyhow, Result};
use chrono::DateTime; use chrono::DateTime;
use fs::Fs; use fs::Fs;
use futures::{io::BufReader, stream::BoxStream, AsyncBufReadExt, AsyncReadExt, StreamExt}; use futures::{io::BufReader, stream::BoxStream, AsyncBufReadExt, AsyncReadExt, StreamExt};
use gpui::{prelude::*, App, AsyncAppContext, Global}; use gpui::{prelude::*, App, AsyncApp, Global};
use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest}; use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest};
use paths::home_dir; use paths::home_dir;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -268,7 +268,7 @@ impl CopilotChat {
pub async fn stream_completion( pub async fn stream_completion(
request: Request, request: Request,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<BoxStream<'static, Result<ResponseEvent>>> { ) -> Result<BoxStream<'static, Result<ResponseEvent>>> {
let Some(this) = cx.update(|cx| Self::global(cx)).ok().flatten() else { let Some(this) = cx.update(|cx| Self::global(cx)).ok().flatten() else {
return Err(anyhow!("Copilot chat is not enabled")); return Err(anyhow!("Copilot chat is not enabled"));

View file

@ -79,11 +79,11 @@ use git::blame::GitBlame;
use gpui::{ use gpui::{
div, impl_actions, point, prelude::*, px, relative, size, Action, AnyElement, App, div, impl_actions, point, prelude::*, px, relative, size, Action, AnyElement, App,
AsyncWindowContext, AvailableSpace, Bounds, ClipboardEntry, ClipboardItem, Context, AsyncWindowContext, AvailableSpace, Bounds, ClipboardEntry, ClipboardItem, Context,
DispatchPhase, ElementId, Entity, EventEmitter, FocusHandle, FocusOutEvent, Focusable, FontId, DispatchPhase, ElementId, Entity, EntityInputHandler, EventEmitter, FocusHandle, FocusOutEvent,
FontWeight, Global, HighlightStyle, Hsla, InteractiveText, KeyContext, MouseButton, PaintQuad, Focusable, FontId, FontWeight, Global, HighlightStyle, Hsla, InteractiveText, KeyContext,
ParentElement, Pixels, Render, SharedString, Size, Styled, StyledText, Subscription, Task, MouseButton, PaintQuad, ParentElement, Pixels, Render, SharedString, Size, Styled, StyledText,
TextStyle, TextStyleRefinement, UTF16Selection, UnderlineStyle, UniformListScrollHandle, Subscription, Task, TextStyle, TextStyleRefinement, UTF16Selection, UnderlineStyle,
ViewInputHandler, WeakEntity, WeakFocusHandle, Window, UniformListScrollHandle, WeakEntity, WeakFocusHandle, Window,
}; };
use highlight_matching_bracket::refresh_matching_bracket_highlights; use highlight_matching_bracket::refresh_matching_bracket_highlights;
use hover_popover::{hide_hover, HoverState}; use hover_popover::{hide_hover, HoverState};
@ -15355,7 +15355,7 @@ impl Render for Editor {
} }
} }
impl ViewInputHandler for Editor { impl EntityInputHandler for Editor {
fn text_for_range( fn text_for_range(
&mut self, &mut self,
range_utf16: Range<usize>, range_utf16: Range<usize>,

View file

@ -7331,7 +7331,7 @@ async fn test_multibuffer_format_during_save(cx: &mut gpui::TestAppContext) {
); );
multi_buffer multi_buffer
}); });
let multi_buffer_editor = cx.new_window_model(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::Full, EditorMode::Full,
multi_buffer, multi_buffer,
@ -12595,7 +12595,7 @@ async fn test_mutlibuffer_in_navigation_history(cx: &mut gpui::TestAppContext) {
let project = Project::test(fs, ["/a".as_ref()], cx).await; let project = Project::test(fs, ["/a".as_ref()], cx).await;
let workspace = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx)); let workspace = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx));
let cx = &mut VisualTestContext::from_window(*workspace.deref(), cx); let cx = &mut VisualTestContext::from_window(*workspace.deref(), cx);
let multi_buffer_editor = cx.new_window_model(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::Full, EditorMode::Full,
multi_buffer, multi_buffer,
@ -14800,7 +14800,7 @@ async fn test_find_enclosing_node_with_task(cx: &mut gpui::TestAppContext) {
let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(language, cx)); let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(language, cx));
let multi_buffer = cx.new(|cx| MultiBuffer::singleton(buffer.clone(), cx)); let multi_buffer = cx.new(|cx| MultiBuffer::singleton(buffer.clone(), cx));
let editor = cx.new_window_model(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::Full, EditorMode::Full,
multi_buffer, multi_buffer,
@ -14954,7 +14954,7 @@ async fn test_multi_buffer_folding(cx: &mut gpui::TestAppContext) {
); );
multi_buffer multi_buffer
}); });
let multi_buffer_editor = cx.new_window_model(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::Full, EditorMode::Full,
multi_buffer, multi_buffer,
@ -15109,7 +15109,7 @@ async fn test_multi_buffer_single_excerpts_folding(cx: &mut gpui::TestAppContext
multi_buffer multi_buffer
}); });
let multi_buffer_editor = cx.new_window_model(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::Full, EditorMode::Full,
multi_buffer, multi_buffer,
@ -15229,7 +15229,7 @@ async fn test_multi_buffer_with_single_excerpt_folding(cx: &mut gpui::TestAppCon
); );
multi_buffer multi_buffer
}); });
let multi_buffer_editor = cx.new_window_model(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::Full, EditorMode::Full,
multi_buffer, multi_buffer,

View file

@ -306,7 +306,7 @@ fn show_hover(
let mut background_color: Option<Hsla> = None; let mut background_color: Option<Hsla> = None;
let parsed_content = cx let parsed_content = cx
.new_window_model(|window, cx| { .new_window_entity(|window, cx| {
let status_colors = cx.theme().status(); let status_colors = cx.theme().status();
match local_diagnostic.diagnostic.severity { match local_diagnostic.diagnostic.severity {
@ -556,7 +556,7 @@ async fn parse_blocks(
.join("\n\n"); .join("\n\n");
let rendered_block = cx let rendered_block = cx
.new_window_model(|window, cx| { .new_window_entity(|window, cx| {
let settings = ThemeSettings::get_global(cx); let settings = ThemeSettings::get_global(cx);
let ui_font_family = settings.ui_font.family.clone(); let ui_font_family = settings.ui_font.family.clone();
let ui_font_fallbacks = settings.ui_font.fallbacks.clone(); let ui_font_fallbacks = settings.ui_font.fallbacks.clone();

View file

@ -14,8 +14,8 @@ use std::{ops::Range, sync::Arc};
use sum_tree::TreeMap; use sum_tree::TreeMap;
use text::OffsetRangeExt; use text::OffsetRangeExt;
use ui::{ use ui::{
prelude::*, ActiveTheme, ContextMenu, IconButtonShape, InteractiveElement, IntoElement, prelude::*, ActiveTheme, Context, Context, ContextMenu, IconButtonShape, InteractiveElement,
ModelContext, ParentElement, PopoverMenu, Styled, Tooltip, Window, IntoElement, ParentElement, PopoverMenu, Styled, Tooltip, Window,
}; };
use util::RangeExt; use util::RangeExt;
use workspace::Item; use workspace::Item;
@ -84,7 +84,7 @@ impl DiffMap {
&mut self, &mut self,
change_set: Model<BufferChangeSet>, change_set: Model<BufferChangeSet>,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Editor>, cx: &mut Context<Editor>,
) { ) {
let buffer_id = change_set.read(cx).buffer_id; let buffer_id = change_set.read(cx).buffer_id;
self.snapshot self.snapshot
@ -216,7 +216,7 @@ impl Editor {
&mut self, &mut self,
hovered_hunk: &HoveredHunk, hovered_hunk: &HoveredHunk,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Editor>, cx: &mut Context<Editor>,
) { ) {
let editor_snapshot = self.snapshot(window, cx); let editor_snapshot = self.snapshot(window, cx);
if let Some(diff_hunk) = to_diff_hunk(hovered_hunk, &editor_snapshot.buffer_snapshot) { if let Some(diff_hunk) = to_diff_hunk(hovered_hunk, &editor_snapshot.buffer_snapshot) {
@ -229,7 +229,7 @@ impl Editor {
&mut self, &mut self,
_: &ToggleHunkDiff, _: &ToggleHunkDiff,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
let snapshot = self.snapshot(window, cx); let snapshot = self.snapshot(window, cx);
let selections = self.selections.all(cx); let selections = self.selections.all(cx);
@ -240,7 +240,7 @@ impl Editor {
&mut self, &mut self,
_: &ExpandAllHunkDiffs, _: &ExpandAllHunkDiffs,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
let snapshot = self.snapshot(window, cx); let snapshot = self.snapshot(window, cx);
let display_rows_with_expanded_hunks = self let display_rows_with_expanded_hunks = self
@ -280,7 +280,7 @@ impl Editor {
&mut self, &mut self,
hunks_to_toggle: Vec<MultiBufferDiffHunk>, hunks_to_toggle: Vec<MultiBufferDiffHunk>,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
if self.diff_map.expand_all { if self.diff_map.expand_all {
return; return;
@ -389,7 +389,7 @@ impl Editor {
diff_base_buffer: Option<Model<Buffer>>, diff_base_buffer: Option<Model<Buffer>>,
hunk: &HoveredHunk, hunk: &HoveredHunk,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Editor>, cx: &mut Context<Editor>,
) -> Option<()> { ) -> Option<()> {
let buffer = self.buffer.clone(); let buffer = self.buffer.clone();
let multi_buffer_snapshot = buffer.read(cx).snapshot(cx); let multi_buffer_snapshot = buffer.read(cx).snapshot(cx);
@ -491,7 +491,7 @@ impl Editor {
&mut self, &mut self,
range: Range<Anchor>, range: Range<Anchor>,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Editor>, cx: &mut Context<Editor>,
) -> Option<()> { ) -> Option<()> {
let multi_buffer = self.buffer.read(cx); let multi_buffer = self.buffer.read(cx);
let multi_buffer_snapshot = multi_buffer.snapshot(cx); let multi_buffer_snapshot = multi_buffer.snapshot(cx);
@ -518,7 +518,7 @@ impl Editor {
&mut self, &mut self,
_: &ApplyAllDiffHunks, _: &ApplyAllDiffHunks,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
let buffers = self.buffer.read(cx).all_buffers(); let buffers = self.buffer.read(cx).all_buffers();
for branch_buffer in buffers { for branch_buffer in buffers {
@ -536,7 +536,7 @@ impl Editor {
&mut self, &mut self,
_: &ApplyDiffHunk, _: &ApplyDiffHunk,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
let snapshot = self.snapshot(window, cx); let snapshot = self.snapshot(window, cx);
let hunks = hunks_for_selections(&snapshot, &self.selections.all(cx)); let hunks = hunks_for_selections(&snapshot, &self.selections.all(cx));
@ -572,7 +572,7 @@ impl Editor {
fn hunk_header_block( fn hunk_header_block(
&self, &self,
hunk: &HoveredHunk, hunk: &HoveredHunk,
cx: &mut ModelContext<Editor>, cx: &mut Context<Editor>,
) -> BlockProperties<Anchor> { ) -> BlockProperties<Anchor> {
let is_branch_buffer = self let is_branch_buffer = self
.buffer .buffer
@ -860,7 +860,7 @@ impl Editor {
diff_base_buffer: Model<Buffer>, diff_base_buffer: Model<Buffer>,
deleted_text_height: u32, deleted_text_height: u32,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Editor>, cx: &mut Context<Editor>,
) -> BlockProperties<Anchor> { ) -> BlockProperties<Anchor> {
let gutter_color = match hunk.status { let gutter_color = match hunk.status {
DiffHunkStatus::Added => unreachable!(), DiffHunkStatus::Added => unreachable!(),
@ -923,7 +923,7 @@ impl Editor {
} }
} }
pub(super) fn clear_expanded_diff_hunks(&mut self, cx: &mut ModelContext<Editor>) -> bool { pub(super) fn clear_expanded_diff_hunks(&mut self, cx: &mut Context<Editor>) -> bool {
if self.diff_map.expand_all { if self.diff_map.expand_all {
return false; return false;
} }
@ -947,7 +947,7 @@ impl Editor {
diff_map: &mut DiffMap, diff_map: &mut DiffMap,
buffer_id: BufferId, buffer_id: BufferId,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
let diff_base_state = diff_map.diff_bases.get_mut(&buffer_id); let diff_base_state = diff_map.diff_bases.get_mut(&buffer_id);
let mut diff_base_buffer = None; let mut diff_base_buffer = None;
@ -1119,7 +1119,7 @@ impl Editor {
&mut self, &mut self,
position: Anchor, position: Anchor,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
let snapshot = self.snapshot(window, cx); let snapshot = self.snapshot(window, cx);
let position = position.to_point(&snapshot.buffer_snapshot); let position = position.to_point(&snapshot.buffer_snapshot);
@ -1147,7 +1147,7 @@ impl Editor {
&mut self, &mut self,
position: Anchor, position: Anchor,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Self>, cx: &mut Context<Self>,
) { ) {
let snapshot = self.snapshot(window, cx); let snapshot = self.snapshot(window, cx);
let position = position.to_point(&snapshot.buffer_snapshot); let position = position.to_point(&snapshot.buffer_snapshot);
@ -1212,7 +1212,7 @@ fn editor_with_deleted_text(
deleted_color: Hsla, deleted_color: Hsla,
hunk: &HoveredHunk, hunk: &HoveredHunk,
window: &mut Window, window: &mut Window,
cx: &mut ModelContext<Editor>, cx: &mut Context<Editor>,
) -> (u32, Model<Editor>) { ) -> (u32, Model<Editor>) {
let parent_editor = cx.model().downgrade(); let parent_editor = cx.model().downgrade();
let editor = cx.new(|cx| { let editor = cx.new(|cx| {

View file

@ -19,7 +19,7 @@ use crate::{
use anyhow::Context as _; use anyhow::Context as _;
use clock::Global; use clock::Global;
use futures::future; use futures::future;
use gpui::{AsyncAppContext, Context, Entity, Task, Window}; use gpui::{AsyncApp, Context, Entity, Task, Window};
use language::{language_settings::InlayHintKind, Buffer, BufferSnapshot}; use language::{language_settings::InlayHintKind, Buffer, BufferSnapshot};
use parking_lot::RwLock; use parking_lot::RwLock;
use project::{InlayHint, ResolveState}; use project::{InlayHint, ResolveState};
@ -840,7 +840,7 @@ fn new_update_task(
)); ));
let query_range_failed = let query_range_failed =
|range: &Range<language::Anchor>, e: anyhow::Error, cx: &mut AsyncAppContext| { |range: &Range<language::Anchor>, e: anyhow::Error, cx: &mut AsyncApp| {
log::error!("inlay hint update task for range failed: {e:#?}"); log::error!("inlay hint update task for range failed: {e:#?}");
editor editor
.update(cx, |editor, cx| { .update(cx, |editor, cx| {

View file

@ -329,7 +329,7 @@ impl EditorLspTestContext {
where where
T: 'static + request::Request, T: 'static + request::Request,
T::Params: 'static + Send, T::Params: 'static + Send,
F: 'static + Send + FnMut(lsp::Url, T::Params, gpui::AsyncAppContext) -> Fut, F: 'static + Send + FnMut(lsp::Url, T::Params, gpui::AsyncApp) -> Fut,
Fut: 'static + Send + Future<Output = Result<T::Result>>, Fut: 'static + Send + Future<Output = Result<T::Result>>,
{ {
let url = self.buffer_lsp_url.clone(); let url = self.buffer_lsp_url.clone();

View file

@ -6,7 +6,7 @@ use clock::RealSystemClock;
use collections::BTreeMap; use collections::BTreeMap;
use feature_flags::FeatureFlagAppExt as _; use feature_flags::FeatureFlagAppExt as _;
use git::GitHostingProviderRegistry; use git::GitHostingProviderRegistry;
use gpui::{AppContext as _, AsyncAppContext, BackgroundExecutor, Entity}; use gpui::{AppContext as _, AsyncApp, BackgroundExecutor, Entity};
use http_client::{HttpClient, Method}; use http_client::{HttpClient, Method};
use language::LanguageRegistry; use language::LanguageRegistry;
use node_runtime::NodeRuntime; use node_runtime::NodeRuntime;
@ -252,7 +252,7 @@ struct Counts {
async fn run_evaluation( async fn run_evaluation(
only_repo: Option<String>, only_repo: Option<String>,
executor: &BackgroundExecutor, executor: &BackgroundExecutor,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
let mut http_client = None; let mut http_client = None;
cx.update(|cx| { cx.update(|cx| {
@ -409,7 +409,7 @@ async fn run_eval_project(
project: Entity<Project>, project: Entity<Project>,
embedding_provider: Arc<dyn EmbeddingProvider>, embedding_provider: Arc<dyn EmbeddingProvider>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<(), anyhow::Error> { ) -> Result<(), anyhow::Error> {
let mut semantic_index = SemanticDb::new(repo_db_path, embedding_provider, cx).await?; let mut semantic_index = SemanticDb::new(repo_db_path, embedding_provider, cx).await?;
@ -546,7 +546,7 @@ async fn run_eval_project(
async fn wait_for_indexing_complete( async fn wait_for_indexing_complete(
project_index: &Entity<ProjectIndex>, project_index: &Entity<ProjectIndex>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
timeout: Option<Duration>, timeout: Option<Duration>,
) { ) {
let (tx, rx) = bounded(1); let (tx, rx) = bounded(1);

View file

@ -27,7 +27,7 @@ use futures::{
select_biased, AsyncReadExt as _, Future, FutureExt as _, StreamExt as _, select_biased, AsyncReadExt as _, Future, FutureExt as _, StreamExt as _,
}; };
use gpui::{ use gpui::{
actions, App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Global, Task, actions, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Global, Task,
WeakEntity, WeakEntity,
}; };
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl}; use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
@ -556,7 +556,7 @@ impl ExtensionStore {
async fn upgrade_extensions( async fn upgrade_extensions(
this: WeakEntity<Self>, this: WeakEntity<Self>,
extensions: Vec<ExtensionMetadata>, extensions: Vec<ExtensionMetadata>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
for extension in extensions { for extension in extensions {
let task = this.update(cx, |this, cx| { let task = this.update(cx, |this, cx| {
@ -1516,7 +1516,7 @@ impl ExtensionStore {
async fn sync_extensions_over_ssh( async fn sync_extensions_over_ssh(
this: &WeakEntity<Self>, this: &WeakEntity<Self>,
client: WeakEntity<SshRemoteClient>, client: WeakEntity<SshRemoteClient>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
let extensions = this.update(cx, |this, _cx| { let extensions = this.update(cx, |this, _cx| {
this.extension_index this.extension_index
@ -1581,10 +1581,7 @@ impl ExtensionStore {
anyhow::Ok(()) anyhow::Ok(())
} }
pub async fn update_ssh_clients( pub async fn update_ssh_clients(this: &WeakEntity<Self>, cx: &mut AsyncApp) -> Result<()> {
this: &WeakEntity<Self>,
cx: &mut AsyncAppContext,
) -> Result<()> {
let clients = this.update(cx, |this, _cx| { let clients = this.update(cx, |this, _cx| {
this.ssh_clients.retain(|_k, v| v.upgrade().is_some()); this.ssh_clients.retain(|_k, v| v.upgrade().is_some());
this.ssh_clients.values().cloned().collect::<Vec<_>>() this.ssh_clients.values().cloned().collect::<Vec<_>>()

View file

@ -8,7 +8,7 @@ use extension::{
ExtensionManifest, ExtensionManifest,
}; };
use fs::{Fs, RemoveOptions, RenameOptions}; use fs::{Fs, RemoveOptions, RenameOptions};
use gpui::{App, AppContext as _, AsyncAppContext, Context, Entity, Task, WeakEntity}; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, Task, WeakEntity};
use http_client::HttpClient; use http_client::HttpClient;
use language::{LanguageConfig, LanguageName, LanguageQueries, LoadedLanguage}; use language::{LanguageConfig, LanguageName, LanguageQueries, LoadedLanguage};
use lsp::LanguageServerName; use lsp::LanguageServerName;
@ -113,7 +113,7 @@ impl HeadlessExtensionStore {
pub async fn load_extension( pub async fn load_extension(
this: WeakEntity<Self>, this: WeakEntity<Self>,
extension: ExtensionVersion, extension: ExtensionVersion,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
let (fs, wasm_host, extension_dir) = this.update(cx, |this, _cx| { let (fs, wasm_host, extension_dir) = this.update(cx, |this, _cx| {
this.loaded_extensions.insert( this.loaded_extensions.insert(
@ -258,7 +258,7 @@ impl HeadlessExtensionStore {
pub async fn handle_sync_extensions( pub async fn handle_sync_extensions(
extension_store: Entity<HeadlessExtensionStore>, extension_store: Entity<HeadlessExtensionStore>,
envelope: TypedEnvelope<proto::SyncExtensions>, envelope: TypedEnvelope<proto::SyncExtensions>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::SyncExtensionsResponse> { ) -> Result<proto::SyncExtensionsResponse> {
let requested_extensions = let requested_extensions =
envelope envelope
@ -294,7 +294,7 @@ impl HeadlessExtensionStore {
pub async fn handle_install_extension( pub async fn handle_install_extension(
extensions: Entity<HeadlessExtensionStore>, extensions: Entity<HeadlessExtensionStore>,
envelope: TypedEnvelope<proto::InstallExtension>, envelope: TypedEnvelope<proto::InstallExtension>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let extension = envelope let extension = envelope
.payload .payload

View file

@ -17,7 +17,7 @@ use futures::{
future::BoxFuture, future::BoxFuture,
Future, FutureExt, StreamExt as _, Future, FutureExt, StreamExt as _,
}; };
use gpui::{App, AsyncAppContext, BackgroundExecutor, Task}; use gpui::{App, AsyncApp, BackgroundExecutor, Task};
use http_client::HttpClient; use http_client::HttpClient;
use language::LanguageName; use language::LanguageName;
use lsp::LanguageServerName; use lsp::LanguageServerName;
@ -305,8 +305,7 @@ pub struct WasmState {
pub host: Arc<WasmHost>, pub host: Arc<WasmHost>,
} }
type MainThreadCall = type MainThreadCall = Box<dyn Send + for<'a> FnOnce(&'a mut AsyncApp) -> LocalBoxFuture<'a, ()>>;
Box<dyn Send + for<'a> FnOnce(&'a mut AsyncAppContext) -> LocalBoxFuture<'a, ()>>;
type ExtensionCall = Box< type ExtensionCall = Box<
dyn Send + for<'a> FnOnce(&'a mut Extension, &'a mut Store<WasmState>) -> BoxFuture<'a, ()>, dyn Send + for<'a> FnOnce(&'a mut Extension, &'a mut Store<WasmState>) -> BoxFuture<'a, ()>,
@ -491,7 +490,7 @@ impl WasmExtension {
extension_dir: PathBuf, extension_dir: PathBuf,
manifest: &Arc<ExtensionManifest>, manifest: &Arc<ExtensionManifest>,
wasm_host: Arc<WasmHost>, wasm_host: Arc<WasmHost>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let path = extension_dir.join("extension.wasm"); let path = extension_dir.join("extension.wasm");
@ -538,7 +537,7 @@ impl WasmState {
fn on_main_thread<T, Fn>(&self, f: Fn) -> impl 'static + Future<Output = T> fn on_main_thread<T, Fn>(&self, f: Fn) -> impl 'static + Future<Output = T>
where where
T: 'static + Send, T: 'static + Send,
Fn: 'static + Send + for<'a> FnOnce(&'a mut AsyncAppContext) -> LocalBoxFuture<'a, T>, Fn: 'static + Send + for<'a> FnOnce(&'a mut AsyncApp) -> LocalBoxFuture<'a, T>,
{ {
let (return_tx, return_rx) = oneshot::channel(); let (return_tx, return_rx) = oneshot::channel();
self.host self.host

View file

@ -24,7 +24,7 @@ Provides access to the global application state. All other kinds of contexts ult
Provides access to the state of an application window, and also derefs to an `AppContext`, so you can pass a window context reference to any method taking an app context. Obtain this context by calling `WindowHandle::update`. Provides access to the state of an application window, and also derefs to an `AppContext`, so you can pass a window context reference to any method taking an app context. Obtain this context by calling `WindowHandle::update`.
## `ModelContext<T>` ## `Context<T>`
Available when you create or update a `Model<T>`. It derefs to an `AppContext`, but also contains methods specific to the particular model, such as the ability to notify change observers or emit events. Available when you create or update a `Model<T>`. It derefs to an `AppContext`, but also contains methods specific to the particular model, such as the ability to notify change observers or emit events.
@ -32,7 +32,7 @@ Available when you create or update a `Model<T>`. It derefs to an `AppContext`,
Available when you create or update a `View<V>`. It derefs to a `WindowContext`, but also contains methods specific to the particular view, such as the ability to notify change observers or emit events. Available when you create or update a `View<V>`. It derefs to a `WindowContext`, but also contains methods specific to the particular view, such as the ability to notify change observers or emit events.
## `AsyncAppContext` and `AsyncWindowContext` ## `AsyncApp` and `AsyncWindowContext`
Whereas the above contexts are always passed to your code as references, you can call `to_async` on the reference to create an async context, which has a static lifetime and can be held across `await` points in async code. When you interact with `Model`s or `View`s with an async context, the calls become fallible, because the context may outlive the window or even the app itself. Whereas the above contexts are always passed to your code as references, you can call `to_async` on the reference to create an async context, which has a static lifetime and can be held across `await` points in async code. When you interact with `Model`s or `View`s with an async context, the calls become fallible, because the context may outlive the window or even the app itself.

View file

@ -42,9 +42,9 @@ To bind actions, chain `on_action` on to your element:
```rust ```rust
impl Render for Menu { impl Render for Menu {
fn render(&mut self, window: &mut Window, cx: &mut ModelContext<Self>) -> impl Component { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl Component {
div() div()
.on_action(|this: &mut Menu, move: &MoveUp, window: &mut Window, cx: &mut ModelContext<Menu>| { .on_action(|this: &mut Menu, move: &MoveUp, window: &mut Window, cx: &mut Context<Menu>| {
// ... // ...
}) })
.on_action(|this, move: &MoveDown, cx| { .on_action(|this, move: &MoveDown, cx| {
@ -59,10 +59,10 @@ In order to bind keys to actions, you need to declare a _key context_ for part o
```rust ```rust
impl Render for Menu { impl Render for Menu {
fn render(&mut self, window: &mut Window, cx: &mut ModelContext<Self>) -> impl Component { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl Component {
div() div()
.key_context("menu") .key_context("menu")
.on_action(|this: &mut Menu, move: &MoveUp, window: &mut Window, cx: &mut ModelContext<Menu>| { .on_action(|this: &mut Menu, move: &MoveUp, window: &mut Window, cx: &mut Context<Menu>| {
// ... // ...
}) })
.on_action(|this, move: &MoveDown, cx| { .on_action(|this, move: &MoveDown, cx| {

View file

@ -3,10 +3,10 @@ use std::ops::Range;
use gpui::{ use gpui::{
actions, black, div, fill, hsla, opaque_grey, point, prelude::*, px, relative, rgb, rgba, size, actions, black, div, fill, hsla, opaque_grey, point, prelude::*, px, relative, rgb, rgba, size,
white, yellow, App, Application, Bounds, ClipboardItem, Context, CursorStyle, ElementId, white, yellow, App, Application, Bounds, ClipboardItem, Context, CursorStyle, ElementId,
ElementInputHandler, Entity, FocusHandle, Focusable, GlobalElementId, KeyBinding, Keystroke, ElementInputHandler, Entity, EntityInputHandler, FocusHandle, Focusable, GlobalElementId,
LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, Pixels, Point, KeyBinding, Keystroke, LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
ShapedLine, SharedString, Style, TextRun, UTF16Selection, UnderlineStyle, ViewInputHandler, PaintQuad, Pixels, Point, ShapedLine, SharedString, Style, TextRun, UTF16Selection,
Window, WindowBounds, WindowOptions, UnderlineStyle, Window, WindowBounds, WindowOptions,
}; };
use unicode_segmentation::*; use unicode_segmentation::*;
@ -257,7 +257,7 @@ impl TextInput {
} }
} }
impl ViewInputHandler for TextInput { impl EntityInputHandler for TextInput {
fn text_for_range( fn text_for_range(
&mut self, &mut self,
range_utf16: Range<usize>, range_utf16: Range<usize>,

View file

@ -1018,10 +1018,10 @@ impl App {
Ok(result) Ok(result)
}) })
} }
/// Creates an `AsyncAppContext`, which can be cloned and has a static lifetime /// Creates an `AsyncApp`, which can be cloned and has a static lifetime
/// so it can be held across `await` points. /// so it can be held across `await` points.
pub fn to_async(&self) -> AsyncAppContext { pub fn to_async(&self) -> AsyncApp {
AsyncAppContext { AsyncApp {
app: self.this.clone(), app: self.this.clone(),
background_executor: self.background_executor.clone(), background_executor: self.background_executor.clone(),
foreground_executor: self.foreground_executor.clone(), foreground_executor: self.foreground_executor.clone(),
@ -1039,8 +1039,8 @@ impl App {
} }
/// Spawns the future returned by the given function on the thread pool. The closure will be invoked /// Spawns the future returned by the given function on the thread pool. The closure will be invoked
/// with [AsyncAppContext], which allows the application state to be accessed across await points. /// with [AsyncApp], which allows the application state to be accessed across await points.
pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncAppContext) -> Fut) -> Task<R> pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task<R>
where where
Fut: Future<Output = R> + 'static, Fut: Future<Output = R> + 'static,
R: 'static, R: 'static,
@ -1598,11 +1598,11 @@ impl AppContext for App {
}) })
} }
fn reserve_model<T: 'static>(&mut self) -> Self::Result<Reservation<T>> { fn reserve_entity<T: 'static>(&mut self) -> Self::Result<Reservation<T>> {
Reservation(self.entities.reserve()) Reservation(self.entities.reserve())
} }
fn insert_model<T: 'static>( fn insert_entity<T: 'static>(
&mut self, &mut self,
reservation: Reservation<T>, reservation: Reservation<T>,
build_model: impl FnOnce(&mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Context<'_, T>) -> T,
@ -1616,7 +1616,7 @@ impl AppContext for App {
/// Updates the entity referenced by the given model. The function is passed a mutable reference to the /// Updates the entity referenced by the given model. The function is passed a mutable reference to the
/// entity along with a `ModelContext` for the entity. /// entity along with a `ModelContext` for the entity.
fn update_model<T: 'static, R>( fn update_entity<T: 'static, R>(
&mut self, &mut self,
model: &Entity<T>, model: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R, update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
@ -1632,7 +1632,7 @@ impl AppContext for App {
}) })
} }
fn read_model<T, R>( fn read_entity<T, R>(
&self, &self,
handle: &Entity<T>, handle: &Entity<T>,
read: impl FnOnce(&T, &App) -> R, read: impl FnOnce(&T, &App) -> R,

View file

@ -14,13 +14,13 @@ use super::Context;
/// You're provided with an instance when calling [AppContext::spawn], and you can also create one with [AppContext::to_async]. /// You're provided with an instance when calling [AppContext::spawn], and you can also create one with [AppContext::to_async].
/// Internally, this holds a weak reference to an `AppContext`, so its methods are fallible to protect against cases where the [AppContext] is dropped. /// Internally, this holds a weak reference to an `AppContext`, so its methods are fallible to protect against cases where the [AppContext] is dropped.
#[derive(Clone)] #[derive(Clone)]
pub struct AsyncAppContext { pub struct AsyncApp {
pub(crate) app: Weak<AppCell>, pub(crate) app: Weak<AppCell>,
pub(crate) background_executor: BackgroundExecutor, pub(crate) background_executor: BackgroundExecutor,
pub(crate) foreground_executor: ForegroundExecutor, pub(crate) foreground_executor: ForegroundExecutor,
} }
impl AppContext for AsyncAppContext { impl AppContext for AsyncApp {
type Result<T> = Result<T>; type Result<T> = Result<T>;
fn new<T: 'static>( fn new<T: 'static>(
@ -35,16 +35,16 @@ impl AppContext for AsyncAppContext {
Ok(app.new(build_model)) Ok(app.new(build_model))
} }
fn reserve_model<T: 'static>(&mut self) -> Result<Reservation<T>> { fn reserve_entity<T: 'static>(&mut self) -> Result<Reservation<T>> {
let app = self let app = self
.app .app
.upgrade() .upgrade()
.ok_or_else(|| anyhow!("app was released"))?; .ok_or_else(|| anyhow!("app was released"))?;
let mut app = app.borrow_mut(); let mut app = app.borrow_mut();
Ok(app.reserve_model()) Ok(app.reserve_entity())
} }
fn insert_model<T: 'static>( fn insert_entity<T: 'static>(
&mut self, &mut self,
reservation: Reservation<T>, reservation: Reservation<T>,
build_model: impl FnOnce(&mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Context<'_, T>) -> T,
@ -54,10 +54,10 @@ impl AppContext for AsyncAppContext {
.upgrade() .upgrade()
.ok_or_else(|| anyhow!("app was released"))?; .ok_or_else(|| anyhow!("app was released"))?;
let mut app = app.borrow_mut(); let mut app = app.borrow_mut();
Ok(app.insert_model(reservation, build_model)) Ok(app.insert_entity(reservation, build_model))
} }
fn update_model<T: 'static, R>( fn update_entity<T: 'static, R>(
&mut self, &mut self,
handle: &Entity<T>, handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R, update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
@ -67,10 +67,10 @@ impl AppContext for AsyncAppContext {
.upgrade() .upgrade()
.ok_or_else(|| anyhow!("app was released"))?; .ok_or_else(|| anyhow!("app was released"))?;
let mut app = app.borrow_mut(); let mut app = app.borrow_mut();
Ok(app.update_model(handle, update)) Ok(app.update_entity(handle, update))
} }
fn read_model<T, R>( fn read_entity<T, R>(
&self, &self,
handle: &Entity<T>, handle: &Entity<T>,
callback: impl FnOnce(&T, &App) -> R, callback: impl FnOnce(&T, &App) -> R,
@ -80,7 +80,7 @@ impl AppContext for AsyncAppContext {
{ {
let app = self.app.upgrade().context("app was released")?; let app = self.app.upgrade().context("app was released")?;
let lock = app.borrow(); let lock = app.borrow();
Ok(lock.read_model(handle, callback)) Ok(lock.read_entity(handle, callback))
} }
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T> fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
@ -106,7 +106,7 @@ impl AppContext for AsyncAppContext {
} }
} }
impl AsyncAppContext { impl AsyncApp {
/// Schedules all windows in the application to be redrawn. /// Schedules all windows in the application to be redrawn.
pub fn refresh(&self) -> Result<()> { pub fn refresh(&self) -> Result<()> {
let app = self let app = self
@ -156,7 +156,7 @@ impl AsyncAppContext {
} }
/// Schedule a future to be polled in the background. /// Schedule a future to be polled in the background.
pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncAppContext) -> Fut) -> Task<R> pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task<R>
where where
Fut: Future<Output = R> + 'static, Fut: Future<Output = R> + 'static,
R: 'static, R: 'static,
@ -190,7 +190,7 @@ impl AsyncAppContext {
/// Reads the global state of the specified type, passing it to the given callback. /// Reads the global state of the specified type, passing it to the given callback.
/// ///
/// Similar to [`AsyncAppContext::read_global`], but returns an error instead of panicking /// Similar to [`AsyncApp::read_global`], but returns an error instead of panicking
/// if no state of the specified type has been assigned. /// if no state of the specified type has been assigned.
/// ///
/// Returns an error if no state of the specified type has been assigned the `AppContext` has been dropped. /// Returns an error if no state of the specified type has been assigned the `AppContext` has been dropped.
@ -221,12 +221,12 @@ impl AsyncAppContext {
pub struct AsyncWindowContext { pub struct AsyncWindowContext {
#[deref] #[deref]
#[deref_mut] #[deref_mut]
app: AsyncAppContext, app: AsyncApp,
window: AnyWindowHandle, window: AnyWindowHandle,
} }
impl AsyncWindowContext { impl AsyncWindowContext {
pub(crate) fn new_context(app: AsyncAppContext, window: AnyWindowHandle) -> Self { pub(crate) fn new_context(app: AsyncApp, window: AnyWindowHandle) -> Self {
Self { app, window } Self { app, window }
} }
@ -317,29 +317,29 @@ impl AppContext for AsyncWindowContext {
self.window.update(self, |_, _, cx| cx.new(build_model)) self.window.update(self, |_, _, cx| cx.new(build_model))
} }
fn reserve_model<T: 'static>(&mut self) -> Result<Reservation<T>> { fn reserve_entity<T: 'static>(&mut self) -> Result<Reservation<T>> {
self.window.update(self, |_, _, cx| cx.reserve_model()) self.window.update(self, |_, _, cx| cx.reserve_entity())
} }
fn insert_model<T: 'static>( fn insert_entity<T: 'static>(
&mut self, &mut self,
reservation: Reservation<T>, reservation: Reservation<T>,
build_model: impl FnOnce(&mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Context<'_, T>) -> T,
) -> Self::Result<Entity<T>> { ) -> Self::Result<Entity<T>> {
self.window self.window
.update(self, |_, _, cx| cx.insert_model(reservation, build_model)) .update(self, |_, _, cx| cx.insert_entity(reservation, build_model))
} }
fn update_model<T: 'static, R>( fn update_entity<T: 'static, R>(
&mut self, &mut self,
handle: &Entity<T>, handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R, update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Result<R> { ) -> Result<R> {
self.window self.window
.update(self, |_, _, cx| cx.update_model(handle, update)) .update(self, |_, _, cx| cx.update_entity(handle, update))
} }
fn read_model<T, R>( fn read_entity<T, R>(
&self, &self,
handle: &Entity<T>, handle: &Entity<T>,
read: impl FnOnce(&T, &App) -> R, read: impl FnOnce(&T, &App) -> R,
@ -347,7 +347,7 @@ impl AppContext for AsyncWindowContext {
where where
T: 'static, T: 'static,
{ {
self.app.read_model(handle, read) self.app.read_entity(handle, read)
} }
fn update_window<T, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<T> fn update_window<T, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<T>
@ -374,7 +374,7 @@ impl VisualContext for AsyncWindowContext {
self.window self.window
} }
fn new_window_model<T: 'static>( fn new_window_entity<T: 'static>(
&mut self, &mut self,
build_model: impl FnOnce(&mut Window, &mut Context<T>) -> T, build_model: impl FnOnce(&mut Window, &mut Context<T>) -> T,
) -> Self::Result<Entity<T>> { ) -> Self::Result<Entity<T>> {
@ -382,7 +382,7 @@ impl VisualContext for AsyncWindowContext {
.update(self, |_, window, cx| cx.new(|cx| build_model(window, cx))) .update(self, |_, window, cx| cx.new(|cx| build_model(window, cx)))
} }
fn update_window_model<T: 'static, R>( fn update_window_entity<T: 'static, R>(
&mut self, &mut self,
view: &Entity<T>, view: &Entity<T>,
update: impl FnOnce(&mut T, &mut Window, &mut Context<T>) -> R, update: impl FnOnce(&mut T, &mut Window, &mut Context<T>) -> R,

View file

@ -422,7 +422,7 @@ impl<T: 'static> Entity<T> {
cx: &C, cx: &C,
f: impl FnOnce(&T, &App) -> R, f: impl FnOnce(&T, &App) -> R,
) -> C::Result<R> { ) -> C::Result<R> {
cx.read_model(self, f) cx.read_entity(self, f)
} }
/// Updates the entity referenced by this model with the given function. /// Updates the entity referenced by this model with the given function.
@ -438,7 +438,7 @@ impl<T: 'static> Entity<T> {
where where
C: AppContext, C: AppContext,
{ {
cx.update_model(self, update) cx.update_entity(self, update)
} }
/// Updates the entity referenced by this model with the given function if /// Updates the entity referenced by this model with the given function if
@ -452,7 +452,7 @@ impl<T: 'static> Entity<T> {
where where
C: VisualContext, C: VisualContext,
{ {
cx.update_window_model(self, update) cx.update_window_entity(self, update)
} }
} }
@ -650,7 +650,7 @@ impl<T: 'static> WeakEntity<T> {
crate::Flatten::flatten( crate::Flatten::flatten(
self.upgrade() self.upgrade()
.ok_or_else(|| anyhow!("entity released")) .ok_or_else(|| anyhow!("entity released"))
.map(|this| cx.update_model(&this, update)), .map(|this| cx.update_entity(&this, update)),
) )
} }
@ -685,7 +685,7 @@ impl<T: 'static> WeakEntity<T> {
crate::Flatten::flatten( crate::Flatten::flatten(
self.upgrade() self.upgrade()
.ok_or_else(|| anyhow!("entity release")) .ok_or_else(|| anyhow!("entity release"))
.map(|this| cx.read_model(&this, read)), .map(|this| cx.read_entity(&this, read)),
) )
} }
} }

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
AnyView, AnyWindowHandle, App, AppContext, AsyncAppContext, DispatchPhase, Effect, EntityId, AnyView, AnyWindowHandle, App, AppContext, AsyncApp, DispatchPhase, Effect, EntityId,
EventEmitter, FocusHandle, FocusOutEvent, Focusable, Global, KeystrokeObserver, Reservation, EventEmitter, FocusHandle, FocusOutEvent, Focusable, Global, KeystrokeObserver, Reservation,
SubscriberSet, Subscription, Task, WeakEntity, WeakFocusHandle, Window, WindowHandle, SubscriberSet, Subscription, Task, WeakEntity, WeakFocusHandle, Window, WindowHandle,
}; };
@ -183,7 +183,7 @@ impl<'a, T: 'static> Context<'a, T> {
/// Spawn the future returned by the given function. /// Spawn the future returned by the given function.
/// The function is provided a weak handle to the model owned by this context and a context that can be held across await points. /// The function is provided a weak handle to the model owned by this context and a context that can be held across await points.
/// The returned task must be held or detached. /// The returned task must be held or detached.
pub fn spawn<Fut, R>(&self, f: impl FnOnce(WeakEntity<T>, AsyncAppContext) -> Fut) -> Task<R> pub fn spawn<Fut, R>(&self, f: impl FnOnce(WeakEntity<T>, AsyncApp) -> Fut) -> Task<R>
where where
T: 'static, T: 'static,
Fut: Future<Output = R> + 'static, Fut: Future<Output = R> + 'static,
@ -683,27 +683,27 @@ impl<'a, T> AppContext for Context<'a, T> {
self.app.new(build_model) self.app.new(build_model)
} }
fn reserve_model<U: 'static>(&mut self) -> Reservation<U> { fn reserve_entity<U: 'static>(&mut self) -> Reservation<U> {
self.app.reserve_model() self.app.reserve_entity()
} }
fn insert_model<U: 'static>( fn insert_entity<U: 'static>(
&mut self, &mut self,
reservation: Reservation<U>, reservation: Reservation<U>,
build_model: impl FnOnce(&mut Context<'_, U>) -> U, build_model: impl FnOnce(&mut Context<'_, U>) -> U,
) -> Self::Result<Entity<U>> { ) -> Self::Result<Entity<U>> {
self.app.insert_model(reservation, build_model) self.app.insert_entity(reservation, build_model)
} }
fn update_model<U: 'static, R>( fn update_entity<U: 'static, R>(
&mut self, &mut self,
handle: &Entity<U>, handle: &Entity<U>,
update: impl FnOnce(&mut U, &mut Context<'_, U>) -> R, update: impl FnOnce(&mut U, &mut Context<'_, U>) -> R,
) -> R { ) -> R {
self.app.update_model(handle, update) self.app.update_entity(handle, update)
} }
fn read_model<U, R>( fn read_entity<U, R>(
&self, &self,
handle: &Entity<U>, handle: &Entity<U>,
read: impl FnOnce(&U, &App) -> R, read: impl FnOnce(&U, &App) -> R,
@ -711,7 +711,7 @@ impl<'a, T> AppContext for Context<'a, T> {
where where
U: 'static, U: 'static,
{ {
self.app.read_model(handle, read) self.app.read_entity(handle, read)
} }
fn update_window<R, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<R> fn update_window<R, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<R>

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
Action, AnyView, AnyWindowHandle, App, AppCell, AppContext, AsyncAppContext, AvailableSpace, Action, AnyView, AnyWindowHandle, App, AppCell, AppContext, AsyncApp, AvailableSpace,
BackgroundExecutor, BorrowAppContext, Bounds, ClipboardItem, DrawPhase, Drawable, Element, BackgroundExecutor, BorrowAppContext, Bounds, ClipboardItem, DrawPhase, Drawable, Element,
Empty, EventEmitter, ForegroundExecutor, Global, InputEvent, Keystroke, Modifiers, Empty, EventEmitter, ForegroundExecutor, Global, InputEvent, Keystroke, Modifiers,
ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels,
@ -40,30 +40,30 @@ impl AppContext for TestAppContext {
app.new(build_model) app.new(build_model)
} }
fn reserve_model<T: 'static>(&mut self) -> Self::Result<crate::Reservation<T>> { fn reserve_entity<T: 'static>(&mut self) -> Self::Result<crate::Reservation<T>> {
let mut app = self.app.borrow_mut(); let mut app = self.app.borrow_mut();
app.reserve_model() app.reserve_entity()
} }
fn insert_model<T: 'static>( fn insert_entity<T: 'static>(
&mut self, &mut self,
reservation: crate::Reservation<T>, reservation: crate::Reservation<T>,
build_model: impl FnOnce(&mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Context<'_, T>) -> T,
) -> Self::Result<Entity<T>> { ) -> Self::Result<Entity<T>> {
let mut app = self.app.borrow_mut(); let mut app = self.app.borrow_mut();
app.insert_model(reservation, build_model) app.insert_entity(reservation, build_model)
} }
fn update_model<T: 'static, R>( fn update_entity<T: 'static, R>(
&mut self, &mut self,
handle: &Entity<T>, handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R, update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Self::Result<R> { ) -> Self::Result<R> {
let mut app = self.app.borrow_mut(); let mut app = self.app.borrow_mut();
app.update_model(handle, update) app.update_entity(handle, update)
} }
fn read_model<T, R>( fn read_entity<T, R>(
&self, &self,
handle: &Entity<T>, handle: &Entity<T>,
read: impl FnOnce(&T, &App) -> R, read: impl FnOnce(&T, &App) -> R,
@ -72,7 +72,7 @@ impl AppContext for TestAppContext {
T: 'static, T: 'static,
{ {
let app = self.app.borrow(); let app = self.app.borrow();
app.read_model(handle, read) app.read_entity(handle, read)
} }
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T> fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
@ -302,7 +302,7 @@ impl TestAppContext {
} }
/// Run the given task on the main thread. /// Run the given task on the main thread.
pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncAppContext) -> Fut) -> Task<R> pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task<R>
where where
Fut: Future<Output = R> + 'static, Fut: Future<Output = R> + 'static,
R: 'static, R: 'static,
@ -341,10 +341,10 @@ impl TestAppContext {
lock.update(|cx| cx.update_global(update)) lock.update(|cx| cx.update_global(update))
} }
/// Returns an `AsyncAppContext` which can be used to run tasks that expect to be on a background /// Returns an `AsyncApp` which can be used to run tasks that expect to be on a background
/// thread on the current thread in tests. /// thread on the current thread in tests.
pub fn to_async(&self) -> AsyncAppContext { pub fn to_async(&self) -> AsyncApp {
AsyncAppContext { AsyncApp {
app: Rc::downgrade(&self.app), app: Rc::downgrade(&self.app),
background_executor: self.background_executor.clone(), background_executor: self.background_executor.clone(),
foreground_executor: self.foreground_executor.clone(), foreground_executor: self.foreground_executor.clone(),
@ -855,19 +855,19 @@ impl AppContext for VisualTestContext {
self.cx.new(build_model) self.cx.new(build_model)
} }
fn reserve_model<T: 'static>(&mut self) -> Self::Result<crate::Reservation<T>> { fn reserve_entity<T: 'static>(&mut self) -> Self::Result<crate::Reservation<T>> {
self.cx.reserve_model() self.cx.reserve_entity()
} }
fn insert_model<T: 'static>( fn insert_entity<T: 'static>(
&mut self, &mut self,
reservation: crate::Reservation<T>, reservation: crate::Reservation<T>,
build_model: impl FnOnce(&mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Context<'_, T>) -> T,
) -> Self::Result<Entity<T>> { ) -> Self::Result<Entity<T>> {
self.cx.insert_model(reservation, build_model) self.cx.insert_entity(reservation, build_model)
} }
fn update_model<T, R>( fn update_entity<T, R>(
&mut self, &mut self,
handle: &Entity<T>, handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R, update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
@ -875,10 +875,10 @@ impl AppContext for VisualTestContext {
where where
T: 'static, T: 'static,
{ {
self.cx.update_model(handle, update) self.cx.update_entity(handle, update)
} }
fn read_model<T, R>( fn read_entity<T, R>(
&self, &self,
handle: &Entity<T>, handle: &Entity<T>,
read: impl FnOnce(&T, &App) -> R, read: impl FnOnce(&T, &App) -> R,
@ -886,7 +886,7 @@ impl AppContext for VisualTestContext {
where where
T: 'static, T: 'static,
{ {
self.cx.read_model(handle, read) self.cx.read_entity(handle, read)
} }
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T> fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
@ -914,7 +914,7 @@ impl VisualContext for VisualTestContext {
self.window self.window
} }
fn new_window_model<T: 'static>( fn new_window_entity<T: 'static>(
&mut self, &mut self,
build_model: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T,
) -> Self::Result<Entity<T>> { ) -> Self::Result<Entity<T>> {
@ -925,7 +925,7 @@ impl VisualContext for VisualTestContext {
.unwrap() .unwrap()
} }
fn update_window_model<V: 'static, R>( fn update_window_entity<V: 'static, R>(
&mut self, &mut self,
view: &Entity<V>, view: &Entity<V>,
update: impl FnOnce(&mut V, &mut Window, &mut Context<V>) -> R, update: impl FnOnce(&mut V, &mut Window, &mut Context<V>) -> R,

View file

@ -171,19 +171,19 @@ pub trait AppContext {
/// Reserve a slot for a model to be inserted later. /// Reserve a slot for a model to be inserted later.
/// The returned [Reservation] allows you to obtain the [EntityId] for the future model. /// The returned [Reservation] allows you to obtain the [EntityId] for the future model.
fn reserve_model<T: 'static>(&mut self) -> Self::Result<Reservation<T>>; fn reserve_entity<T: 'static>(&mut self) -> Self::Result<Reservation<T>>;
/// Insert a new model in the app context based on a [Reservation] previously obtained from [`reserve_model`]. /// Insert a new model in the app context based on a [Reservation] previously obtained from [`reserve_entity`].
/// ///
/// [`reserve_model`]: Self::reserve_model /// [`reserve_entity`]: Self::reserve_entity
fn insert_model<T: 'static>( fn insert_entity<T: 'static>(
&mut self, &mut self,
reservation: Reservation<T>, reservation: Reservation<T>,
build_model: impl FnOnce(&mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Context<'_, T>) -> T,
) -> Self::Result<Entity<T>>; ) -> Self::Result<Entity<T>>;
/// Update a model in the app context. /// Update a model in the app context.
fn update_model<T, R>( fn update_entity<T, R>(
&mut self, &mut self,
handle: &Entity<T>, handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R, update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
@ -192,7 +192,7 @@ pub trait AppContext {
T: 'static; T: 'static;
/// Read a model from the app context. /// Read a model from the app context.
fn read_model<T, R>( fn read_entity<T, R>(
&self, &self,
handle: &Entity<T>, handle: &Entity<T>,
read: impl FnOnce(&T, &App) -> R, read: impl FnOnce(&T, &App) -> R,
@ -215,7 +215,7 @@ pub trait AppContext {
T: 'static; T: 'static;
} }
/// Returned by [Context::reserve_model] to later be passed to [Context::insert_model]. /// Returned by [Context::reserve_entity] to later be passed to [Context::insert_model].
/// Allows you to obtain the [EntityId] for a model before it is created. /// Allows you to obtain the [EntityId] for a model before it is created.
pub struct Reservation<T>(pub(crate) Slot<T>); pub struct Reservation<T>(pub(crate) Slot<T>);
@ -233,14 +233,14 @@ pub trait VisualContext: AppContext {
fn window_handle(&self) -> AnyWindowHandle; fn window_handle(&self) -> AnyWindowHandle;
/// Update a view with the given callback /// Update a view with the given callback
fn update_window_model<T: 'static, R>( fn update_window_entity<T: 'static, R>(
&mut self, &mut self,
model: &Entity<T>, model: &Entity<T>,
update: impl FnOnce(&mut T, &mut Window, &mut Context<T>) -> R, update: impl FnOnce(&mut T, &mut Window, &mut Context<T>) -> R,
) -> Self::Result<R>; ) -> Self::Result<R>;
/// Update a view with the given callback /// Update a view with the given callback
fn new_window_model<T: 'static>( fn new_window_entity<T: 'static>(
&mut self, &mut self,
build_model: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T, build_model: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T,
) -> Self::Result<Entity<T>>; ) -> Self::Result<Entity<T>>;

View file

@ -7,7 +7,7 @@ use std::ops::Range;
/// This input handler can then be assigned during paint by calling [`WindowContext::handle_input`]. /// This input handler can then be assigned during paint by calling [`WindowContext::handle_input`].
/// ///
/// See [`InputHandler`] for details on how to implement each method. /// See [`InputHandler`] for details on how to implement each method.
pub trait ViewInputHandler: 'static + Sized { pub trait EntityInputHandler: 'static + Sized {
/// See [`InputHandler::text_for_range`] for details /// See [`InputHandler::text_for_range`] for details
fn text_for_range( fn text_for_range(
&mut self, &mut self,
@ -84,7 +84,7 @@ impl<V: 'static> ElementInputHandler<V> {
} }
} }
impl<V: ViewInputHandler> InputHandler for ElementInputHandler<V> { impl<V: EntityInputHandler> InputHandler for ElementInputHandler<V> {
fn selected_text_range( fn selected_text_range(
&mut self, &mut self,
ignore_disabled_input: bool, ignore_disabled_input: bool,

View file

@ -9,12 +9,12 @@
/// actions!(editor,[Undo, Redo]);; /// actions!(editor,[Undo, Redo]);;
/// ///
/// impl Editor { /// impl Editor {
/// fn undo(&mut self, _: &Undo, _window: &mut Window, _cx: &mut ModelContext<Self>) { ... } /// fn undo(&mut self, _: &Undo, _window: &mut Window, _cx: &mut Context<Self>) { ... }
/// fn redo(&mut self, _: &Redo, _window: &mut Window, _cx: &mut ModelContext<Self>) { ... } /// fn redo(&mut self, _: &Redo, _window: &mut Window, _cx: &mut Context<Self>) { ... }
/// } /// }
/// ///
/// impl Render for Editor { /// impl Render for Editor {
/// fn render(&mut self, window: &mut Window, cx: &mut ModelContext<Self>) -> impl IntoElement { /// fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
/// div() /// div()
/// .track_focus(&self.focus_handle(cx)) /// .track_focus(&self.focus_handle(cx))
/// .keymap_context("Editor") /// .keymap_context("Editor")

View file

@ -17,3 +17,6 @@ doctest = false
proc-macro2 = "1.0.66" proc-macro2 = "1.0.66"
quote = "1.0.9" quote = "1.0.9"
syn = { version = "1.0.72", features = ["full", "extra-traits"] } syn = { version = "1.0.72", features = ["full", "extra-traits"] }
[dev-dependencies]
gpui.workspace = true

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, _window: &mut Window, _cx: &mut ModelContext<Self>) -> impl gpui::Element { fn render(&mut self, _window: &mut gpui::Window, _cx: &mut gpui::Context<Self>) -> impl gpui::Element {
gpui::Empty gpui::Empty
} }
} }

View file

@ -0,0 +1,7 @@
#[test]
fn test_derive_render() {
use gpui_macros::Render;
#[derive(Render)]
struct _Element;
}

View file

@ -1,11 +1,11 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use gpui::{actions, AsyncAppContext}; use gpui::{actions, AsyncApp};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use util::ResultExt; use util::ResultExt;
actions!(cli, [Install, RegisterZedScheme]); actions!(cli, [Install, RegisterZedScheme]);
pub async fn install_cli(cx: &AsyncAppContext) -> Result<PathBuf> { pub async fn install_cli(cx: &AsyncApp) -> Result<PathBuf> {
let cli_path = cx.update(|cx| cx.path_for_auxiliary_executable("cli"))??; let cli_path = cx.update(|cx| cx.path_for_auxiliary_executable("cli"))??;
let link_path = Path::new("/usr/local/bin/zed"); let link_path = Path::new("/usr/local/bin/zed");
let bin_dir_path = link_path.parent().unwrap(); let bin_dir_path = link_path.parent().unwrap();

View file

@ -928,7 +928,7 @@ impl Buffer {
language_registry: Option<Arc<LanguageRegistry>>, language_registry: Option<Arc<LanguageRegistry>>,
cx: &mut App, cx: &mut App,
) -> impl Future<Output = BufferSnapshot> { ) -> impl Future<Output = BufferSnapshot> {
let entity_id = cx.reserve_model::<Self>().entity_id(); let entity_id = cx.reserve_entity::<Self>().entity_id();
let buffer_id = entity_id.as_non_zero_u64().into(); let buffer_id = entity_id.as_non_zero_u64().into();
async move { async move {
let text = let text =

View file

@ -27,7 +27,7 @@ use async_trait::async_trait;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use fs::Fs; use fs::Fs;
use futures::Future; use futures::Future;
use gpui::{App, AsyncAppContext, Entity, SharedString, Task}; use gpui::{App, AsyncApp, Entity, SharedString, Task};
pub use highlight_map::HighlightMap; pub use highlight_map::HighlightMap;
use http_client::HttpClient; use http_client::HttpClient;
pub use language_registry::{LanguageName, LoadedLanguage}; pub use language_registry::{LanguageName, LoadedLanguage};
@ -211,7 +211,7 @@ impl CachedLspAdapter {
delegate: Arc<dyn LspAdapterDelegate>, delegate: Arc<dyn LspAdapterDelegate>,
toolchains: Arc<dyn LanguageToolchainStore>, toolchains: Arc<dyn LanguageToolchainStore>,
binary_options: LanguageServerBinaryOptions, binary_options: LanguageServerBinaryOptions,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<LanguageServerBinary> { ) -> Result<LanguageServerBinary> {
let cached_binary = self.cached_binary.lock().await; let cached_binary = self.cached_binary.lock().await;
self.adapter self.adapter
@ -293,7 +293,7 @@ pub trait LspAdapter: 'static + Send + Sync {
toolchains: Arc<dyn LanguageToolchainStore>, toolchains: Arc<dyn LanguageToolchainStore>,
binary_options: LanguageServerBinaryOptions, binary_options: LanguageServerBinaryOptions,
mut cached_binary: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>, mut cached_binary: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>,
cx: &'a mut AsyncAppContext, cx: &'a mut AsyncApp,
) -> Pin<Box<dyn 'a + Future<Output = Result<LanguageServerBinary>>>> { ) -> Pin<Box<dyn 'a + Future<Output = Result<LanguageServerBinary>>>> {
async move { async move {
// First we check whether the adapter can give us a user-installed binary. // First we check whether the adapter can give us a user-installed binary.
@ -368,7 +368,7 @@ pub trait LspAdapter: 'static + Send + Sync {
&self, &self,
_: &dyn LspAdapterDelegate, _: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
None None
} }
@ -381,7 +381,7 @@ pub trait LspAdapter: 'static + Send + Sync {
fn will_fetch_server( fn will_fetch_server(
&self, &self,
_: &Arc<dyn LspAdapterDelegate>, _: &Arc<dyn LspAdapterDelegate>,
_: &mut AsyncAppContext, _: &mut AsyncApp,
) -> Option<Task<Result<()>>> { ) -> Option<Task<Result<()>>> {
None None
} }
@ -476,7 +476,7 @@ pub trait LspAdapter: 'static + Send + Sync {
_: &dyn Fs, _: &dyn Fs,
_: &Arc<dyn LspAdapterDelegate>, _: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_cx: &mut AsyncAppContext, _cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
Ok(serde_json::json!({})) Ok(serde_json::json!({}))
} }
@ -514,7 +514,7 @@ async fn try_fetch_server_binary<L: LspAdapter + 'static + Send + Sync + ?Sized>
adapter: &L, adapter: &L,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
container_dir: PathBuf, container_dir: PathBuf,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<LanguageServerBinary> { ) -> Result<LanguageServerBinary> {
if let Some(task) = adapter.will_fetch_server(delegate, cx) { if let Some(task) = adapter.will_fetch_server(delegate, cx) {
task.await?; task.await?;
@ -1805,7 +1805,7 @@ impl LspAdapter for FakeLspAdapter {
&self, &self,
_: &dyn LspAdapterDelegate, _: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
Some(self.language_server_binary.clone()) Some(self.language_server_binary.clone())
} }
@ -1816,7 +1816,7 @@ impl LspAdapter for FakeLspAdapter {
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: LanguageServerBinaryOptions, _: LanguageServerBinaryOptions,
_: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>, _: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>,
_: &'a mut AsyncAppContext, _: &'a mut AsyncApp,
) -> Pin<Box<dyn 'a + Future<Output = Result<LanguageServerBinary>>>> { ) -> Pin<Box<dyn 'a + Future<Output = Result<LanguageServerBinary>>>> {
async move { Ok(self.language_server_binary.clone()) }.boxed_local() async move { Ok(self.language_server_binary.clone()) }.boxed_local()
} }

View file

@ -904,7 +904,7 @@ impl LanguageRegistry {
server_id: LanguageServerId, server_id: LanguageServerId,
name: &LanguageServerName, name: &LanguageServerName,
binary: lsp::LanguageServerBinary, binary: lsp::LanguageServerBinary,
cx: gpui::AsyncAppContext, cx: gpui::AsyncApp,
) -> Option<lsp::LanguageServer> { ) -> Option<lsp::LanguageServer> {
let mut state = self.state.write(); let mut state = self.state.write();
let fake_entry = state.fake_server_entries.get_mut(&name)?; let fake_entry = state.fake_server_entries.get_mut(&name)?;

View file

@ -8,7 +8,7 @@ use std::{path::PathBuf, sync::Arc};
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use gpui::{AsyncAppContext, SharedString}; use gpui::{AsyncApp, SharedString};
use settings::WorktreeId; use settings::WorktreeId;
use crate::LanguageName; use crate::LanguageName;
@ -53,7 +53,7 @@ pub trait LanguageToolchainStore {
self: Arc<Self>, self: Arc<Self>,
worktree_id: WorktreeId, worktree_id: WorktreeId,
language_name: LanguageName, language_name: LanguageName,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Option<Toolchain>; ) -> Option<Toolchain>;
} }

View file

@ -10,7 +10,7 @@ use collections::HashMap;
use extension::{Extension, ExtensionLanguageServerProxy, WorktreeDelegate}; use extension::{Extension, ExtensionLanguageServerProxy, WorktreeDelegate};
use fs::Fs; use fs::Fs;
use futures::{Future, FutureExt}; use futures::{Future, FutureExt};
use gpui::AsyncAppContext; use gpui::AsyncApp;
use language::{ use language::{
CodeLabel, HighlightId, Language, LanguageName, LanguageServerBinaryStatus, CodeLabel, HighlightId, Language, LanguageName, LanguageServerBinaryStatus,
LanguageToolchainStore, LspAdapter, LspAdapterDelegate, LanguageToolchainStore, LspAdapter, LspAdapterDelegate,
@ -119,7 +119,7 @@ impl LspAdapter for ExtensionLspAdapter {
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: LanguageServerBinaryOptions, _: LanguageServerBinaryOptions,
_: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>, _: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>,
_: &'a mut AsyncAppContext, _: &'a mut AsyncApp,
) -> Pin<Box<dyn 'a + Future<Output = Result<LanguageServerBinary>>>> { ) -> Pin<Box<dyn 'a + Future<Output = Result<LanguageServerBinary>>>> {
async move { async move {
let delegate = Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _; let delegate = Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _;
@ -251,7 +251,7 @@ impl LspAdapter for ExtensionLspAdapter {
_: &dyn Fs, _: &dyn Fs,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_cx: &mut AsyncAppContext, _cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let delegate = Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _; let delegate = Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _;
let json_options: Option<String> = self let json_options: Option<String> = self

View file

@ -4,7 +4,7 @@ use crate::{
LanguageModelProviderState, LanguageModelRequest, LanguageModelProviderState, LanguageModelRequest,
}; };
use futures::{channel::mpsc, future::BoxFuture, stream::BoxStream, FutureExt, StreamExt}; use futures::{channel::mpsc, future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
use gpui::{AnyView, App, AsyncAppContext, Entity, Task, Window}; use gpui::{AnyView, App, AsyncApp, Entity, Task, Window};
use http_client::Result; use http_client::Result;
use parking_lot::Mutex; use parking_lot::Mutex;
use serde::Serialize; use serde::Serialize;
@ -164,7 +164,7 @@ impl LanguageModel for FakeLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
_: &AsyncAppContext, _: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> {
let (tx, rx) = mpsc::unbounded(); let (tx, rx) = mpsc::unbounded();
self.current_completion_txs.lock().push((request, tx)); self.current_completion_txs.lock().push((request, tx));
@ -182,7 +182,7 @@ impl LanguageModel for FakeLanguageModel {
name: String, name: String,
description: String, description: String,
schema: serde_json::Value, schema: serde_json::Value,
_cx: &AsyncAppContext, _cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> {
let (tx, rx) = mpsc::unbounded(); let (tx, rx) = mpsc::unbounded();
let tool_call = ToolUseRequest { let tool_call = ToolUseRequest {

View file

@ -10,7 +10,7 @@ pub mod fake_provider;
use anyhow::Result; use anyhow::Result;
use futures::FutureExt; use futures::FutureExt;
use futures::{future::BoxFuture, stream::BoxStream, StreamExt, TryStreamExt as _}; use futures::{future::BoxFuture, stream::BoxStream, StreamExt, TryStreamExt as _};
use gpui::{AnyElement, AnyView, App, AsyncAppContext, SharedString, Task, Window}; use gpui::{AnyElement, AnyView, App, AsyncApp, SharedString, Task, Window};
pub use model::*; pub use model::*;
use proto::Plan; use proto::Plan;
pub use rate_limiter::*; pub use rate_limiter::*;
@ -136,13 +136,13 @@ pub trait LanguageModel: Send + Sync {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>>; ) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>>;
fn stream_completion_text( fn stream_completion_text(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<LanguageModelTextStream>> { ) -> BoxFuture<'static, Result<LanguageModelTextStream>> {
let events = self.stream_completion(request, cx); let events = self.stream_completion(request, cx);
@ -186,7 +186,7 @@ pub trait LanguageModel: Send + Sync {
name: String, name: String,
description: String, description: String,
schema: serde_json::Value, schema: serde_json::Value,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>>; ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>>;
fn cache_configuration(&self) -> Option<LanguageModelCacheConfiguration> { fn cache_configuration(&self) -> Option<LanguageModelCacheConfiguration> {
@ -203,7 +203,7 @@ impl dyn LanguageModel {
pub fn use_tool<T: LanguageModelTool>( pub fn use_tool<T: LanguageModelTool>(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> impl 'static + Future<Output = Result<T>> { ) -> impl 'static + Future<Output = Result<T>> {
let schema = schemars::schema_for!(T); let schema = schemars::schema_for!(T);
let schema_json = serde_json::to_value(&schema).unwrap(); let schema_json = serde_json::to_value(&schema).unwrap();
@ -218,7 +218,7 @@ impl dyn LanguageModel {
pub fn use_tool_stream<T: LanguageModelTool>( pub fn use_tool_stream<T: LanguageModelTool>(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> {
let schema = schemars::schema_for!(T); let schema = schemars::schema_for!(T);
let schema_json = serde_json::to_value(&schema).unwrap(); let schema_json = serde_json::to_value(&schema).unwrap();

View file

@ -6,8 +6,7 @@ use editor::{Editor, EditorElement, EditorStyle};
use futures::Stream; use futures::Stream;
use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt, TryStreamExt as _}; use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt, TryStreamExt as _};
use gpui::{ use gpui::{
AnyView, App, AsyncAppContext, Context, Entity, FontStyle, Subscription, Task, TextStyle, AnyView, App, AsyncApp, Context, Entity, FontStyle, Subscription, Task, TextStyle, WhiteSpace,
WhiteSpace,
}; };
use http_client::HttpClient; use http_client::HttpClient;
use language_model::{ use language_model::{
@ -307,12 +306,12 @@ impl AnthropicModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: anthropic::Request, request: anthropic::Request,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<anthropic::Event, AnthropicError>>>> ) -> BoxFuture<'static, Result<BoxStream<'static, Result<anthropic::Event, AnthropicError>>>>
{ {
let http_client = self.http_client.clone(); let http_client = self.http_client.clone();
let Ok((api_key, api_url)) = cx.read_model(&self.state, |state, cx| { let Ok((api_key, api_url)) = cx.read_entity(&self.state, |state, cx| {
let settings = &AllLanguageModelSettings::get_global(cx).anthropic; let settings = &AllLanguageModelSettings::get_global(cx).anthropic;
(state.api_key.clone(), settings.api_url.clone()) (state.api_key.clone(), settings.api_url.clone())
}) else { }) else {
@ -373,7 +372,7 @@ impl LanguageModel for AnthropicModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> {
let request = request.into_anthropic( let request = request.into_anthropic(
self.model.id().into(), self.model.id().into(),
@ -404,7 +403,7 @@ impl LanguageModel for AnthropicModel {
tool_name: String, tool_name: String,
tool_description: String, tool_description: String,
input_schema: serde_json::Value, input_schema: serde_json::Value,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> {
let mut request = request.into_anthropic( let mut request = request.into_anthropic(
self.model.tool_model_id().into(), self.model.tool_model_id().into(),

View file

@ -12,7 +12,7 @@ use futures::{
TryStreamExt as _, TryStreamExt as _,
}; };
use gpui::{ use gpui::{
AnyElement, AnyView, App, AsyncAppContext, Context, Entity, EventEmitter, Global, ReadGlobal, AnyElement, AnyView, App, AsyncApp, Context, Entity, EventEmitter, Global, ReadGlobal,
Subscription, Task, Subscription, Task,
}; };
use http_client::{AsyncBody, HttpClient, Method, Response, StatusCode}; use http_client::{AsyncBody, HttpClient, Method, Response, StatusCode};
@ -131,7 +131,7 @@ impl RefreshLlmTokenListener {
async fn handle_refresh_llm_token( async fn handle_refresh_llm_token(
this: Entity<Self>, this: Entity<Self>,
_: TypedEnvelope<proto::RefreshLlmToken>, _: TypedEnvelope<proto::RefreshLlmToken>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |_this, cx| cx.emit(RefreshLlmTokenEvent)) this.update(&mut cx, |_this, cx| cx.emit(RefreshLlmTokenEvent))
} }
@ -621,7 +621,7 @@ impl LanguageModel for CloudLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
_cx: &AsyncAppContext, _cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> {
match &self.model { match &self.model {
CloudModel::Anthropic(model) => { CloudModel::Anthropic(model) => {
@ -716,7 +716,7 @@ impl LanguageModel for CloudLanguageModel {
tool_name: String, tool_name: String,
tool_description: String, tool_description: String,
input_schema: serde_json::Value, input_schema: serde_json::Value,
_cx: &AsyncAppContext, _cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> {
let client = self.client.clone(); let client = self.client.clone();
let llm_api_token = self.llm_api_token.clone(); let llm_api_token = self.llm_api_token.clone();

View file

@ -11,8 +11,8 @@ use futures::future::BoxFuture;
use futures::stream::BoxStream; use futures::stream::BoxStream;
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
use gpui::{ use gpui::{
percentage, svg, Animation, AnimationExt, AnyView, App, AsyncAppContext, Entity, Render, percentage, svg, Animation, AnimationExt, AnyView, App, AsyncApp, Entity, Render, Subscription,
Subscription, Task, Transformation, Task, Transformation,
}; };
use language_model::{ use language_model::{
LanguageModel, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModel, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName,
@ -190,7 +190,7 @@ impl LanguageModel for CopilotChatLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> {
if let Some(message) = request.messages.last() { if let Some(message) = request.messages.last() {
if message.contents_empty() { if message.contents_empty() {
@ -266,7 +266,7 @@ impl LanguageModel for CopilotChatLanguageModel {
_name: String, _name: String,
_description: String, _description: String,
_schema: serde_json::Value, _schema: serde_json::Value,
_cx: &AsyncAppContext, _cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> {
future::ready(Err(anyhow!("not implemented"))).boxed() future::ready(Err(anyhow!("not implemented"))).boxed()
} }

View file

@ -4,8 +4,7 @@ use editor::{Editor, EditorElement, EditorStyle};
use futures::{future::BoxFuture, FutureExt, StreamExt}; use futures::{future::BoxFuture, FutureExt, StreamExt};
use google_ai::stream_generate_content; use google_ai::stream_generate_content;
use gpui::{ use gpui::{
AnyView, App, AsyncAppContext, Context, Entity, FontStyle, Subscription, Task, TextStyle, AnyView, App, AsyncApp, Context, Entity, FontStyle, Subscription, Task, TextStyle, WhiteSpace,
WhiteSpace,
}; };
use http_client::HttpClient; use http_client::HttpClient;
use language_model::LanguageModelCompletionEvent; use language_model::LanguageModelCompletionEvent;
@ -282,7 +281,7 @@ impl LanguageModel for GoogleLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture< ) -> BoxFuture<
'static, 'static,
Result<futures::stream::BoxStream<'static, Result<LanguageModelCompletionEvent>>>, Result<futures::stream::BoxStream<'static, Result<LanguageModelCompletionEvent>>>,
@ -290,7 +289,7 @@ impl LanguageModel for GoogleLanguageModel {
let request = request.into_google(self.model.id().to_string()); let request = request.into_google(self.model.id().to_string());
let http_client = self.http_client.clone(); let http_client = self.http_client.clone();
let Ok((api_key, api_url)) = cx.read_model(&self.state, |state, cx| { let Ok((api_key, api_url)) = cx.read_entity(&self.state, |state, cx| {
let settings = &AllLanguageModelSettings::get_global(cx).google; let settings = &AllLanguageModelSettings::get_global(cx).google;
(state.api_key.clone(), settings.api_url.clone()) (state.api_key.clone(), settings.api_url.clone())
}) else { }) else {
@ -319,7 +318,7 @@ impl LanguageModel for GoogleLanguageModel {
_name: String, _name: String,
_description: String, _description: String,
_schema: serde_json::Value, _schema: serde_json::Value,
_cx: &AsyncAppContext, _cx: &AsyncApp,
) -> BoxFuture<'static, Result<futures::stream::BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<futures::stream::BoxStream<'static, Result<String>>>> {
future::ready(Err(anyhow!("not implemented"))).boxed() future::ready(Err(anyhow!("not implemented"))).boxed()
} }

View file

@ -1,6 +1,6 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt}; use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
use gpui::{AnyView, App, AsyncAppContext, Context, Subscription, Task}; use gpui::{AnyView, App, AsyncApp, Context, Subscription, Task};
use http_client::HttpClient; use http_client::HttpClient;
use language_model::LanguageModelCompletionEvent; use language_model::LanguageModelCompletionEvent;
use language_model::{ use language_model::{
@ -295,7 +295,7 @@ impl LanguageModel for LmStudioLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> {
let request = self.to_lmstudio_request(request); let request = self.to_lmstudio_request(request);
@ -362,7 +362,7 @@ impl LanguageModel for LmStudioLanguageModel {
_tool_name: String, _tool_name: String,
_tool_description: String, _tool_description: String,
_schema: serde_json::Value, _schema: serde_json::Value,
_cx: &AsyncAppContext, _cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> {
async move { Ok(futures::stream::empty().boxed()) }.boxed() async move { Ok(futures::stream::empty().boxed()) }.boxed()
} }

View file

@ -1,6 +1,6 @@
use anyhow::{anyhow, bail, Result}; use anyhow::{anyhow, bail, Result};
use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt}; use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
use gpui::{AnyView, App, AsyncAppContext, Context, Subscription, Task}; use gpui::{AnyView, App, AsyncApp, Context, Subscription, Task};
use http_client::HttpClient; use http_client::HttpClient;
use language_model::LanguageModelCompletionEvent; use language_model::LanguageModelCompletionEvent;
use language_model::{ use language_model::{
@ -263,7 +263,7 @@ impl OllamaLanguageModel {
fn request_completion( fn request_completion(
&self, &self,
request: ChatRequest, request: ChatRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<ChatResponseDelta>> { ) -> BoxFuture<'static, Result<ChatResponseDelta>> {
let http_client = self.http_client.clone(); let http_client = self.http_client.clone();
@ -323,7 +323,7 @@ impl LanguageModel for OllamaLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<LanguageModelCompletionEvent>>>> {
let request = self.to_ollama_request(request); let request = self.to_ollama_request(request);
@ -370,7 +370,7 @@ impl LanguageModel for OllamaLanguageModel {
tool_name: String, tool_name: String,
tool_description: String, tool_description: String,
schema: serde_json::Value, schema: serde_json::Value,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>> {
use ollama::{OllamaFunctionTool, OllamaTool}; use ollama::{OllamaFunctionTool, OllamaTool};
let function = OllamaFunctionTool { let function = OllamaFunctionTool {

View file

@ -3,8 +3,7 @@ use collections::BTreeMap;
use editor::{Editor, EditorElement, EditorStyle}; use editor::{Editor, EditorElement, EditorStyle};
use futures::{future::BoxFuture, FutureExt, StreamExt}; use futures::{future::BoxFuture, FutureExt, StreamExt};
use gpui::{ use gpui::{
AnyView, App, AsyncAppContext, Context, Entity, FontStyle, Subscription, Task, TextStyle, AnyView, App, AsyncApp, Context, Entity, FontStyle, Subscription, Task, TextStyle, WhiteSpace,
WhiteSpace,
}; };
use http_client::HttpClient; use http_client::HttpClient;
use language_model::{ use language_model::{
@ -224,11 +223,11 @@ impl OpenAiLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: open_ai::Request, request: open_ai::Request,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<futures::stream::BoxStream<'static, Result<ResponseStreamEvent>>>> ) -> BoxFuture<'static, Result<futures::stream::BoxStream<'static, Result<ResponseStreamEvent>>>>
{ {
let http_client = self.http_client.clone(); let http_client = self.http_client.clone();
let Ok((api_key, api_url)) = cx.read_model(&self.state, |state, cx| { let Ok((api_key, api_url)) = cx.read_entity(&self.state, |state, cx| {
let settings = &AllLanguageModelSettings::get_global(cx).openai; let settings = &AllLanguageModelSettings::get_global(cx).openai;
(state.api_key.clone(), settings.api_url.clone()) (state.api_key.clone(), settings.api_url.clone())
}) else { }) else {
@ -286,7 +285,7 @@ impl LanguageModel for OpenAiLanguageModel {
fn stream_completion( fn stream_completion(
&self, &self,
request: LanguageModelRequest, request: LanguageModelRequest,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture< ) -> BoxFuture<
'static, 'static,
Result<futures::stream::BoxStream<'static, Result<LanguageModelCompletionEvent>>>, Result<futures::stream::BoxStream<'static, Result<LanguageModelCompletionEvent>>>,
@ -307,7 +306,7 @@ impl LanguageModel for OpenAiLanguageModel {
tool_name: String, tool_name: String,
tool_description: String, tool_description: String,
schema: serde_json::Value, schema: serde_json::Value,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> BoxFuture<'static, Result<futures::stream::BoxStream<'static, Result<String>>>> { ) -> BoxFuture<'static, Result<futures::stream::BoxStream<'static, Result<String>>>> {
let mut request = request.into_open_ai(self.model.id().into(), self.max_output_tokens()); let mut request = request.into_open_ai(self.model.id().into(), self.max_output_tokens());
request.tool_choice = Some(ToolChoice::Other(ToolDefinition::Function { request.tool_choice = Some(ToolChoice::Other(ToolDefinition::Function {

View file

@ -1,7 +1,7 @@
use anyhow::{anyhow, bail, Context, Result}; use anyhow::{anyhow, bail, Context, Result};
use async_trait::async_trait; use async_trait::async_trait;
use futures::StreamExt; use futures::StreamExt;
use gpui::AsyncAppContext; use gpui::AsyncApp;
use http_client::github::{latest_github_release, GitHubLspBinaryVersion}; use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
pub use language::*; pub use language::*;
use lsp::{InitializeParams, LanguageServerBinary, LanguageServerName}; use lsp::{InitializeParams, LanguageServerBinary, LanguageServerName};
@ -26,7 +26,7 @@ impl super::LspAdapter for CLspAdapter {
&self, &self,
delegate: &dyn LspAdapterDelegate, delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
let path = delegate.which(Self::SERVER_NAME.as_ref()).await?; let path = delegate.which(Self::SERVER_NAME.as_ref()).await?;
Some(LanguageServerBinary { Some(LanguageServerBinary {

View file

@ -2,7 +2,7 @@ use anyhow::{anyhow, Context as _, Result};
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use futures::StreamExt; use futures::StreamExt;
use gpui::{App, AsyncAppContext, Task}; use gpui::{App, AsyncApp, Task};
use http_client::github::latest_github_release; use http_client::github::latest_github_release;
pub use language::*; pub use language::*;
use lsp::{LanguageServerBinary, LanguageServerName}; use lsp::{LanguageServerBinary, LanguageServerName};
@ -76,7 +76,7 @@ impl super::LspAdapter for GoLspAdapter {
&self, &self,
delegate: &dyn LspAdapterDelegate, delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
let path = delegate.which(Self::SERVER_NAME.as_ref()).await?; let path = delegate.which(Self::SERVER_NAME.as_ref()).await?;
Some(LanguageServerBinary { Some(LanguageServerBinary {
@ -89,7 +89,7 @@ impl super::LspAdapter for GoLspAdapter {
fn will_fetch_server( fn will_fetch_server(
&self, &self,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Option<Task<Result<()>>> { ) -> Option<Task<Result<()>>> {
static DID_SHOW_NOTIFICATION: AtomicBool = AtomicBool::new(false); static DID_SHOW_NOTIFICATION: AtomicBool = AtomicBool::new(false);

View file

@ -4,7 +4,7 @@ use async_tar::Archive;
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use futures::StreamExt; use futures::StreamExt;
use gpui::{App, AsyncAppContext}; use gpui::{App, AsyncApp};
use http_client::github::{latest_github_release, GitHubLspBinaryVersion}; use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
use language::{LanguageRegistry, LanguageToolchainStore, LspAdapter, LspAdapterDelegate}; use language::{LanguageRegistry, LanguageToolchainStore, LspAdapter, LspAdapterDelegate};
use lsp::{LanguageServerBinary, LanguageServerName}; use lsp::{LanguageServerBinary, LanguageServerName};
@ -221,7 +221,7 @@ impl LspAdapter for JsonLspAdapter {
_: &dyn Fs, _: &dyn Fs,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let mut config = cx.update(|cx| { let mut config = cx.update(|cx| {
self.workspace_config self.workspace_config

View file

@ -3,7 +3,7 @@ use anyhow::{anyhow, Result};
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use gpui::{App, Task}; use gpui::{App, Task};
use gpui::{AsyncAppContext, SharedString}; use gpui::{AsyncApp, SharedString};
use language::language_settings::language_settings; use language::language_settings::language_settings;
use language::LanguageName; use language::LanguageName;
use language::LanguageToolchainStore; use language::LanguageToolchainStore;
@ -81,7 +81,7 @@ impl LspAdapter for PythonLspAdapter {
&self, &self,
delegate: &dyn LspAdapterDelegate, delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
let node = delegate.which("node".as_ref()).await?; let node = delegate.which("node".as_ref()).await?;
let (node_modules_path, _) = delegate let (node_modules_path, _) = delegate
@ -254,7 +254,7 @@ impl LspAdapter for PythonLspAdapter {
_: &dyn Fs, _: &dyn Fs,
adapter: &Arc<dyn LspAdapterDelegate>, adapter: &Arc<dyn LspAdapterDelegate>,
toolchains: Arc<dyn LanguageToolchainStore>, toolchains: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let toolchain = toolchains let toolchain = toolchains
.active_toolchain(adapter.worktree_id(), LanguageName::new("Python"), cx) .active_toolchain(adapter.worktree_id(), LanguageName::new("Python"), cx)
@ -789,7 +789,7 @@ impl LspAdapter for PyLspAdapter {
&self, &self,
delegate: &dyn LspAdapterDelegate, delegate: &dyn LspAdapterDelegate,
toolchains: Arc<dyn LanguageToolchainStore>, toolchains: Arc<dyn LanguageToolchainStore>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
let venv = toolchains let venv = toolchains
.active_toolchain( .active_toolchain(
@ -936,7 +936,7 @@ impl LspAdapter for PyLspAdapter {
_: &dyn Fs, _: &dyn Fs,
adapter: &Arc<dyn LspAdapterDelegate>, adapter: &Arc<dyn LspAdapterDelegate>,
toolchains: Arc<dyn LanguageToolchainStore>, toolchains: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let toolchain = toolchains let toolchain = toolchains
.active_toolchain(adapter.worktree_id(), LanguageName::new("Python"), cx) .active_toolchain(adapter.worktree_id(), LanguageName::new("Python"), cx)

View file

@ -3,7 +3,7 @@ use async_compression::futures::bufread::GzipDecoder;
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use futures::{io::BufReader, StreamExt}; use futures::{io::BufReader, StreamExt};
use gpui::{App, AsyncAppContext, Task}; use gpui::{App, AsyncApp, Task};
use http_client::github::AssetKind; use http_client::github::AssetKind;
use http_client::github::{latest_github_release, GitHubLspBinaryVersion}; use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
pub use language::*; pub use language::*;
@ -78,7 +78,7 @@ impl LspAdapter for RustLspAdapter {
&self, &self,
delegate: &dyn LspAdapterDelegate, delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
let path = delegate.which("rust-analyzer".as_ref()).await?; let path = delegate.which("rust-analyzer".as_ref()).await?;
let env = delegate.shell_env().await; let env = delegate.shell_env().await;

View file

@ -2,7 +2,7 @@ use anyhow::{anyhow, Result};
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use futures::StreamExt; use futures::StreamExt;
use gpui::AsyncAppContext; use gpui::AsyncApp;
use language::{LanguageToolchainStore, LspAdapter, LspAdapterDelegate}; use language::{LanguageToolchainStore, LspAdapter, LspAdapterDelegate};
use lsp::{LanguageServerBinary, LanguageServerName}; use lsp::{LanguageServerBinary, LanguageServerName};
use node_runtime::NodeRuntime; use node_runtime::NodeRuntime;
@ -135,7 +135,7 @@ impl LspAdapter for TailwindLspAdapter {
_: &dyn Fs, _: &dyn Fs,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let mut tailwind_user_settings = cx.update(|cx| { let mut tailwind_user_settings = cx.update(|cx| {
language_server_settings(delegate.as_ref(), &Self::SERVER_NAME, cx) language_server_settings(delegate.as_ref(), &Self::SERVER_NAME, cx)

View file

@ -3,7 +3,7 @@ use async_compression::futures::bufread::GzipDecoder;
use async_tar::Archive; use async_tar::Archive;
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use gpui::AsyncAppContext; use gpui::AsyncApp;
use http_client::github::{build_asset_url, AssetKind, GitHubLspBinaryVersion}; use http_client::github::{build_asset_url, AssetKind, GitHubLspBinaryVersion};
use language::{LanguageToolchainStore, LspAdapter, LspAdapterDelegate}; use language::{LanguageToolchainStore, LspAdapter, LspAdapterDelegate};
use lsp::{CodeActionKind, LanguageServerBinary, LanguageServerName}; use lsp::{CodeActionKind, LanguageServerBinary, LanguageServerName};
@ -270,7 +270,7 @@ impl LspAdapter for TypeScriptLspAdapter {
_: &dyn Fs, _: &dyn Fs,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let override_options = cx.update(|cx| { let override_options = cx.update(|cx| {
language_server_settings(delegate.as_ref(), &Self::SERVER_NAME, cx) language_server_settings(delegate.as_ref(), &Self::SERVER_NAME, cx)
@ -367,7 +367,7 @@ impl LspAdapter for EsLintLspAdapter {
_: &dyn Fs, _: &dyn Fs,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let workspace_root = delegate.worktree_root_path(); let workspace_root = delegate.worktree_root_path();

View file

@ -1,7 +1,7 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use async_trait::async_trait; use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use gpui::AsyncAppContext; use gpui::AsyncApp;
use language::{LanguageToolchainStore, LspAdapter, LspAdapterDelegate}; use language::{LanguageToolchainStore, LspAdapter, LspAdapterDelegate};
use lsp::{CodeActionKind, LanguageServerBinary, LanguageServerName}; use lsp::{CodeActionKind, LanguageServerBinary, LanguageServerName};
use node_runtime::NodeRuntime; use node_runtime::NodeRuntime;
@ -87,7 +87,7 @@ impl LspAdapter for VtslsLspAdapter {
&self, &self,
delegate: &dyn LspAdapterDelegate, delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
let env = delegate.shell_env().await; let env = delegate.shell_env().await;
let path = delegate.which(SERVER_NAME.as_ref()).await?; let path = delegate.which(SERVER_NAME.as_ref()).await?;
@ -208,7 +208,7 @@ impl LspAdapter for VtslsLspAdapter {
fs: &dyn Fs, fs: &dyn Fs,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let tsdk_path = Self::tsdk_path(fs, delegate).await; let tsdk_path = Self::tsdk_path(fs, delegate).await;
let config = serde_json::json!({ let config = serde_json::json!({

View file

@ -1,7 +1,7 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use async_trait::async_trait; use async_trait::async_trait;
use futures::StreamExt; use futures::StreamExt;
use gpui::AsyncAppContext; use gpui::AsyncApp;
use language::{ use language::{
language_settings::AllLanguageSettings, LanguageToolchainStore, LspAdapter, LspAdapterDelegate, language_settings::AllLanguageSettings, LanguageToolchainStore, LspAdapter, LspAdapterDelegate,
}; };
@ -58,7 +58,7 @@ impl LspAdapter for YamlLspAdapter {
&self, &self,
delegate: &dyn LspAdapterDelegate, delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
let path = delegate.which(Self::SERVER_NAME.as_ref()).await?; let path = delegate.which(Self::SERVER_NAME.as_ref()).await?;
let env = delegate.shell_env().await; let env = delegate.shell_env().await;
@ -131,7 +131,7 @@ impl LspAdapter for YamlLspAdapter {
_: &dyn Fs, _: &dyn Fs,
delegate: &Arc<dyn LspAdapterDelegate>, delegate: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Value> { ) -> Result<Value> {
let location = SettingsLocation { let location = SettingsLocation {
worktree_id: delegate.worktree_id(), worktree_id: delegate.worktree_id(),

View file

@ -6,7 +6,7 @@
use gpui::{ use gpui::{
actions, bounds, div, point, actions, bounds, div, point,
prelude::{FluentBuilder as _, IntoElement}, prelude::{FluentBuilder as _, IntoElement},
px, rgb, size, AppContext as _, AsyncAppContext, Bounds, Context, Entity, InteractiveElement, px, rgb, size, AppContext as _, AsyncApp, Bounds, Context, Entity, InteractiveElement,
KeyBinding, Menu, MenuItem, ParentElement, Pixels, Render, ScreenCaptureStream, SharedString, KeyBinding, Menu, MenuItem, ParentElement, Pixels, Render, ScreenCaptureStream, SharedString,
StatefulInteractiveElement as _, Styled, Task, Window, WindowBounds, WindowHandle, StatefulInteractiveElement as _, Styled, Task, Window, WindowBounds, WindowHandle,
WindowOptions, WindowOptions,
@ -127,7 +127,7 @@ impl LivekitWindow {
url: &str, url: &str,
token: &str, token: &str,
bounds: Bounds<Pixels>, bounds: Bounds<Pixels>,
cx: AsyncAppContext, cx: AsyncApp,
) -> WindowHandle<Self> { ) -> WindowHandle<Self> {
let (room, mut events) = Room::connect(url, token, RoomOptions::default()) let (room, mut events) = Room::connect(url, token, RoomOptions::default())
.await .await

View file

@ -6,7 +6,7 @@ pub use lsp_types::*;
use anyhow::{anyhow, Context as _, Result}; use anyhow::{anyhow, Context as _, Result};
use collections::HashMap; use collections::HashMap;
use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, Future, FutureExt}; use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, Future, FutureExt};
use gpui::{App, AsyncAppContext, BackgroundExecutor, SharedString, Task}; use gpui::{App, AsyncApp, BackgroundExecutor, SharedString, Task};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use postage::{barrier, prelude::Stream}; use postage::{barrier, prelude::Stream};
use schemars::{ use schemars::{
@ -45,7 +45,7 @@ const CONTENT_LEN_HEADER: &str = "Content-Length: ";
const LSP_REQUEST_TIMEOUT: Duration = Duration::from_secs(60 * 2); const LSP_REQUEST_TIMEOUT: Duration = Duration::from_secs(60 * 2);
const SERVER_SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(5); const SERVER_SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(5);
type NotificationHandler = Box<dyn Send + FnMut(Option<RequestId>, Value, AsyncAppContext)>; type NotificationHandler = Box<dyn Send + FnMut(Option<RequestId>, Value, AsyncApp)>;
type ResponseHandler = Box<dyn Send + FnOnce(Result<String, Error>)>; type ResponseHandler = Box<dyn Send + FnOnce(Result<String, Error>)>;
type IoHandler = Box<dyn Send + FnMut(IoKind, &str)>; type IoHandler = Box<dyn Send + FnMut(IoKind, &str)>;
@ -334,7 +334,7 @@ impl LanguageServer {
binary: LanguageServerBinary, binary: LanguageServerBinary,
root_path: &Path, root_path: &Path,
code_action_kinds: Option<Vec<CodeActionKind>>, code_action_kinds: Option<Vec<CodeActionKind>>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let working_dir = if root_path.is_dir() { let working_dir = if root_path.is_dir() {
root_path root_path
@ -407,7 +407,7 @@ impl LanguageServer {
working_dir: &Path, working_dir: &Path,
code_action_kinds: Option<Vec<CodeActionKind>>, code_action_kinds: Option<Vec<CodeActionKind>>,
binary: LanguageServerBinary, binary: LanguageServerBinary,
cx: AsyncAppContext, cx: AsyncApp,
on_unhandled_notification: F, on_unhandled_notification: F,
) -> Self ) -> Self
where where
@ -505,7 +505,7 @@ impl LanguageServer {
notification_handlers: Arc<Mutex<HashMap<&'static str, NotificationHandler>>>, notification_handlers: Arc<Mutex<HashMap<&'static str, NotificationHandler>>>,
response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>, response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>,
io_handlers: Arc<Mutex<HashMap<i32, IoHandler>>>, io_handlers: Arc<Mutex<HashMap<i32, IoHandler>>>,
cx: AsyncAppContext, cx: AsyncApp,
) -> anyhow::Result<()> ) -> anyhow::Result<()>
where where
Stdout: AsyncRead + Unpin + Send + 'static, Stdout: AsyncRead + Unpin + Send + 'static,
@ -890,7 +890,7 @@ impl LanguageServer {
pub fn on_notification<T, F>(&self, f: F) -> Subscription pub fn on_notification<T, F>(&self, f: F) -> Subscription
where where
T: notification::Notification, T: notification::Notification,
F: 'static + Send + FnMut(T::Params, AsyncAppContext), F: 'static + Send + FnMut(T::Params, AsyncApp),
{ {
self.on_custom_notification(T::METHOD, f) self.on_custom_notification(T::METHOD, f)
} }
@ -903,7 +903,7 @@ impl LanguageServer {
where where
T: request::Request, T: request::Request,
T::Params: 'static + Send, T::Params: 'static + Send,
F: 'static + FnMut(T::Params, AsyncAppContext) -> Fut + Send, F: 'static + FnMut(T::Params, AsyncApp) -> Fut + Send,
Fut: 'static + Future<Output = Result<T::Result>>, Fut: 'static + Future<Output = Result<T::Result>>,
{ {
self.on_custom_request(T::METHOD, f) self.on_custom_request(T::METHOD, f)
@ -941,7 +941,7 @@ impl LanguageServer {
#[must_use] #[must_use]
fn on_custom_notification<Params, F>(&self, method: &'static str, mut f: F) -> Subscription fn on_custom_notification<Params, F>(&self, method: &'static str, mut f: F) -> Subscription
where where
F: 'static + FnMut(Params, AsyncAppContext) + Send, F: 'static + FnMut(Params, AsyncApp) + Send,
Params: DeserializeOwned, Params: DeserializeOwned,
{ {
let prev_handler = self.notification_handlers.lock().insert( let prev_handler = self.notification_handlers.lock().insert(
@ -965,7 +965,7 @@ impl LanguageServer {
#[must_use] #[must_use]
fn on_custom_request<Params, Res, Fut, F>(&self, method: &'static str, mut f: F) -> Subscription fn on_custom_request<Params, Res, Fut, F>(&self, method: &'static str, mut f: F) -> Subscription
where where
F: 'static + FnMut(Params, AsyncAppContext) -> Fut + Send, F: 'static + FnMut(Params, AsyncApp) -> Fut + Send,
Fut: 'static + Future<Output = Result<Res>>, Fut: 'static + Future<Output = Result<Res>>,
Params: DeserializeOwned + Send + 'static, Params: DeserializeOwned + Send + 'static,
Res: Serialize, Res: Serialize,
@ -1282,7 +1282,7 @@ impl FakeLanguageServer {
binary: LanguageServerBinary, binary: LanguageServerBinary,
name: String, name: String,
capabilities: ServerCapabilities, capabilities: ServerCapabilities,
cx: AsyncAppContext, cx: AsyncApp,
) -> (LanguageServer, FakeLanguageServer) { ) -> (LanguageServer, FakeLanguageServer) {
let (stdin_writer, stdin_reader) = async_pipe::pipe(); let (stdin_writer, stdin_reader) = async_pipe::pipe();
let (stdout_writer, stdout_reader) = async_pipe::pipe(); let (stdout_writer, stdout_reader) = async_pipe::pipe();
@ -1430,7 +1430,7 @@ impl FakeLanguageServer {
where where
T: 'static + request::Request, T: 'static + request::Request,
T::Params: 'static + Send, T::Params: 'static + Send,
F: 'static + Send + FnMut(T::Params, gpui::AsyncAppContext) -> Fut, F: 'static + Send + FnMut(T::Params, gpui::AsyncApp) -> Fut,
Fut: 'static + Send + Future<Output = Result<T::Result>>, Fut: 'static + Send + Future<Output = Result<T::Result>>,
{ {
let (responded_tx, responded_rx) = futures::channel::mpsc::unbounded(); let (responded_tx, responded_rx) = futures::channel::mpsc::unbounded();
@ -1459,7 +1459,7 @@ impl FakeLanguageServer {
where where
T: 'static + notification::Notification, T: 'static + notification::Notification,
T::Params: 'static + Send, T::Params: 'static + Send,
F: 'static + Send + FnMut(T::Params, gpui::AsyncAppContext), F: 'static + Send + FnMut(T::Params, gpui::AsyncApp),
{ {
let (handled_tx, handled_rx) = futures::channel::mpsc::unbounded(); let (handled_tx, handled_rx) = futures::channel::mpsc::unbounded();
self.server.remove_notification_handler::<T>(); self.server.remove_notification_handler::<T>();

View file

@ -3,7 +3,7 @@ use channel::{ChannelMessage, ChannelMessageId, ChannelStore};
use client::{ChannelId, Client, UserStore}; use client::{ChannelId, Client, UserStore};
use collections::HashMap; use collections::HashMap;
use db::smol::stream::StreamExt; use db::smol::stream::StreamExt;
use gpui::{App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Global, Task}; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Global, Task};
use rpc::{proto, Notification, TypedEnvelope}; use rpc::{proto, Notification, TypedEnvelope};
use std::{ops::Range, sync::Arc}; use std::{ops::Range, sync::Arc};
use sum_tree::{Bias, SumTree}; use sum_tree::{Bias, SumTree};
@ -199,7 +199,7 @@ impl NotificationStore {
async fn handle_new_notification( async fn handle_new_notification(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::AddNotification>, envelope: TypedEnvelope<proto::AddNotification>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
Self::add_notifications( Self::add_notifications(
this, this,
@ -217,7 +217,7 @@ impl NotificationStore {
async fn handle_delete_notification( async fn handle_delete_notification(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::DeleteNotification>, envelope: TypedEnvelope<proto::DeleteNotification>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.splice_notifications([(envelope.payload.notification_id, None)], false, cx); this.splice_notifications([(envelope.payload.notification_id, None)], false, cx);
@ -228,7 +228,7 @@ impl NotificationStore {
async fn handle_update_notification( async fn handle_update_notification(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateNotification>, envelope: TypedEnvelope<proto::UpdateNotification>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
if let Some(notification) = envelope.payload.notification { if let Some(notification) = envelope.payload.notification {
@ -259,7 +259,7 @@ impl NotificationStore {
this: Entity<Self>, this: Entity<Self>,
notifications: Vec<proto::Notification>, notifications: Vec<proto::Notification>,
options: AddNotificationsOptions, options: AddNotificationsOptions,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let mut user_ids = Vec::new(); let mut user_ids = Vec::new();
let mut message_ids = Vec::new(); let mut message_ids = Vec::new();

View file

@ -1,7 +1,7 @@
use anyhow::{anyhow, Context as _}; use anyhow::{anyhow, Context as _};
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use fs::Fs; use fs::Fs;
use gpui::{AsyncAppContext, Entity}; use gpui::{AsyncApp, Entity};
use language::{language_settings::language_settings, Buffer, Diff}; use language::{language_settings::language_settings, Buffer, Diff};
use lsp::{LanguageServer, LanguageServerId}; use lsp::{LanguageServer, LanguageServerId};
use node_runtime::NodeRuntime; use node_runtime::NodeRuntime;
@ -235,7 +235,7 @@ impl Prettier {
_: LanguageServerId, _: LanguageServerId,
prettier_dir: PathBuf, prettier_dir: PathBuf,
_: NodeRuntime, _: NodeRuntime,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
Ok(Self::Test(TestPrettier { Ok(Self::Test(TestPrettier {
default: prettier_dir == default_prettier_dir().as_path(), default: prettier_dir == default_prettier_dir().as_path(),
@ -248,7 +248,7 @@ impl Prettier {
server_id: LanguageServerId, server_id: LanguageServerId,
prettier_dir: PathBuf, prettier_dir: PathBuf,
node: NodeRuntime, node: NodeRuntime,
cx: AsyncAppContext, cx: AsyncApp,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
use lsp::{LanguageServerBinary, LanguageServerName}; use lsp::{LanguageServerBinary, LanguageServerName};
@ -305,7 +305,7 @@ impl Prettier {
buffer: &Entity<Buffer>, buffer: &Entity<Buffer>,
buffer_path: Option<PathBuf>, buffer_path: Option<PathBuf>,
ignore_dir: Option<PathBuf>, ignore_dir: Option<PathBuf>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> anyhow::Result<Diff> { ) -> anyhow::Result<Diff> {
match self { match self {
Self::Real(local) => { Self::Real(local) => {

View file

@ -12,8 +12,7 @@ use fs::Fs;
use futures::{channel::oneshot, future::Shared, Future, FutureExt as _, StreamExt}; use futures::{channel::oneshot, future::Shared, Future, FutureExt as _, StreamExt};
use git::{blame::Blame, diff::BufferDiff, repository::RepoPath}; use git::{blame::Blame, diff::BufferDiff, repository::RepoPath};
use gpui::{ use gpui::{
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Subscription, Task, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Subscription, Task, WeakEntity,
WeakEntity,
}; };
use http_client::Url; use http_client::Url;
use language::{ use language::{
@ -787,7 +786,7 @@ impl LocalBufferStore {
) -> Task<Result<Entity<Buffer>>> { ) -> Task<Result<Entity<Buffer>>> {
let load_buffer = worktree.update(cx, |worktree, cx| { let load_buffer = worktree.update(cx, |worktree, cx| {
let load_file = worktree.load_file(path.as_ref(), cx); let load_file = worktree.load_file(path.as_ref(), cx);
let reservation = cx.reserve_model(); let reservation = cx.reserve_entity();
let buffer_id = BufferId::from(reservation.entity_id().as_non_zero_u64()); let buffer_id = BufferId::from(reservation.entity_id().as_non_zero_u64());
cx.spawn(move |_, mut cx| async move { cx.spawn(move |_, mut cx| async move {
let loaded = load_file.await?; let loaded = load_file.await?;
@ -795,7 +794,7 @@ impl LocalBufferStore {
.background_executor() .background_executor()
.spawn(async move { text::Buffer::new(0, buffer_id, loaded.text) }) .spawn(async move { text::Buffer::new(0, buffer_id, loaded.text) })
.await; .await;
cx.insert_model(reservation, |_| { cx.insert_entity(reservation, |_| {
Buffer::build(text_buffer, Some(loaded.file), Capability::ReadWrite) Buffer::build(text_buffer, Some(loaded.file), Capability::ReadWrite)
}) })
}) })
@ -1058,7 +1057,7 @@ impl BufferStore {
this: WeakEntity<Self>, this: WeakEntity<Self>,
text: Result<Option<String>>, text: Result<Option<String>>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Entity<BufferChangeSet>> { ) -> Result<Entity<BufferChangeSet>> {
let text = match text { let text = match text {
Err(e) => { Err(e) => {
@ -1562,7 +1561,7 @@ impl BufferStore {
pub async fn handle_update_buffer( pub async fn handle_update_buffer(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateBuffer>, envelope: TypedEnvelope<proto::UpdateBuffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let payload = envelope.payload.clone(); let payload = envelope.payload.clone();
let buffer_id = BufferId::new(payload.buffer_id)?; let buffer_id = BufferId::new(payload.buffer_id)?;
@ -1717,7 +1716,7 @@ impl BufferStore {
pub async fn handle_update_buffer_file( pub async fn handle_update_buffer_file(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateBufferFile>, envelope: TypedEnvelope<proto::UpdateBufferFile>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let buffer_id = envelope.payload.buffer_id; let buffer_id = envelope.payload.buffer_id;
let buffer_id = BufferId::new(buffer_id)?; let buffer_id = BufferId::new(buffer_id)?;
@ -1765,7 +1764,7 @@ impl BufferStore {
pub async fn handle_save_buffer( pub async fn handle_save_buffer(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::SaveBuffer>, envelope: TypedEnvelope<proto::SaveBuffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::BufferSaved> { ) -> Result<proto::BufferSaved> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
let (buffer, project_id) = this.update(&mut cx, |this, _| { let (buffer, project_id) = this.update(&mut cx, |this, _| {
@ -1806,7 +1805,7 @@ impl BufferStore {
pub async fn handle_close_buffer( pub async fn handle_close_buffer(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::CloseBuffer>, envelope: TypedEnvelope<proto::CloseBuffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let peer_id = envelope.sender_id; let peer_id = envelope.sender_id;
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
@ -1830,7 +1829,7 @@ impl BufferStore {
pub async fn handle_buffer_saved( pub async fn handle_buffer_saved(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::BufferSaved>, envelope: TypedEnvelope<proto::BufferSaved>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
let version = deserialize_version(&envelope.payload.version); let version = deserialize_version(&envelope.payload.version);
@ -1858,7 +1857,7 @@ impl BufferStore {
pub async fn handle_buffer_reloaded( pub async fn handle_buffer_reloaded(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::BufferReloaded>, envelope: TypedEnvelope<proto::BufferReloaded>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
let version = deserialize_version(&envelope.payload.version); let version = deserialize_version(&envelope.payload.version);
@ -1891,7 +1890,7 @@ impl BufferStore {
pub async fn handle_blame_buffer( pub async fn handle_blame_buffer(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::BlameBuffer>, envelope: TypedEnvelope<proto::BlameBuffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::BlameBufferResponse> { ) -> Result<proto::BlameBufferResponse> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
let version = deserialize_version(&envelope.payload.version); let version = deserialize_version(&envelope.payload.version);
@ -1912,7 +1911,7 @@ impl BufferStore {
pub async fn handle_get_permalink_to_line( pub async fn handle_get_permalink_to_line(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::GetPermalinkToLine>, envelope: TypedEnvelope<proto::GetPermalinkToLine>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::GetPermalinkToLineResponse> { ) -> Result<proto::GetPermalinkToLineResponse> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
// let version = deserialize_version(&envelope.payload.version); // let version = deserialize_version(&envelope.payload.version);
@ -1937,7 +1936,7 @@ impl BufferStore {
pub async fn handle_get_staged_text( pub async fn handle_get_staged_text(
this: Entity<Self>, this: Entity<Self>,
request: TypedEnvelope<proto::GetStagedText>, request: TypedEnvelope<proto::GetStagedText>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::GetStagedTextResponse> { ) -> Result<proto::GetStagedTextResponse> {
let buffer_id = BufferId::new(request.payload.buffer_id)?; let buffer_id = BufferId::new(request.payload.buffer_id)?;
let change_set = this let change_set = this
@ -1966,7 +1965,7 @@ impl BufferStore {
pub async fn handle_update_diff_base( pub async fn handle_update_diff_base(
this: Entity<Self>, this: Entity<Self>,
request: TypedEnvelope<proto::UpdateDiffBase>, request: TypedEnvelope<proto::UpdateDiffBase>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let buffer_id = BufferId::new(request.payload.buffer_id)?; let buffer_id = BufferId::new(request.payload.buffer_id)?;
let Some((buffer, change_set)) = this.update(&mut cx, |this, _| { let Some((buffer, change_set)) = this.update(&mut cx, |this, _| {
@ -2011,7 +2010,7 @@ impl BufferStore {
async fn handle_reload_buffers( async fn handle_reload_buffers(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ReloadBuffers>, envelope: TypedEnvelope<proto::ReloadBuffers>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ReloadBuffersResponse> { ) -> Result<proto::ReloadBuffersResponse> {
let sender_id = envelope.original_sender_id().unwrap_or_default(); let sender_id = envelope.original_sender_id().unwrap_or_default();
let reload = this.update(&mut cx, |this, cx| { let reload = this.update(&mut cx, |this, cx| {

View file

@ -3,7 +3,7 @@ use anyhow::Result;
use client::Client; use client::Client;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
use gpui::{App, AppContext as _, AsyncAppContext, Context, Entity, Global, Task, WeakEntity}; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, Global, Task, WeakEntity};
use postage::stream::Stream; use postage::stream::Stream;
use rpc::proto; use rpc::proto;
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
@ -133,7 +133,7 @@ impl Manager {
async fn maintain_connection( async fn maintain_connection(
this: WeakEntity<Self>, this: WeakEntity<Self>,
client: Arc<Client>, client: Arc<Client>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let mut client_status = client.status(); let mut client_status = client.status();
loop { loop {

View file

@ -394,7 +394,7 @@ impl ImageStoreImpl for Entity<LocalImageStore> {
reload_task: None, reload_task: None,
})?; })?;
let image_id = cx.read_model(&model, |model, _| model.id)?; let image_id = cx.read_entity(&model, |model, _| model.id)?;
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
image_store.update(cx, |image_store, cx| { image_store.update(cx, |image_store, cx| {

View file

@ -12,7 +12,7 @@ use client::proto::{self, PeerId};
use clock::Global; use clock::Global;
use collections::HashSet; use collections::HashSet;
use futures::future; use futures::future;
use gpui::{App, AsyncAppContext, Entity}; use gpui::{App, AsyncApp, Entity};
use language::{ use language::{
language_settings::{language_settings, InlayHintKind, LanguageSettings}, language_settings::{language_settings, InlayHintKind, LanguageSettings},
point_from_lsp, point_to_lsp, point_from_lsp, point_to_lsp,
@ -122,7 +122,7 @@ pub trait LspCommand: 'static + Sized + Send + std::fmt::Debug {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Self::Response>; ) -> Result<Self::Response>;
fn to_proto(&self, project_id: u64, buffer: &Buffer) -> Self::ProtoRequest; fn to_proto(&self, project_id: u64, buffer: &Buffer) -> Self::ProtoRequest;
@ -131,7 +131,7 @@ pub trait LspCommand: 'static + Sized + Send + std::fmt::Debug {
message: Self::ProtoRequest, message: Self::ProtoRequest,
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Self>; ) -> Result<Self>;
fn response_to_proto( fn response_to_proto(
@ -147,7 +147,7 @@ pub trait LspCommand: 'static + Sized + Send + std::fmt::Debug {
message: <Self::ProtoRequest as proto::RequestMessage>::Response, message: <Self::ProtoRequest as proto::RequestMessage>::Response,
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Self::Response>; ) -> Result<Self::Response>;
fn buffer_id_from_proto(message: &Self::ProtoRequest) -> Result<BufferId>; fn buffer_id_from_proto(message: &Self::ProtoRequest) -> Result<BufferId>;
@ -297,7 +297,7 @@ impl LspCommand for PrepareRename {
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
_: LanguageServerId, _: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<PrepareRenameResponse> { ) -> Result<PrepareRenameResponse> {
buffer.update(&mut cx, |buffer, _| { buffer.update(&mut cx, |buffer, _| {
match message { match message {
@ -339,7 +339,7 @@ impl LspCommand for PrepareRename {
message: proto::PrepareRename, message: proto::PrepareRename,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -393,7 +393,7 @@ impl LspCommand for PrepareRename {
message: proto::PrepareRenameResponse, message: proto::PrepareRenameResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<PrepareRenameResponse> { ) -> Result<PrepareRenameResponse> {
if message.can_rename { if message.can_rename {
buffer buffer
@ -453,7 +453,7 @@ impl LspCommand for PerformRename {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<ProjectTransaction> { ) -> Result<ProjectTransaction> {
if let Some(edit) = message { if let Some(edit) = message {
let (lsp_adapter, lsp_server) = let (lsp_adapter, lsp_server) =
@ -488,7 +488,7 @@ impl LspCommand for PerformRename {
message: proto::PerformRename, message: proto::PerformRename,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -526,7 +526,7 @@ impl LspCommand for PerformRename {
message: proto::PerformRenameResponse, message: proto::PerformRenameResponse,
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<ProjectTransaction> { ) -> Result<ProjectTransaction> {
let message = message let message = message
.transaction .transaction
@ -582,7 +582,7 @@ impl LspCommand for GetDefinition {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_lsp(message, lsp_store, buffer, server_id, cx).await location_links_from_lsp(message, lsp_store, buffer, server_id, cx).await
} }
@ -602,7 +602,7 @@ impl LspCommand for GetDefinition {
message: proto::GetDefinition, message: proto::GetDefinition,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -634,7 +634,7 @@ impl LspCommand for GetDefinition {
message: proto::GetDefinitionResponse, message: proto::GetDefinitionResponse,
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, lsp_store, cx).await location_links_from_proto(message.links, lsp_store, cx).await
} }
@ -681,7 +681,7 @@ impl LspCommand for GetDeclaration {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_lsp(message, lsp_store, buffer, server_id, cx).await location_links_from_lsp(message, lsp_store, buffer, server_id, cx).await
} }
@ -701,7 +701,7 @@ impl LspCommand for GetDeclaration {
message: proto::GetDeclaration, message: proto::GetDeclaration,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -733,7 +733,7 @@ impl LspCommand for GetDeclaration {
message: proto::GetDeclarationResponse, message: proto::GetDeclarationResponse,
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, lsp_store, cx).await location_links_from_proto(message.links, lsp_store, cx).await
} }
@ -773,7 +773,7 @@ impl LspCommand for GetImplementation {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_lsp(message, lsp_store, buffer, server_id, cx).await location_links_from_lsp(message, lsp_store, buffer, server_id, cx).await
} }
@ -793,7 +793,7 @@ impl LspCommand for GetImplementation {
message: proto::GetImplementation, message: proto::GetImplementation,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -825,7 +825,7 @@ impl LspCommand for GetImplementation {
message: proto::GetImplementationResponse, message: proto::GetImplementationResponse,
project: Entity<LspStore>, project: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, project, cx).await location_links_from_proto(message.links, project, cx).await
} }
@ -872,7 +872,7 @@ impl LspCommand for GetTypeDefinition {
project: Entity<LspStore>, project: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_lsp(message, project, buffer, server_id, cx).await location_links_from_lsp(message, project, buffer, server_id, cx).await
} }
@ -892,7 +892,7 @@ impl LspCommand for GetTypeDefinition {
message: proto::GetTypeDefinition, message: proto::GetTypeDefinition,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -924,7 +924,7 @@ impl LspCommand for GetTypeDefinition {
message: proto::GetTypeDefinitionResponse, message: proto::GetTypeDefinitionResponse,
project: Entity<LspStore>, project: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, project, cx).await location_links_from_proto(message.links, project, cx).await
} }
@ -938,7 +938,7 @@ fn language_server_for_buffer(
lsp_store: &Entity<LspStore>, lsp_store: &Entity<LspStore>,
buffer: &Entity<Buffer>, buffer: &Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<(Arc<CachedLspAdapter>, Arc<LanguageServer>)> { ) -> Result<(Arc<CachedLspAdapter>, Arc<LanguageServer>)> {
lsp_store lsp_store
.update(cx, |lsp_store, cx| { .update(cx, |lsp_store, cx| {
@ -952,7 +952,7 @@ fn language_server_for_buffer(
async fn location_links_from_proto( async fn location_links_from_proto(
proto_links: Vec<proto::LocationLink>, proto_links: Vec<proto::LocationLink>,
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
let mut links = Vec::new(); let mut links = Vec::new();
@ -1018,7 +1018,7 @@ async fn location_links_from_lsp(
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<LocationLink>> { ) -> Result<Vec<LocationLink>> {
let message = match message { let message = match message {
Some(message) => message, Some(message) => message,
@ -1187,7 +1187,7 @@ impl LspCommand for GetReferences {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<Location>> { ) -> Result<Vec<Location>> {
let mut references = Vec::new(); let mut references = Vec::new();
let (lsp_adapter, language_server) = let (lsp_adapter, language_server) =
@ -1240,7 +1240,7 @@ impl LspCommand for GetReferences {
message: proto::GetReferences, message: proto::GetReferences,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -1288,7 +1288,7 @@ impl LspCommand for GetReferences {
message: proto::GetReferencesResponse, message: proto::GetReferencesResponse,
project: Entity<LspStore>, project: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<Location>> { ) -> Result<Vec<Location>> {
let mut locations = Vec::new(); let mut locations = Vec::new();
for location in message.locations { for location in message.locations {
@ -1359,7 +1359,7 @@ impl LspCommand for GetDocumentHighlights {
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
_: LanguageServerId, _: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<DocumentHighlight>> { ) -> Result<Vec<DocumentHighlight>> {
buffer.update(&mut cx, |buffer, _| { buffer.update(&mut cx, |buffer, _| {
let mut lsp_highlights = lsp_highlights.unwrap_or_default(); let mut lsp_highlights = lsp_highlights.unwrap_or_default();
@ -1397,7 +1397,7 @@ impl LspCommand for GetDocumentHighlights {
message: proto::GetDocumentHighlights, message: proto::GetDocumentHighlights,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -1441,7 +1441,7 @@ impl LspCommand for GetDocumentHighlights {
message: proto::GetDocumentHighlightsResponse, message: proto::GetDocumentHighlightsResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<DocumentHighlight>> { ) -> Result<Vec<DocumentHighlight>> {
let mut highlights = Vec::new(); let mut highlights = Vec::new();
for highlight in message.highlights { for highlight in message.highlights {
@ -1512,7 +1512,7 @@ impl LspCommand for GetSignatureHelp {
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
_: LanguageServerId, _: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self::Response> { ) -> Result<Self::Response> {
let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?; let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?;
Ok(message.and_then(|message| SignatureHelp::new(message, language))) Ok(message.and_then(|message| SignatureHelp::new(message, language)))
@ -1532,7 +1532,7 @@ impl LspCommand for GetSignatureHelp {
payload: Self::ProtoRequest, payload: Self::ProtoRequest,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
buffer buffer
.update(&mut cx, |buffer, _| { .update(&mut cx, |buffer, _| {
@ -1568,7 +1568,7 @@ impl LspCommand for GetSignatureHelp {
response: proto::GetSignatureHelpResponse, response: proto::GetSignatureHelpResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self::Response> { ) -> Result<Self::Response> {
let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?; let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?;
Ok(response Ok(response
@ -1619,7 +1619,7 @@ impl LspCommand for GetHover {
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
_: LanguageServerId, _: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self::Response> { ) -> Result<Self::Response> {
let Some(hover) = message else { let Some(hover) = message else {
return Ok(None); return Ok(None);
@ -1699,7 +1699,7 @@ impl LspCommand for GetHover {
message: Self::ProtoRequest, message: Self::ProtoRequest,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -1765,7 +1765,7 @@ impl LspCommand for GetHover {
message: proto::GetHoverResponse, message: proto::GetHoverResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self::Response> { ) -> Result<Self::Response> {
let contents: Vec<_> = message let contents: Vec<_> = message
.contents .contents
@ -1843,7 +1843,7 @@ impl LspCommand for GetCompletions {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self::Response> { ) -> Result<Self::Response> {
let mut response_list = None; let mut response_list = None;
let mut completions = if let Some(completions) = completions { let mut completions = if let Some(completions) = completions {
@ -2035,7 +2035,7 @@ impl LspCommand for GetCompletions {
message: proto::GetCompletions, message: proto::GetCompletions,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let version = deserialize_version(&message.version); let version = deserialize_version(&message.version);
buffer buffer
@ -2080,7 +2080,7 @@ impl LspCommand for GetCompletions {
message: proto::GetCompletionsResponse, message: proto::GetCompletionsResponse,
_project: Entity<LspStore>, _project: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self::Response> { ) -> Result<Self::Response> {
buffer buffer
.update(&mut cx, |buffer, _| { .update(&mut cx, |buffer, _| {
@ -2224,7 +2224,7 @@ impl LspCommand for GetCodeActions {
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
_: AsyncAppContext, _: AsyncApp,
) -> Result<Vec<CodeAction>> { ) -> Result<Vec<CodeAction>> {
let requested_kinds_set = if let Some(kinds) = self.kinds { let requested_kinds_set = if let Some(kinds) = self.kinds {
Some(kinds.into_iter().collect::<HashSet<_>>()) Some(kinds.into_iter().collect::<HashSet<_>>())
@ -2271,7 +2271,7 @@ impl LspCommand for GetCodeActions {
message: proto::GetCodeActions, message: proto::GetCodeActions,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let start = message let start = message
.start .start
@ -2314,7 +2314,7 @@ impl LspCommand for GetCodeActions {
message: proto::GetCodeActionsResponse, message: proto::GetCodeActionsResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<CodeAction>> { ) -> Result<Vec<CodeAction>> {
buffer buffer
.update(&mut cx, |buffer, _| { .update(&mut cx, |buffer, _| {
@ -2405,7 +2405,7 @@ impl LspCommand for OnTypeFormatting {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Option<Transaction>> { ) -> Result<Option<Transaction>> {
if let Some(edits) = message { if let Some(edits) = message {
let (lsp_adapter, lsp_server) = let (lsp_adapter, lsp_server) =
@ -2441,7 +2441,7 @@ impl LspCommand for OnTypeFormatting {
message: proto::OnTypeFormatting, message: proto::OnTypeFormatting,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -2485,7 +2485,7 @@ impl LspCommand for OnTypeFormatting {
message: proto::OnTypeFormattingResponse, message: proto::OnTypeFormattingResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: AsyncAppContext, _: AsyncApp,
) -> Result<Option<Transaction>> { ) -> Result<Option<Transaction>> {
let Some(transaction) = message.transaction else { let Some(transaction) = message.transaction else {
return Ok(None); return Ok(None);
@ -2505,7 +2505,7 @@ impl InlayHints {
server_id: LanguageServerId, server_id: LanguageServerId,
resolve_state: ResolveState, resolve_state: ResolveState,
force_no_type_left_padding: bool, force_no_type_left_padding: bool,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> anyhow::Result<InlayHint> { ) -> anyhow::Result<InlayHint> {
let kind = lsp_hint.kind.and_then(|kind| match kind { let kind = lsp_hint.kind.and_then(|kind| match kind {
lsp::InlayHintKind::TYPE => Some(InlayHintKind::Type), lsp::InlayHintKind::TYPE => Some(InlayHintKind::Type),
@ -2914,7 +2914,7 @@ impl LspCommand for InlayHints {
lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
server_id: LanguageServerId, server_id: LanguageServerId,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> anyhow::Result<Vec<InlayHint>> { ) -> anyhow::Result<Vec<InlayHint>> {
let (lsp_adapter, lsp_server) = let (lsp_adapter, lsp_server) =
language_server_for_buffer(&lsp_store, &buffer, server_id, &mut cx)?; language_server_for_buffer(&lsp_store, &buffer, server_id, &mut cx)?;
@ -2969,7 +2969,7 @@ impl LspCommand for InlayHints {
message: proto::InlayHints, message: proto::InlayHints,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let start = message let start = message
.start .start
@ -3009,7 +3009,7 @@ impl LspCommand for InlayHints {
message: proto::InlayHintsResponse, message: proto::InlayHintsResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> anyhow::Result<Vec<InlayHint>> { ) -> anyhow::Result<Vec<InlayHint>> {
buffer buffer
.update(&mut cx, |buffer, _| { .update(&mut cx, |buffer, _| {
@ -3073,7 +3073,7 @@ impl LspCommand for LinkedEditingRange {
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
_server_id: LanguageServerId, _server_id: LanguageServerId,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Vec<Range<Anchor>>> { ) -> Result<Vec<Range<Anchor>>> {
if let Some(lsp::LinkedEditingRanges { mut ranges, .. }) = message { if let Some(lsp::LinkedEditingRanges { mut ranges, .. }) = message {
ranges.sort_by_key(|range| range.start); ranges.sort_by_key(|range| range.start);
@ -3107,7 +3107,7 @@ impl LspCommand for LinkedEditingRange {
message: proto::LinkedEditingRange, message: proto::LinkedEditingRange,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let position = message let position = message
.position .position
@ -3148,7 +3148,7 @@ impl LspCommand for LinkedEditingRange {
message: proto::LinkedEditingRangeResponse, message: proto::LinkedEditingRangeResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Vec<Range<Anchor>>> { ) -> Result<Vec<Range<Anchor>>> {
buffer buffer
.update(&mut cx, |buffer, _| { .update(&mut cx, |buffer, _| {

View file

@ -1,7 +1,7 @@
use crate::{lsp_command::LspCommand, lsp_store::LspStore, make_text_document_identifier}; use crate::{lsp_command::LspCommand, lsp_store::LspStore, make_text_document_identifier};
use anyhow::{Context as _, Result}; use anyhow::{Context as _, Result};
use async_trait::async_trait; use async_trait::async_trait;
use gpui::{App, AsyncAppContext, Entity}; use gpui::{App, AsyncApp, Entity};
use language::{point_to_lsp, proto::deserialize_anchor, Buffer}; use language::{point_to_lsp, proto::deserialize_anchor, Buffer};
use lsp::{LanguageServer, LanguageServerId}; use lsp::{LanguageServer, LanguageServerId};
use rpc::proto::{self, PeerId}; use rpc::proto::{self, PeerId};
@ -70,7 +70,7 @@ impl LspCommand for ExpandMacro {
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: LanguageServerId, _: LanguageServerId,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<ExpandedMacro> { ) -> anyhow::Result<ExpandedMacro> {
Ok(message Ok(message
.map(|message| ExpandedMacro { .map(|message| ExpandedMacro {
@ -94,7 +94,7 @@ impl LspCommand for ExpandMacro {
message: Self::ProtoRequest, message: Self::ProtoRequest,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
let position = message let position = message
.position .position
@ -123,7 +123,7 @@ impl LspCommand for ExpandMacro {
message: proto::LspExtExpandMacroResponse, message: proto::LspExtExpandMacroResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<ExpandedMacro> { ) -> anyhow::Result<ExpandedMacro> {
Ok(ExpandedMacro { Ok(ExpandedMacro {
name: message.name, name: message.name,
@ -200,7 +200,7 @@ impl LspCommand for OpenDocs {
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: LanguageServerId, _: LanguageServerId,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<DocsUrls> { ) -> anyhow::Result<DocsUrls> {
Ok(message Ok(message
.map(|message| DocsUrls { .map(|message| DocsUrls {
@ -224,7 +224,7 @@ impl LspCommand for OpenDocs {
message: Self::ProtoRequest, message: Self::ProtoRequest,
_: Entity<LspStore>, _: Entity<LspStore>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
let position = message let position = message
.position .position
@ -253,7 +253,7 @@ impl LspCommand for OpenDocs {
message: proto::LspExtOpenDocsResponse, message: proto::LspExtOpenDocsResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<DocsUrls> { ) -> anyhow::Result<DocsUrls> {
Ok(DocsUrls { Ok(DocsUrls {
web: message.web, web: message.web,
@ -314,7 +314,7 @@ impl LspCommand for SwitchSourceHeader {
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: LanguageServerId, _: LanguageServerId,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<SwitchSourceHeaderResult> { ) -> anyhow::Result<SwitchSourceHeaderResult> {
Ok(message Ok(message
.map(|message| SwitchSourceHeaderResult(message.0)) .map(|message| SwitchSourceHeaderResult(message.0))
@ -332,7 +332,7 @@ impl LspCommand for SwitchSourceHeader {
_: Self::ProtoRequest, _: Self::ProtoRequest,
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
Ok(Self {}) Ok(Self {})
} }
@ -354,7 +354,7 @@ impl LspCommand for SwitchSourceHeader {
message: proto::LspExtSwitchSourceHeaderResponse, message: proto::LspExtSwitchSourceHeaderResponse,
_: Entity<LspStore>, _: Entity<LspStore>,
_: Entity<Buffer>, _: Entity<Buffer>,
_: AsyncAppContext, _: AsyncApp,
) -> anyhow::Result<SwitchSourceHeaderResult> { ) -> anyhow::Result<SwitchSourceHeaderResult> {
Ok(SwitchSourceHeaderResult(message.target_file)) Ok(SwitchSourceHeaderResult(message.target_file))
} }

View file

@ -25,8 +25,7 @@ use futures::{
}; };
use globset::{Glob, GlobBuilder, GlobMatcher, GlobSet, GlobSetBuilder}; use globset::{Glob, GlobBuilder, GlobMatcher, GlobSet, GlobSetBuilder};
use gpui::{ use gpui::{
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, PromptLevel, Task, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, PromptLevel, Task, WeakEntity,
WeakEntity,
}; };
use http_client::HttpClient; use http_client::HttpClient;
use itertools::Itertools as _; use itertools::Itertools as _;
@ -1089,7 +1088,7 @@ impl LocalLspStore {
target: &LspFormatTarget, target: &LspFormatTarget,
push_to_history: bool, push_to_history: bool,
trigger: FormatTrigger, trigger: FormatTrigger,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> anyhow::Result<ProjectTransaction> { ) -> anyhow::Result<ProjectTransaction> {
// Do not allow multiple concurrent formatting requests for the // Do not allow multiple concurrent formatting requests for the
// same buffer. // same buffer.
@ -1437,7 +1436,7 @@ impl LocalLspStore {
adapters_and_servers: &[(Arc<CachedLspAdapter>, Arc<LanguageServer>)], adapters_and_servers: &[(Arc<CachedLspAdapter>, Arc<LanguageServer>)],
push_to_history: bool, push_to_history: bool,
transaction: &mut ProjectTransaction, transaction: &mut ProjectTransaction,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Option<FormatOperation>, anyhow::Error> { ) -> Result<Option<FormatOperation>, anyhow::Error> {
let result = match formatter { let result = match formatter {
Formatter::LanguageServer { name } => { Formatter::LanguageServer { name } => {
@ -1527,7 +1526,7 @@ impl LocalLspStore {
abs_path: &Path, abs_path: &Path,
language_server: &Arc<LanguageServer>, language_server: &Arc<LanguageServer>,
settings: &LanguageSettings, settings: &LanguageSettings,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Vec<(Range<Anchor>, String)>> { ) -> Result<Vec<(Range<Anchor>, String)>> {
let capabilities = &language_server.capabilities(); let capabilities = &language_server.capabilities();
let range_formatting_provider = capabilities.document_range_formatting_provider.as_ref(); let range_formatting_provider = capabilities.document_range_formatting_provider.as_ref();
@ -1598,7 +1597,7 @@ impl LocalLspStore {
abs_path: &Path, abs_path: &Path,
language_server: &Arc<LanguageServer>, language_server: &Arc<LanguageServer>,
settings: &LanguageSettings, settings: &LanguageSettings,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Vec<(Range<Anchor>, String)>> { ) -> Result<Vec<(Range<Anchor>, String)>> {
let uri = lsp::Url::from_file_path(abs_path) let uri = lsp::Url::from_file_path(abs_path)
.map_err(|_| anyhow!("failed to convert abs path to uri"))?; .map_err(|_| anyhow!("failed to convert abs path to uri"))?;
@ -1651,7 +1650,7 @@ impl LocalLspStore {
buffer: &FormattableBuffer, buffer: &FormattableBuffer,
command: &str, command: &str,
arguments: Option<&[String]>, arguments: Option<&[String]>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Option<Diff>> { ) -> Result<Option<Diff>> {
let working_dir_path = buffer.handle.update(cx, |buffer, cx| { let working_dir_path = buffer.handle.update(cx, |buffer, cx| {
let file = File::from_dyn(buffer.file())?; let file = File::from_dyn(buffer.file())?;
@ -2029,7 +2028,7 @@ impl LocalLspStore {
buffer: &Entity<Buffer>, buffer: &Entity<Buffer>,
push_to_history: bool, push_to_history: bool,
project_transaction: &mut ProjectTransaction, project_transaction: &mut ProjectTransaction,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<(), anyhow::Error> { ) -> Result<(), anyhow::Error> {
for (lsp_adapter, language_server) in adapters_and_servers.iter() { for (lsp_adapter, language_server) in adapters_and_servers.iter() {
let code_actions = code_actions.clone(); let code_actions = code_actions.clone();
@ -2107,7 +2106,7 @@ impl LocalLspStore {
push_to_history: bool, push_to_history: bool,
_: Arc<CachedLspAdapter>, _: Arc<CachedLspAdapter>,
language_server: Arc<LanguageServer>, language_server: Arc<LanguageServer>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Option<Transaction>> { ) -> Result<Option<Transaction>> {
let edits = this let edits = this
.update(cx, |this, cx| { .update(cx, |this, cx| {
@ -2253,7 +2252,7 @@ impl LocalLspStore {
push_to_history: bool, push_to_history: bool,
lsp_adapter: Arc<CachedLspAdapter>, lsp_adapter: Arc<CachedLspAdapter>,
language_server: Arc<LanguageServer>, language_server: Arc<LanguageServer>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<ProjectTransaction> { ) -> Result<ProjectTransaction> {
let fs = this.read_with(cx, |this, _| this.as_local().unwrap().fs.clone())?; let fs = this.read_with(cx, |this, _| this.as_local().unwrap().fs.clone())?;
@ -2478,7 +2477,7 @@ impl LocalLspStore {
params: lsp::ApplyWorkspaceEditParams, params: lsp::ApplyWorkspaceEditParams,
server_id: LanguageServerId, server_id: LanguageServerId,
adapter: Arc<CachedLspAdapter>, adapter: Arc<CachedLspAdapter>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<lsp::ApplyWorkspaceEditResponse> { ) -> Result<lsp::ApplyWorkspaceEditResponse> {
let this = this let this = this
.upgrade() .upgrade()
@ -5134,7 +5133,7 @@ impl LspStore {
pub(crate) async fn refresh_workspace_configurations( pub(crate) async fn refresh_workspace_configurations(
this: &WeakEntity<Self>, this: &WeakEntity<Self>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) { ) {
maybe!(async move { maybe!(async move {
let servers = this let servers = this
@ -5679,7 +5678,7 @@ impl LspStore {
async fn handle_lsp_command<T: LspCommand>( async fn handle_lsp_command<T: LspCommand>(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<T::ProtoRequest>, envelope: TypedEnvelope<T::ProtoRequest>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<<T::ProtoRequest as proto::RequestMessage>::Response> ) -> Result<<T::ProtoRequest as proto::RequestMessage>::Response>
where where
<T::LspRequest as lsp::request::Request>::Params: Send, <T::LspRequest as lsp::request::Request>::Params: Send,
@ -5721,7 +5720,7 @@ impl LspStore {
async fn handle_multi_lsp_query( async fn handle_multi_lsp_query(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::MultiLspQuery>, envelope: TypedEnvelope<proto::MultiLspQuery>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::MultiLspQueryResponse> { ) -> Result<proto::MultiLspQueryResponse> {
let response_from_ssh = this.update(&mut cx, |this, _| { let response_from_ssh = this.update(&mut cx, |this, _| {
let (upstream_client, project_id) = this.upstream_client()?; let (upstream_client, project_id) = this.upstream_client()?;
@ -5872,7 +5871,7 @@ impl LspStore {
async fn handle_apply_code_action( async fn handle_apply_code_action(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ApplyCodeAction>, envelope: TypedEnvelope<proto::ApplyCodeAction>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ApplyCodeActionResponse> { ) -> Result<proto::ApplyCodeActionResponse> {
let sender_id = envelope.original_sender_id().unwrap_or_default(); let sender_id = envelope.original_sender_id().unwrap_or_default();
let action = Self::deserialize_code_action( let action = Self::deserialize_code_action(
@ -5905,7 +5904,7 @@ impl LspStore {
async fn handle_register_buffer_with_language_servers( async fn handle_register_buffer_with_language_servers(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::RegisterBufferWithLanguageServers>, envelope: TypedEnvelope<proto::RegisterBufferWithLanguageServers>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
let peer_id = envelope.original_sender_id.unwrap_or(envelope.sender_id); let peer_id = envelope.original_sender_id.unwrap_or(envelope.sender_id);
@ -5934,7 +5933,7 @@ impl LspStore {
async fn handle_rename_project_entry( async fn handle_rename_project_entry(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::RenameProjectEntry>, envelope: TypedEnvelope<proto::RenameProjectEntry>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ProjectEntryResponse> { ) -> Result<proto::ProjectEntryResponse> {
let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id); let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id);
let (worktree_id, worktree, old_path, is_dir) = this let (worktree_id, worktree, old_path, is_dir) = this
@ -5980,7 +5979,7 @@ impl LspStore {
async fn handle_update_diagnostic_summary( async fn handle_update_diagnostic_summary(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateDiagnosticSummary>, envelope: TypedEnvelope<proto::UpdateDiagnosticSummary>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id); let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
@ -6041,7 +6040,7 @@ impl LspStore {
async fn handle_start_language_server( async fn handle_start_language_server(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::StartLanguageServer>, envelope: TypedEnvelope<proto::StartLanguageServer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let server = envelope let server = envelope
.payload .payload
@ -6072,7 +6071,7 @@ impl LspStore {
async fn handle_update_language_server( async fn handle_update_language_server(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateLanguageServer>, envelope: TypedEnvelope<proto::UpdateLanguageServer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let language_server_id = LanguageServerId(envelope.payload.language_server_id as usize); let language_server_id = LanguageServerId(envelope.payload.language_server_id as usize);
@ -6134,7 +6133,7 @@ impl LspStore {
async fn handle_language_server_log( async fn handle_language_server_log(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::LanguageServerLog>, envelope: TypedEnvelope<proto::LanguageServerLog>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let language_server_id = LanguageServerId(envelope.payload.language_server_id as usize); let language_server_id = LanguageServerId(envelope.payload.language_server_id as usize);
let log_type = envelope let log_type = envelope
@ -6298,7 +6297,7 @@ impl LspStore {
old_path: &Path, old_path: &Path,
new_path: &Path, new_path: &Path,
is_dir: bool, is_dir: bool,
cx: AsyncAppContext, cx: AsyncApp,
) -> Task<()> { ) -> Task<()> {
let old_uri = lsp::Url::from_file_path(old_path).ok().map(String::from); let old_uri = lsp::Url::from_file_path(old_path).ok().map(String::from);
let new_uri = lsp::Url::from_file_path(new_path).ok().map(String::from); let new_uri = lsp::Url::from_file_path(new_path).ok().map(String::from);
@ -6587,7 +6586,7 @@ impl LspStore {
pub async fn handle_resolve_completion_documentation( pub async fn handle_resolve_completion_documentation(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ResolveCompletionDocumentation>, envelope: TypedEnvelope<proto::ResolveCompletionDocumentation>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ResolveCompletionDocumentationResponse> { ) -> Result<proto::ResolveCompletionDocumentationResponse> {
let lsp_completion = serde_json::from_slice(&envelope.payload.lsp_completion)?; let lsp_completion = serde_json::from_slice(&envelope.payload.lsp_completion)?;
@ -6666,7 +6665,7 @@ impl LspStore {
async fn handle_on_type_formatting( async fn handle_on_type_formatting(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::OnTypeFormatting>, envelope: TypedEnvelope<proto::OnTypeFormatting>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OnTypeFormattingResponse> { ) -> Result<proto::OnTypeFormattingResponse> {
let on_type_formatting = this.update(&mut cx, |this, cx| { let on_type_formatting = this.update(&mut cx, |this, cx| {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
@ -6694,7 +6693,7 @@ impl LspStore {
async fn handle_refresh_inlay_hints( async fn handle_refresh_inlay_hints(
this: Entity<Self>, this: Entity<Self>,
_: TypedEnvelope<proto::RefreshInlayHints>, _: TypedEnvelope<proto::RefreshInlayHints>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
this.update(&mut cx, |_, cx| { this.update(&mut cx, |_, cx| {
cx.emit(LspStoreEvent::RefreshInlayHints); cx.emit(LspStoreEvent::RefreshInlayHints);
@ -6705,7 +6704,7 @@ impl LspStore {
async fn handle_inlay_hints( async fn handle_inlay_hints(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::InlayHints>, envelope: TypedEnvelope<proto::InlayHints>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::InlayHintsResponse> { ) -> Result<proto::InlayHintsResponse> {
let sender_id = envelope.original_sender_id().unwrap_or_default(); let sender_id = envelope.original_sender_id().unwrap_or_default();
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
@ -6750,7 +6749,7 @@ impl LspStore {
async fn handle_resolve_inlay_hint( async fn handle_resolve_inlay_hint(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ResolveInlayHint>, envelope: TypedEnvelope<proto::ResolveInlayHint>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ResolveInlayHintResponse> { ) -> Result<proto::ResolveInlayHintResponse> {
let proto_hint = envelope let proto_hint = envelope
.payload .payload
@ -6781,7 +6780,7 @@ impl LspStore {
async fn handle_open_buffer_for_symbol( async fn handle_open_buffer_for_symbol(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::OpenBufferForSymbol>, envelope: TypedEnvelope<proto::OpenBufferForSymbol>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenBufferForSymbolResponse> { ) -> Result<proto::OpenBufferForSymbolResponse> {
let peer_id = envelope.original_sender_id().unwrap_or_default(); let peer_id = envelope.original_sender_id().unwrap_or_default();
let symbol = envelope let symbol = envelope
@ -6850,7 +6849,7 @@ impl LspStore {
pub async fn handle_get_project_symbols( pub async fn handle_get_project_symbols(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::GetProjectSymbols>, envelope: TypedEnvelope<proto::GetProjectSymbols>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::GetProjectSymbolsResponse> { ) -> Result<proto::GetProjectSymbolsResponse> {
let symbols = this let symbols = this
.update(&mut cx, |this, cx| { .update(&mut cx, |this, cx| {
@ -6866,7 +6865,7 @@ impl LspStore {
pub async fn handle_restart_language_servers( pub async fn handle_restart_language_servers(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::RestartLanguageServers>, envelope: TypedEnvelope<proto::RestartLanguageServers>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let buffers = this.buffer_ids_to_buffers(envelope.payload.buffer_ids.into_iter(), cx); let buffers = this.buffer_ids_to_buffers(envelope.payload.buffer_ids.into_iter(), cx);
@ -6879,7 +6878,7 @@ impl LspStore {
pub async fn handle_cancel_language_server_work( pub async fn handle_cancel_language_server_work(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::CancelLanguageServerWork>, envelope: TypedEnvelope<proto::CancelLanguageServerWork>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
if let Some(work) = envelope.payload.work { if let Some(work) = envelope.payload.work {
@ -6918,7 +6917,7 @@ impl LspStore {
async fn handle_apply_additional_edits_for_completion( async fn handle_apply_additional_edits_for_completion(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ApplyCompletionAdditionalEdits>, envelope: TypedEnvelope<proto::ApplyCompletionAdditionalEdits>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ApplyCompletionAdditionalEditsResponse> { ) -> Result<proto::ApplyCompletionAdditionalEditsResponse> {
let (buffer, completion) = this.update(&mut cx, |this, cx| { let (buffer, completion) = this.update(&mut cx, |this, cx| {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?; let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
@ -7094,7 +7093,7 @@ impl LspStore {
async fn handle_format_buffers( async fn handle_format_buffers(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::FormatBuffers>, envelope: TypedEnvelope<proto::FormatBuffers>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::FormatBuffersResponse> { ) -> Result<proto::FormatBuffersResponse> {
let sender_id = envelope.original_sender_id().unwrap_or_default(); let sender_id = envelope.original_sender_id().unwrap_or_default();
let format = this.update(&mut cx, |this, cx| { let format = this.update(&mut cx, |this, cx| {
@ -7125,7 +7124,7 @@ impl LspStore {
async fn shutdown_language_server( async fn shutdown_language_server(
server_state: Option<LanguageServerState>, server_state: Option<LanguageServerState>,
name: LanguageServerName, name: LanguageServerName,
cx: AsyncAppContext, cx: AsyncApp,
) { ) {
let server = match server_state { let server = match server_state {
Some(LanguageServerState::Starting(task)) => { Some(LanguageServerState::Starting(task)) => {
@ -8435,7 +8434,7 @@ impl LspAdapter for SshLspAdapter {
&self, &self,
_: &dyn LspAdapterDelegate, _: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>, _: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext, _: &AsyncApp,
) -> Option<LanguageServerBinary> { ) -> Option<LanguageServerBinary> {
Some(self.binary.clone()) Some(self.binary.clone())
} }

View file

@ -12,7 +12,7 @@ use futures::{
stream::FuturesUnordered, stream::FuturesUnordered,
FutureExt, FutureExt,
}; };
use gpui::{AsyncAppContext, Context, Entity, EventEmitter, Task, WeakEntity}; use gpui::{AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
use language::{ use language::{
language_settings::{Formatter, LanguageSettings, SelectedFormatter}, language_settings::{Formatter, LanguageSettings, SelectedFormatter},
Buffer, LanguageRegistry, LocalFile, Buffer, LanguageRegistry, LocalFile,
@ -387,7 +387,7 @@ impl PrettierStore {
prettier: &Prettier, prettier: &Prettier,
worktree_id: Option<WorktreeId>, worktree_id: Option<WorktreeId>,
new_server_id: LanguageServerId, new_server_id: LanguageServerId,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) { ) {
let prettier_dir = prettier.prettier_dir(); let prettier_dir = prettier.prettier_dir();
let is_default = prettier.is_default(); let is_default = prettier.is_default();
@ -707,7 +707,7 @@ pub fn prettier_plugins_for_language(
pub(super) async fn format_with_prettier( pub(super) async fn format_with_prettier(
prettier_store: &WeakEntity<PrettierStore>, prettier_store: &WeakEntity<PrettierStore>,
buffer: &Entity<Buffer>, buffer: &Entity<Buffer>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Option<Result<crate::lsp_store::FormatOperation>> { ) -> Option<Result<crate::lsp_store::FormatOperation>> {
let prettier_instance = prettier_store let prettier_instance = prettier_store
.update(cx, |prettier_store, cx| { .update(cx, |prettier_store, cx| {

View file

@ -48,8 +48,8 @@ use ::git::{
status::FileStatus, status::FileStatus,
}; };
use gpui::{ use gpui::{
AnyEntity, App, AppContext as _, AsyncAppContext, BorrowAppContext, Context, Entity, AnyEntity, App, AppContext as _, AsyncApp, BorrowAppContext, Context, Entity, EventEmitter,
EventEmitter, Hsla, SharedString, Task, WeakEntity, Window, Hsla, SharedString, Task, WeakEntity, Window,
}; };
use itertools::Itertools; use itertools::Itertools;
use language::{ use language::{
@ -898,7 +898,7 @@ impl Project {
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
languages: Arc<LanguageRegistry>, languages: Arc<LanguageRegistry>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
let project = let project =
Self::in_room(remote_id, client, user_store, languages, fs, cx.clone()).await?; Self::in_room(remote_id, client, user_store, languages, fs, cx.clone()).await?;
@ -916,7 +916,7 @@ impl Project {
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
languages: Arc<LanguageRegistry>, languages: Arc<LanguageRegistry>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
client.authenticate_and_connect(true, &cx).await?; client.authenticate_and_connect(true, &cx).await?;
@ -958,7 +958,7 @@ impl Project {
user_store: Entity<UserStore>, user_store: Entity<UserStore>,
languages: Arc<LanguageRegistry>, languages: Arc<LanguageRegistry>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<Entity<Self>> { ) -> Result<Entity<Self>> {
let remote_id = response.payload.project_id; let remote_id = response.payload.project_id;
let role = response.payload.role(); let role = response.payload.role();
@ -1156,7 +1156,7 @@ impl Project {
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
pub async fn example( pub async fn example(
root_paths: impl IntoIterator<Item = &Path>, root_paths: impl IntoIterator<Item = &Path>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Entity<Project> { ) -> Entity<Project> {
use clock::FakeSystemClock; use clock::FakeSystemClock;
@ -2018,7 +2018,7 @@ impl Project {
async fn send_buffer_ordered_messages( async fn send_buffer_ordered_messages(
this: WeakEntity<Self>, this: WeakEntity<Self>,
rx: UnboundedReceiver<BufferOrderedMessage>, rx: UnboundedReceiver<BufferOrderedMessage>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
const MAX_BATCH_SIZE: usize = 128; const MAX_BATCH_SIZE: usize = 128;
@ -2028,7 +2028,7 @@ impl Project {
operations_by_buffer_id: &mut HashMap<BufferId, Vec<proto::Operation>>, operations_by_buffer_id: &mut HashMap<BufferId, Vec<proto::Operation>>,
needs_resync_with_host: &mut bool, needs_resync_with_host: &mut bool,
is_local: bool, is_local: bool,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
for (buffer_id, operations) in operations_by_buffer_id.drain() { for (buffer_id, operations) in operations_by_buffer_id.drain() {
let request = this.update(cx, |this, _| { let request = this.update(cx, |this, _| {
@ -3541,7 +3541,7 @@ impl Project {
async fn handle_unshare_project( async fn handle_unshare_project(
this: Entity<Self>, this: Entity<Self>,
_: TypedEnvelope<proto::UnshareProject>, _: TypedEnvelope<proto::UnshareProject>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
if this.is_local() || this.is_via_ssh() { if this.is_local() || this.is_via_ssh() {
@ -3556,7 +3556,7 @@ impl Project {
async fn handle_add_collaborator( async fn handle_add_collaborator(
this: Entity<Self>, this: Entity<Self>,
mut envelope: TypedEnvelope<proto::AddProjectCollaborator>, mut envelope: TypedEnvelope<proto::AddProjectCollaborator>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let collaborator = envelope let collaborator = envelope
.payload .payload
@ -3581,7 +3581,7 @@ impl Project {
async fn handle_update_project_collaborator( async fn handle_update_project_collaborator(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateProjectCollaborator>, envelope: TypedEnvelope<proto::UpdateProjectCollaborator>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
let old_peer_id = envelope let old_peer_id = envelope
.payload .payload
@ -3624,7 +3624,7 @@ impl Project {
async fn handle_remove_collaborator( async fn handle_remove_collaborator(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::RemoveProjectCollaborator>, envelope: TypedEnvelope<proto::RemoveProjectCollaborator>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let peer_id = envelope let peer_id = envelope
@ -3652,7 +3652,7 @@ impl Project {
async fn handle_update_project( async fn handle_update_project(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateProject>, envelope: TypedEnvelope<proto::UpdateProject>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
// Don't handle messages that were sent before the response to us joining the project // Don't handle messages that were sent before the response to us joining the project
@ -3666,7 +3666,7 @@ impl Project {
async fn handle_toast( async fn handle_toast(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::Toast>, envelope: TypedEnvelope<proto::Toast>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |_, cx| { this.update(&mut cx, |_, cx| {
cx.emit(Event::Toast { cx.emit(Event::Toast {
@ -3680,7 +3680,7 @@ impl Project {
async fn handle_language_server_prompt_request( async fn handle_language_server_prompt_request(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::LanguageServerPromptRequest>, envelope: TypedEnvelope<proto::LanguageServerPromptRequest>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::LanguageServerPromptResponse> { ) -> Result<proto::LanguageServerPromptResponse> {
let (tx, mut rx) = smol::channel::bounded(1); let (tx, mut rx) = smol::channel::bounded(1);
let actions: Vec<_> = envelope let actions: Vec<_> = envelope
@ -3727,7 +3727,7 @@ impl Project {
async fn handle_hide_toast( async fn handle_hide_toast(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::HideToast>, envelope: TypedEnvelope<proto::HideToast>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |_, cx| { this.update(&mut cx, |_, cx| {
cx.emit(Event::HideToast { cx.emit(Event::HideToast {
@ -3741,7 +3741,7 @@ impl Project {
async fn handle_update_worktree( async fn handle_update_worktree(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateWorktree>, envelope: TypedEnvelope<proto::UpdateWorktree>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id); let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
@ -3758,7 +3758,7 @@ impl Project {
async fn handle_update_buffer_from_ssh( async fn handle_update_buffer_from_ssh(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateBuffer>, envelope: TypedEnvelope<proto::UpdateBuffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let buffer_store = this.read_with(&cx, |this, cx| { let buffer_store = this.read_with(&cx, |this, cx| {
if let Some(remote_id) = this.remote_id() { if let Some(remote_id) = this.remote_id() {
@ -3776,7 +3776,7 @@ impl Project {
async fn handle_update_buffer( async fn handle_update_buffer(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateBuffer>, envelope: TypedEnvelope<proto::UpdateBuffer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let buffer_store = this.read_with(&cx, |this, cx| { let buffer_store = this.read_with(&cx, |this, cx| {
if let Some(ssh) = &this.ssh_client { if let Some(ssh) = &this.ssh_client {
@ -3812,7 +3812,7 @@ impl Project {
async fn handle_create_buffer_for_peer( async fn handle_create_buffer_for_peer(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::CreateBufferForPeer>, envelope: TypedEnvelope<proto::CreateBufferForPeer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<()> { ) -> Result<()> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.buffer_store.update(cx, |buffer_store, cx| { this.buffer_store.update(cx, |buffer_store, cx| {
@ -3829,7 +3829,7 @@ impl Project {
async fn handle_synchronize_buffers( async fn handle_synchronize_buffers(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::SynchronizeBuffers>, envelope: TypedEnvelope<proto::SynchronizeBuffers>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::SynchronizeBuffersResponse> { ) -> Result<proto::SynchronizeBuffersResponse> {
let response = this.update(&mut cx, |this, cx| { let response = this.update(&mut cx, |this, cx| {
let client = this.client.clone(); let client = this.client.clone();
@ -3844,7 +3844,7 @@ impl Project {
async fn handle_search_candidate_buffers( async fn handle_search_candidate_buffers(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::FindSearchCandidates>, envelope: TypedEnvelope<proto::FindSearchCandidates>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::FindSearchCandidatesResponse> { ) -> Result<proto::FindSearchCandidatesResponse> {
let peer_id = envelope.original_sender_id()?; let peer_id = envelope.original_sender_id()?;
let message = envelope.payload; let message = envelope.payload;
@ -3874,7 +3874,7 @@ impl Project {
async fn handle_open_buffer_by_id( async fn handle_open_buffer_by_id(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::OpenBufferById>, envelope: TypedEnvelope<proto::OpenBufferById>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenBufferResponse> { ) -> Result<proto::OpenBufferResponse> {
let peer_id = envelope.original_sender_id()?; let peer_id = envelope.original_sender_id()?;
let buffer_id = BufferId::new(envelope.payload.id)?; let buffer_id = BufferId::new(envelope.payload.id)?;
@ -3887,7 +3887,7 @@ impl Project {
async fn handle_open_buffer_by_path( async fn handle_open_buffer_by_path(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::OpenBufferByPath>, envelope: TypedEnvelope<proto::OpenBufferByPath>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenBufferResponse> { ) -> Result<proto::OpenBufferResponse> {
let peer_id = envelope.original_sender_id()?; let peer_id = envelope.original_sender_id()?;
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id); let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
@ -3908,7 +3908,7 @@ impl Project {
async fn handle_open_new_buffer( async fn handle_open_new_buffer(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::OpenNewBuffer>, envelope: TypedEnvelope<proto::OpenNewBuffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenBufferResponse> { ) -> Result<proto::OpenBufferResponse> {
let buffer = this let buffer = this
.update(&mut cx, |this, cx| this.create_buffer(cx))? .update(&mut cx, |this, cx| this.create_buffer(cx))?
@ -3922,7 +3922,7 @@ impl Project {
this: Entity<Self>, this: Entity<Self>,
buffer: Entity<Buffer>, buffer: Entity<Buffer>,
peer_id: proto::PeerId, peer_id: proto::PeerId,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<proto::OpenBufferResponse> { ) -> Result<proto::OpenBufferResponse> {
this.update(cx, |this, cx| { this.update(cx, |this, cx| {
let is_private = buffer let is_private = buffer

View file

@ -1,7 +1,7 @@
use anyhow::Context as _; use anyhow::Context as _;
use collections::HashMap; use collections::HashMap;
use fs::Fs; use fs::Fs;
use gpui::{App, AsyncAppContext, BorrowAppContext, Context, Entity, EventEmitter}; use gpui::{App, AsyncApp, BorrowAppContext, Context, Entity, EventEmitter};
use lsp::LanguageServerName; use lsp::LanguageServerName;
use paths::{ use paths::{
local_settings_file_relative_path, local_tasks_file_relative_path, local_settings_file_relative_path, local_tasks_file_relative_path,
@ -323,7 +323,7 @@ impl SettingsObserver {
async fn handle_update_worktree_settings( async fn handle_update_worktree_settings(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateWorktreeSettings>, envelope: TypedEnvelope<proto::UpdateWorktreeSettings>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
let kind = match envelope.payload.kind { let kind = match envelope.payload.kind {
Some(kind) => proto::LocalSettingsKind::from_i32(kind) Some(kind) => proto::LocalSettingsKind::from_i32(kind)

View file

@ -4,7 +4,7 @@ use anyhow::Context as _;
use collections::HashMap; use collections::HashMap;
use fs::Fs; use fs::Fs;
use futures::StreamExt as _; use futures::StreamExt as _;
use gpui::{App, AsyncAppContext, Context, Entity, EventEmitter, Task, WeakEntity}; use gpui::{App, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
use language::{ use language::{
proto::{deserialize_anchor, serialize_anchor}, proto::{deserialize_anchor, serialize_anchor},
ContextProvider as _, LanguageToolchainStore, Location, ContextProvider as _, LanguageToolchainStore, Location,
@ -58,7 +58,7 @@ impl TaskStore {
async fn handle_task_context_for_location( async fn handle_task_context_for_location(
store: Entity<Self>, store: Entity<Self>,
envelope: TypedEnvelope<proto::TaskContextForLocation>, envelope: TypedEnvelope<proto::TaskContextForLocation>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> anyhow::Result<proto::TaskContext> { ) -> anyhow::Result<proto::TaskContext> {
let location = envelope let location = envelope
.payload .payload

View file

@ -5,8 +5,7 @@ use anyhow::{bail, Result};
use async_trait::async_trait; use async_trait::async_trait;
use collections::BTreeMap; use collections::BTreeMap;
use gpui::{ use gpui::{
App, AppContext as _, AsyncAppContext, Context, Entity, EventEmitter, Subscription, Task, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Subscription, Task, WeakEntity,
WeakEntity,
}; };
use language::{LanguageName, LanguageRegistry, LanguageToolchainStore, Toolchain, ToolchainList}; use language::{LanguageName, LanguageRegistry, LanguageToolchainStore, Toolchain, ToolchainList};
use rpc::{proto, AnyProtoClient, TypedEnvelope}; use rpc::{proto, AnyProtoClient, TypedEnvelope};
@ -112,7 +111,7 @@ impl ToolchainStore {
async fn handle_activate_toolchain( async fn handle_activate_toolchain(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ActivateToolchain>, envelope: TypedEnvelope<proto::ActivateToolchain>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let language_name = LanguageName::from_proto(envelope.payload.language_name); let language_name = LanguageName::from_proto(envelope.payload.language_name);
@ -134,7 +133,7 @@ impl ToolchainStore {
async fn handle_active_toolchain( async fn handle_active_toolchain(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ActiveToolchain>, envelope: TypedEnvelope<proto::ActiveToolchain>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ActiveToolchainResponse> { ) -> Result<proto::ActiveToolchainResponse> {
let toolchain = this let toolchain = this
.update(&mut cx, |this, cx| { .update(&mut cx, |this, cx| {
@ -156,7 +155,7 @@ impl ToolchainStore {
async fn handle_list_toolchains( async fn handle_list_toolchains(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ListToolchains>, envelope: TypedEnvelope<proto::ListToolchains>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ListToolchainsResponse> { ) -> Result<proto::ListToolchainsResponse> {
let toolchains = this let toolchains = this
.update(&mut cx, |this, cx| { .update(&mut cx, |this, cx| {
@ -221,7 +220,7 @@ impl language::LanguageToolchainStore for LocalStore {
self: Arc<Self>, self: Arc<Self>,
worktree_id: WorktreeId, worktree_id: WorktreeId,
language_name: LanguageName, language_name: LanguageName,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Option<Toolchain> { ) -> Option<Toolchain> {
self.0 self.0
.update(cx, |this, cx| { .update(cx, |this, cx| {
@ -238,7 +237,7 @@ impl language::LanguageToolchainStore for RemoteStore {
self: Arc<Self>, self: Arc<Self>,
worktree_id: WorktreeId, worktree_id: WorktreeId,
language_name: LanguageName, language_name: LanguageName,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Option<Toolchain> { ) -> Option<Toolchain> {
self.0 self.0
.update(cx, |this, cx| { .update(cx, |this, cx| {
@ -256,7 +255,7 @@ impl language::LanguageToolchainStore for EmptyToolchainStore {
self: Arc<Self>, self: Arc<Self>,
_: WorktreeId, _: WorktreeId,
_: LanguageName, _: LanguageName,
_: &mut AsyncAppContext, _: &mut AsyncApp,
) -> Option<Toolchain> { ) -> Option<Toolchain> {
None None
} }

View file

@ -12,7 +12,7 @@ use futures::{
future::{BoxFuture, Shared}, future::{BoxFuture, Shared},
FutureExt, SinkExt, FutureExt, SinkExt,
}; };
use gpui::{App, AsyncAppContext, Context, Entity, EntityId, EventEmitter, Task, WeakEntity}; use gpui::{App, AsyncApp, Context, Entity, EntityId, EventEmitter, Task, WeakEntity};
use postage::oneshot; use postage::oneshot;
use rpc::{ use rpc::{
proto::{self, SSH_PROJECT_ID}, proto::{self, SSH_PROJECT_ID},
@ -1041,7 +1041,7 @@ impl WorktreeStore {
pub async fn handle_create_project_entry( pub async fn handle_create_project_entry(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::CreateProjectEntry>, envelope: TypedEnvelope<proto::CreateProjectEntry>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ProjectEntryResponse> { ) -> Result<proto::ProjectEntryResponse> {
let worktree = this.update(&mut cx, |this, cx| { let worktree = this.update(&mut cx, |this, cx| {
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id); let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
@ -1054,7 +1054,7 @@ impl WorktreeStore {
pub async fn handle_copy_project_entry( pub async fn handle_copy_project_entry(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::CopyProjectEntry>, envelope: TypedEnvelope<proto::CopyProjectEntry>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ProjectEntryResponse> { ) -> Result<proto::ProjectEntryResponse> {
let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id); let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id);
let worktree = this.update(&mut cx, |this, cx| { let worktree = this.update(&mut cx, |this, cx| {
@ -1067,7 +1067,7 @@ impl WorktreeStore {
pub async fn handle_delete_project_entry( pub async fn handle_delete_project_entry(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::DeleteProjectEntry>, envelope: TypedEnvelope<proto::DeleteProjectEntry>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ProjectEntryResponse> { ) -> Result<proto::ProjectEntryResponse> {
let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id); let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id);
let worktree = this.update(&mut cx, |this, cx| { let worktree = this.update(&mut cx, |this, cx| {
@ -1080,7 +1080,7 @@ impl WorktreeStore {
pub async fn handle_expand_project_entry( pub async fn handle_expand_project_entry(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ExpandProjectEntry>, envelope: TypedEnvelope<proto::ExpandProjectEntry>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::ExpandProjectEntryResponse> { ) -> Result<proto::ExpandProjectEntryResponse> {
let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id); let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id);
let worktree = this let worktree = this
@ -1092,7 +1092,7 @@ impl WorktreeStore {
pub async fn handle_git_branches( pub async fn handle_git_branches(
this: Entity<Self>, this: Entity<Self>,
branches: TypedEnvelope<proto::GitBranches>, branches: TypedEnvelope<proto::GitBranches>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<proto::GitBranchesResponse> { ) -> Result<proto::GitBranchesResponse> {
let project_path = branches let project_path = branches
.payload .payload
@ -1123,7 +1123,7 @@ impl WorktreeStore {
pub async fn handle_update_branch( pub async fn handle_update_branch(
this: Entity<Self>, this: Entity<Self>,
update_branch: TypedEnvelope<proto::UpdateGitBranch>, update_branch: TypedEnvelope<proto::UpdateGitBranch>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let project_path = update_branch let project_path = update_branch
.payload .payload

View file

@ -350,7 +350,7 @@ mod tests {
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
// Create the project symbols view. // Create the project symbols view.
let symbols = cx.new_window_model(|window, cx| { let symbols = cx.new_window_entity(|window, cx| {
Picker::uniform_list( Picker::uniform_list(
ProjectSymbolsDelegate::new(workspace.downgrade(), project.clone()), ProjectSymbolsDelegate::new(workspace.downgrade(), project.clone()),
window, window,

View file

@ -7,8 +7,8 @@ use editor::Editor;
use extension_host::ExtensionStore; use extension_host::ExtensionStore;
use futures::channel::oneshot; use futures::channel::oneshot;
use gpui::{ use gpui::{
percentage, Animation, AnimationExt, AnyWindowHandle, App, AsyncAppContext, DismissEvent, percentage, Animation, AnimationExt, AnyWindowHandle, App, AsyncApp, DismissEvent, Entity,
Entity, EventEmitter, Focusable, FontFeatures, ParentElement as _, PromptLevel, Render, EventEmitter, Focusable, FontFeatures, ParentElement as _, PromptLevel, Render,
SemanticVersion, SharedString, Task, TextStyleRefinement, Transformation, WeakEntity, SemanticVersion, SharedString, Task, TextStyleRefinement, Transformation, WeakEntity,
}; };
@ -425,11 +425,7 @@ pub struct SshClientDelegate {
} }
impl remote::SshClientDelegate for SshClientDelegate { impl remote::SshClientDelegate for SshClientDelegate {
fn ask_password( fn ask_password(&self, prompt: String, cx: &mut AsyncApp) -> oneshot::Receiver<Result<String>> {
&self,
prompt: String,
cx: &mut AsyncAppContext,
) -> oneshot::Receiver<Result<String>> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let mut known_password = self.known_password.clone(); let mut known_password = self.known_password.clone();
if let Some(password) = known_password.take() { if let Some(password) = known_password.take() {
@ -446,7 +442,7 @@ impl remote::SshClientDelegate for SshClientDelegate {
rx rx
} }
fn set_status(&self, status: Option<&str>, cx: &mut AsyncAppContext) { fn set_status(&self, status: Option<&str>, cx: &mut AsyncApp) {
self.update_status(status, cx) self.update_status(status, cx)
} }
@ -455,7 +451,7 @@ impl remote::SshClientDelegate for SshClientDelegate {
platform: SshPlatform, platform: SshPlatform,
release_channel: ReleaseChannel, release_channel: ReleaseChannel,
version: Option<SemanticVersion>, version: Option<SemanticVersion>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<anyhow::Result<PathBuf>> { ) -> Task<anyhow::Result<PathBuf>> {
cx.spawn(|mut cx| async move { cx.spawn(|mut cx| async move {
let binary_path = AutoUpdater::download_remote_server_release( let binary_path = AutoUpdater::download_remote_server_release(
@ -486,7 +482,7 @@ impl remote::SshClientDelegate for SshClientDelegate {
platform: SshPlatform, platform: SshPlatform,
release_channel: ReleaseChannel, release_channel: ReleaseChannel,
version: Option<SemanticVersion>, version: Option<SemanticVersion>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<Result<Option<(String, String)>>> { ) -> Task<Result<Option<(String, String)>>> {
cx.spawn(|mut cx| async move { cx.spawn(|mut cx| async move {
AutoUpdater::get_remote_server_release_url( AutoUpdater::get_remote_server_release_url(
@ -502,7 +498,7 @@ impl remote::SshClientDelegate for SshClientDelegate {
} }
impl SshClientDelegate { impl SshClientDelegate {
fn update_status(&self, status: Option<&str>, cx: &mut AsyncAppContext) { fn update_status(&self, status: Option<&str>, cx: &mut AsyncApp) {
self.window self.window
.update(cx, |_, _, cx| { .update(cx, |_, _, cx| {
self.ui.update(cx, |modal, cx| { self.ui.update(cx, |modal, cx| {
@ -547,7 +543,7 @@ pub async fn open_ssh_project(
paths: Vec<PathBuf>, paths: Vec<PathBuf>,
app_state: Arc<AppState>, app_state: Arc<AppState>,
open_options: workspace::OpenOptions, open_options: workspace::OpenOptions,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
let window = if let Some(window) = open_options.replace_window { let window = if let Some(window) = open_options.replace_window {
window window

View file

@ -17,7 +17,7 @@ use futures::{
select, select_biased, AsyncReadExt as _, Future, FutureExt as _, StreamExt as _, select, select_biased, AsyncReadExt as _, Future, FutureExt as _, StreamExt as _,
}; };
use gpui::{ use gpui::{
App, AppContext, AsyncAppContext, BorrowAppContext, Context, Entity, EventEmitter, Global, App, AppContext, AsyncApp, BorrowAppContext, Context, Entity, EventEmitter, Global,
SemanticVersion, Task, WeakEntity, SemanticVersion, Task, WeakEntity,
}; };
use itertools::Itertools; use itertools::Itertools;
@ -226,17 +226,13 @@ impl SshPlatform {
} }
pub trait SshClientDelegate: Send + Sync { pub trait SshClientDelegate: Send + Sync {
fn ask_password( fn ask_password(&self, prompt: String, cx: &mut AsyncApp) -> oneshot::Receiver<Result<String>>;
&self,
prompt: String,
cx: &mut AsyncAppContext,
) -> oneshot::Receiver<Result<String>>;
fn get_download_params( fn get_download_params(
&self, &self,
platform: SshPlatform, platform: SshPlatform,
release_channel: ReleaseChannel, release_channel: ReleaseChannel,
version: Option<SemanticVersion>, version: Option<SemanticVersion>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<Result<Option<(String, String)>>>; ) -> Task<Result<Option<(String, String)>>>;
fn download_server_binary_locally( fn download_server_binary_locally(
@ -244,9 +240,9 @@ pub trait SshClientDelegate: Send + Sync {
platform: SshPlatform, platform: SshPlatform,
release_channel: ReleaseChannel, release_channel: ReleaseChannel,
version: Option<SemanticVersion>, version: Option<SemanticVersion>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<Result<PathBuf>>; ) -> Task<Result<PathBuf>>;
fn set_status(&self, status: Option<&str>, cx: &mut AsyncAppContext); fn set_status(&self, status: Option<&str>, cx: &mut AsyncApp);
} }
impl SshSocket { impl SshSocket {
@ -813,7 +809,7 @@ impl SshRemoteClient {
fn heartbeat( fn heartbeat(
this: WeakEntity<Self>, this: WeakEntity<Self>,
mut connection_activity_rx: mpsc::Receiver<()>, mut connection_activity_rx: mpsc::Receiver<()>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<Result<()>> { ) -> Task<Result<()>> {
let Ok(client) = this.update(cx, |this, _| this.client.clone()) else { let Ok(client) = this.update(cx, |this, _| this.client.clone()) else {
return Task::ready(Err(anyhow!("SshRemoteClient lost"))); return Task::ready(Err(anyhow!("SshRemoteClient lost")));
@ -915,7 +911,7 @@ impl SshRemoteClient {
fn monitor( fn monitor(
this: WeakEntity<Self>, this: WeakEntity<Self>,
io_task: Task<Result<i32>>, io_task: Task<Result<i32>>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Task<Result<()>> { ) -> Task<Result<()>> {
cx.spawn(|mut cx| async move { cx.spawn(|mut cx| async move {
let result = io_task.await; let result = io_task.await;
@ -1204,7 +1200,7 @@ trait RemoteConnection: Send + Sync {
outgoing_rx: UnboundedReceiver<Envelope>, outgoing_rx: UnboundedReceiver<Envelope>,
connection_activity_tx: Sender<()>, connection_activity_tx: Sender<()>,
delegate: Arc<dyn SshClientDelegate>, delegate: Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<Result<i32>>; ) -> Task<Result<i32>>;
fn upload_directory(&self, src_path: PathBuf, dest_path: PathBuf, cx: &App) fn upload_directory(&self, src_path: PathBuf, dest_path: PathBuf, cx: &App)
-> Task<Result<()>>; -> Task<Result<()>>;
@ -1214,7 +1210,7 @@ trait RemoteConnection: Send + Sync {
fn connection_options(&self) -> SshConnectionOptions; fn connection_options(&self) -> SshConnectionOptions;
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
fn simulate_disconnect(&self, _: &AsyncAppContext) {} fn simulate_disconnect(&self, _: &AsyncApp) {}
} }
struct SshRemoteConnection { struct SshRemoteConnection {
@ -1298,7 +1294,7 @@ impl RemoteConnection for SshRemoteConnection {
outgoing_rx: UnboundedReceiver<Envelope>, outgoing_rx: UnboundedReceiver<Envelope>,
connection_activity_tx: Sender<()>, connection_activity_tx: Sender<()>,
delegate: Arc<dyn SshClientDelegate>, delegate: Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<Result<i32>> { ) -> Task<Result<i32>> {
delegate.set_status(Some("Starting proxy"), cx); delegate.set_status(Some("Starting proxy"), cx);
@ -1358,7 +1354,7 @@ impl SshRemoteConnection {
async fn new( async fn new(
_connection_options: SshConnectionOptions, _connection_options: SshConnectionOptions,
_delegate: Arc<dyn SshClientDelegate>, _delegate: Arc<dyn SshClientDelegate>,
_cx: &mut AsyncAppContext, _cx: &mut AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
Err(anyhow!("ssh is not supported on this platform")) Err(anyhow!("ssh is not supported on this platform"))
} }
@ -1367,7 +1363,7 @@ impl SshRemoteConnection {
async fn new( async fn new(
connection_options: SshConnectionOptions, connection_options: SshConnectionOptions,
delegate: Arc<dyn SshClientDelegate>, delegate: Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
use futures::AsyncWriteExt as _; use futures::AsyncWriteExt as _;
use futures::{io::BufReader, AsyncBufReadExt as _}; use futures::{io::BufReader, AsyncBufReadExt as _};
@ -1584,7 +1580,7 @@ impl SshRemoteConnection {
incoming_tx: UnboundedSender<Envelope>, incoming_tx: UnboundedSender<Envelope>,
mut outgoing_rx: UnboundedReceiver<Envelope>, mut outgoing_rx: UnboundedReceiver<Envelope>,
mut connection_activity_tx: Sender<()>, mut connection_activity_tx: Sender<()>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Task<Result<i32>> { ) -> Task<Result<i32>> {
let mut child_stderr = ssh_proxy_process.stderr.take().unwrap(); let mut child_stderr = ssh_proxy_process.stderr.take().unwrap();
let mut child_stdout = ssh_proxy_process.stdout.take().unwrap(); let mut child_stdout = ssh_proxy_process.stdout.take().unwrap();
@ -1688,7 +1684,7 @@ impl SshRemoteConnection {
release_channel: ReleaseChannel, release_channel: ReleaseChannel,
version: SemanticVersion, version: SemanticVersion,
commit: Option<AppCommitSha>, commit: Option<AppCommitSha>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
let version_str = match release_channel { let version_str = match release_channel {
ReleaseChannel::Nightly => { ReleaseChannel::Nightly => {
@ -1785,7 +1781,7 @@ impl SshRemoteConnection {
body: &str, body: &str,
tmp_path_gz: &Path, tmp_path_gz: &Path,
delegate: &Arc<dyn SshClientDelegate>, delegate: &Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
if let Some(parent) = tmp_path_gz.parent() { if let Some(parent) = tmp_path_gz.parent() {
self.socket self.socket
@ -1858,7 +1854,7 @@ impl SshRemoteConnection {
src_path: &Path, src_path: &Path,
tmp_path_gz: &Path, tmp_path_gz: &Path,
delegate: &Arc<dyn SshClientDelegate>, delegate: &Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
if let Some(parent) = tmp_path_gz.parent() { if let Some(parent) = tmp_path_gz.parent() {
self.socket self.socket
@ -1888,7 +1884,7 @@ impl SshRemoteConnection {
dst_path: &Path, dst_path: &Path,
tmp_path_gz: &Path, tmp_path_gz: &Path,
delegate: &Arc<dyn SshClientDelegate>, delegate: &Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<()> { ) -> Result<()> {
delegate.set_status(Some("Extracting remote development server"), cx); delegate.set_status(Some("Extracting remote development server"), cx);
let server_mode = 0o755; let server_mode = 0o755;
@ -1943,7 +1939,7 @@ impl SshRemoteConnection {
&self, &self,
platform: SshPlatform, platform: SshPlatform,
delegate: &Arc<dyn SshClientDelegate>, delegate: &Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
use smol::process::{Command, Stdio}; use smol::process::{Command, Stdio};
@ -2085,7 +2081,7 @@ impl ChannelClient {
fn start_handling_messages( fn start_handling_messages(
this: Weak<Self>, this: Weak<Self>,
mut incoming_rx: mpsc::UnboundedReceiver<Envelope>, mut incoming_rx: mpsc::UnboundedReceiver<Envelope>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Task<Result<()>> { ) -> Task<Result<()>> {
cx.spawn(|cx| async move { cx.spawn(|cx| async move {
let peer_id = PeerId { owner_id: 0, id: 0 }; let peer_id = PeerId { owner_id: 0, id: 0 };
@ -2185,7 +2181,7 @@ impl ChannelClient {
self: &Arc<Self>, self: &Arc<Self>,
incoming_rx: UnboundedReceiver<Envelope>, incoming_rx: UnboundedReceiver<Envelope>,
outgoing_tx: UnboundedSender<Envelope>, outgoing_tx: UnboundedSender<Envelope>,
cx: &AsyncAppContext, cx: &AsyncApp,
) { ) {
*self.outgoing_tx.lock() = outgoing_tx; *self.outgoing_tx.lock() = outgoing_tx;
*self.task.lock() = Self::start_handling_messages(Arc::downgrade(self), incoming_rx, cx); *self.task.lock() = Self::start_handling_messages(Arc::downgrade(self), incoming_rx, cx);
@ -2365,7 +2361,7 @@ mod fake {
}, },
select_biased, FutureExt, SinkExt, StreamExt, select_biased, FutureExt, SinkExt, StreamExt,
}; };
use gpui::{App, AsyncAppContext, SemanticVersion, Task, TestAppContext}; use gpui::{App, AsyncApp, SemanticVersion, Task, TestAppContext};
use release_channel::ReleaseChannel; use release_channel::ReleaseChannel;
use rpc::proto::Envelope; use rpc::proto::Envelope;
@ -2379,15 +2375,15 @@ mod fake {
pub(super) server_cx: SendableCx, pub(super) server_cx: SendableCx,
} }
pub(super) struct SendableCx(AsyncAppContext); pub(super) struct SendableCx(AsyncApp);
impl SendableCx { impl SendableCx {
// SAFETY: When run in test mode, GPUI is always single threaded. // SAFETY: When run in test mode, GPUI is always single threaded.
pub(super) fn new(cx: &TestAppContext) -> Self { pub(super) fn new(cx: &TestAppContext) -> Self {
Self(cx.to_async()) Self(cx.to_async())
} }
// SAFETY: Enforce that we're on the main thread by requiring a valid AsyncAppContext // SAFETY: Enforce that we're on the main thread by requiring a valid AsyncApp
fn get(&self, _: &AsyncAppContext) -> AsyncAppContext { fn get(&self, _: &AsyncApp) -> AsyncApp {
self.0.clone() self.0.clone()
} }
} }
@ -2422,7 +2418,7 @@ mod fake {
self.connection_options.clone() self.connection_options.clone()
} }
fn simulate_disconnect(&self, cx: &AsyncAppContext) { fn simulate_disconnect(&self, cx: &AsyncApp) {
let (outgoing_tx, _) = mpsc::unbounded::<Envelope>(); let (outgoing_tx, _) = mpsc::unbounded::<Envelope>();
let (_, incoming_rx) = mpsc::unbounded::<Envelope>(); let (_, incoming_rx) = mpsc::unbounded::<Envelope>();
self.server_channel self.server_channel
@ -2438,7 +2434,7 @@ mod fake {
mut client_outgoing_rx: mpsc::UnboundedReceiver<Envelope>, mut client_outgoing_rx: mpsc::UnboundedReceiver<Envelope>,
mut connection_activity_tx: Sender<()>, mut connection_activity_tx: Sender<()>,
_delegate: Arc<dyn SshClientDelegate>, _delegate: Arc<dyn SshClientDelegate>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Task<Result<i32>> { ) -> Task<Result<i32>> {
let (mut server_incoming_tx, server_incoming_rx) = mpsc::unbounded::<Envelope>(); let (mut server_incoming_tx, server_incoming_rx) = mpsc::unbounded::<Envelope>();
let (server_outgoing_tx, mut server_outgoing_rx) = mpsc::unbounded::<Envelope>(); let (server_outgoing_tx, mut server_outgoing_rx) = mpsc::unbounded::<Envelope>();
@ -2474,11 +2470,7 @@ mod fake {
pub(super) struct Delegate; pub(super) struct Delegate;
impl SshClientDelegate for Delegate { impl SshClientDelegate for Delegate {
fn ask_password( fn ask_password(&self, _: String, _: &mut AsyncApp) -> oneshot::Receiver<Result<String>> {
&self,
_: String,
_: &mut AsyncAppContext,
) -> oneshot::Receiver<Result<String>> {
unreachable!() unreachable!()
} }
@ -2487,7 +2479,7 @@ mod fake {
_: SshPlatform, _: SshPlatform,
_: ReleaseChannel, _: ReleaseChannel,
_: Option<SemanticVersion>, _: Option<SemanticVersion>,
_: &mut AsyncAppContext, _: &mut AsyncApp,
) -> Task<Result<PathBuf>> { ) -> Task<Result<PathBuf>> {
unreachable!() unreachable!()
} }
@ -2497,11 +2489,11 @@ mod fake {
_platform: SshPlatform, _platform: SshPlatform,
_release_channel: ReleaseChannel, _release_channel: ReleaseChannel,
_version: Option<SemanticVersion>, _version: Option<SemanticVersion>,
_cx: &mut AsyncAppContext, _cx: &mut AsyncApp,
) -> Task<Result<Option<(String, String)>>> { ) -> Task<Result<Option<(String, String)>>> {
unreachable!() unreachable!()
} }
fn set_status(&self, _: Option<&str>, _: &mut AsyncAppContext) {} fn set_status(&self, _: Option<&str>, _: &mut AsyncApp) {}
} }
} }

View file

@ -2,7 +2,7 @@ use anyhow::{anyhow, Result};
use extension::ExtensionHostProxy; use extension::ExtensionHostProxy;
use extension_host::headless_host::HeadlessExtensionStore; use extension_host::headless_host::HeadlessExtensionStore;
use fs::Fs; use fs::Fs;
use gpui::{App, AppContext as _, AsyncAppContext, Context, Entity, PromptLevel}; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, PromptLevel};
use http_client::HttpClient; use http_client::HttpClient;
use language::{proto::serialize_operation, Buffer, BufferEvent, LanguageRegistry}; use language::{proto::serialize_operation, Buffer, BufferEvent, LanguageRegistry};
use node_runtime::NodeRuntime; use node_runtime::NodeRuntime;
@ -308,7 +308,7 @@ impl HeadlessProject {
pub async fn handle_add_worktree( pub async fn handle_add_worktree(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::AddWorktree>, message: TypedEnvelope<proto::AddWorktree>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::AddWorktreeResponse> { ) -> Result<proto::AddWorktreeResponse> {
use client::ErrorCodeExt; use client::ErrorCodeExt;
let path = shellexpand::tilde(&message.payload.path).to_string(); let path = shellexpand::tilde(&message.payload.path).to_string();
@ -381,7 +381,7 @@ impl HeadlessProject {
pub async fn handle_remove_worktree( pub async fn handle_remove_worktree(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::RemoveWorktree>, envelope: TypedEnvelope<proto::RemoveWorktree>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id); let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
@ -395,7 +395,7 @@ impl HeadlessProject {
pub async fn handle_open_buffer_by_path( pub async fn handle_open_buffer_by_path(
this: Entity<Self>, this: Entity<Self>,
message: TypedEnvelope<proto::OpenBufferByPath>, message: TypedEnvelope<proto::OpenBufferByPath>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenBufferResponse> { ) -> Result<proto::OpenBufferResponse> {
let worktree_id = WorktreeId::from_proto(message.payload.worktree_id); let worktree_id = WorktreeId::from_proto(message.payload.worktree_id);
let (buffer_store, buffer) = this.update(&mut cx, |this, cx| { let (buffer_store, buffer) = this.update(&mut cx, |this, cx| {
@ -428,7 +428,7 @@ impl HeadlessProject {
pub async fn handle_open_new_buffer( pub async fn handle_open_new_buffer(
this: Entity<Self>, this: Entity<Self>,
_message: TypedEnvelope<proto::OpenNewBuffer>, _message: TypedEnvelope<proto::OpenNewBuffer>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenBufferResponse> { ) -> Result<proto::OpenBufferResponse> {
let (buffer_store, buffer) = this.update(&mut cx, |this, cx| { let (buffer_store, buffer) = this.update(&mut cx, |this, cx| {
let buffer_store = this.buffer_store.clone(); let buffer_store = this.buffer_store.clone();
@ -454,7 +454,7 @@ impl HeadlessProject {
pub async fn handle_open_server_settings( pub async fn handle_open_server_settings(
this: Entity<Self>, this: Entity<Self>,
_: TypedEnvelope<proto::OpenServerSettings>, _: TypedEnvelope<proto::OpenServerSettings>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::OpenBufferResponse> { ) -> Result<proto::OpenBufferResponse> {
let settings_path = paths::settings_file(); let settings_path = paths::settings_file();
let (worktree, path) = this let (worktree, path) = this
@ -507,7 +507,7 @@ impl HeadlessProject {
pub async fn handle_find_search_candidates( pub async fn handle_find_search_candidates(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::FindSearchCandidates>, envelope: TypedEnvelope<proto::FindSearchCandidates>,
mut cx: AsyncAppContext, mut cx: AsyncApp,
) -> Result<proto::FindSearchCandidatesResponse> { ) -> Result<proto::FindSearchCandidatesResponse> {
let message = envelope.payload; let message = envelope.payload;
let query = SearchQuery::from_proto( let query = SearchQuery::from_proto(
@ -543,10 +543,10 @@ impl HeadlessProject {
pub async fn handle_list_remote_directory( pub async fn handle_list_remote_directory(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ListRemoteDirectory>, envelope: TypedEnvelope<proto::ListRemoteDirectory>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<proto::ListRemoteDirectoryResponse> { ) -> Result<proto::ListRemoteDirectoryResponse> {
let expanded = shellexpand::tilde(&envelope.payload.path).to_string(); let expanded = shellexpand::tilde(&envelope.payload.path).to_string();
let fs = cx.read_model(&this, |this, _| this.fs.clone())?; let fs = cx.read_entity(&this, |this, _| this.fs.clone())?;
let mut entries = Vec::new(); let mut entries = Vec::new();
let mut response = fs.read_dir(Path::new(&expanded)).await?; let mut response = fs.read_dir(Path::new(&expanded)).await?;
@ -561,9 +561,9 @@ impl HeadlessProject {
pub async fn handle_get_path_metadata( pub async fn handle_get_path_metadata(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::GetPathMetadata>, envelope: TypedEnvelope<proto::GetPathMetadata>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<proto::GetPathMetadataResponse> { ) -> Result<proto::GetPathMetadataResponse> {
let fs = cx.read_model(&this, |this, _| this.fs.clone())?; let fs = cx.read_entity(&this, |this, _| this.fs.clone())?;
let expanded = shellexpand::tilde(&envelope.payload.path).to_string(); let expanded = shellexpand::tilde(&envelope.payload.path).to_string();
let metadata = fs.metadata(&PathBuf::from(expanded.clone())).await?; let metadata = fs.metadata(&PathBuf::from(expanded.clone())).await?;
@ -579,7 +579,7 @@ impl HeadlessProject {
pub async fn handle_shutdown_remote_server( pub async fn handle_shutdown_remote_server(
_this: Entity<Self>, _this: Entity<Self>,
_envelope: TypedEnvelope<proto::ShutdownRemoteServer>, _envelope: TypedEnvelope<proto::ShutdownRemoteServer>,
cx: AsyncAppContext, cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
cx.spawn(|cx| async move { cx.spawn(|cx| async move {
cx.update(|cx| { cx.update(|cx| {
@ -597,7 +597,7 @@ impl HeadlessProject {
pub async fn handle_ping( pub async fn handle_ping(
_this: Entity<Self>, _this: Entity<Self>,
_envelope: TypedEnvelope<proto::Ping>, _envelope: TypedEnvelope<proto::Ping>,
_cx: AsyncAppContext, _cx: AsyncApp,
) -> Result<proto::Ack> { ) -> Result<proto::Ack> {
log::debug!("Received ping from client"); log::debug!("Received ping from client");
Ok(proto::Ack {}) Ok(proto::Ack {})

View file

@ -401,7 +401,7 @@ async fn test_remote_lsp(cx: &mut TestAppContext, server_cx: &mut TestAppContext
) )
.await; .await;
cx.update_model(&project, |project, _| { cx.update_entity(&project, |project, _| {
project.languages().register_test_language(LanguageConfig { project.languages().register_test_language(LanguageConfig {
name: "Rust".into(), name: "Rust".into(),
matcher: LanguageMatcher { matcher: LanguageMatcher {
@ -578,7 +578,7 @@ async fn test_remote_cancel_language_server_work(
) )
.await; .await;
cx.update_model(&project, |project, _| { cx.update_entity(&project, |project, _| {
project.languages().register_test_language(LanguageConfig { project.languages().register_test_language(LanguageConfig {
name: "Rust".into(), name: "Rust".into(),
matcher: LanguageMatcher { matcher: LanguageMatcher {

View file

@ -675,7 +675,7 @@ impl EventEmitter<()> for NotebookEditor {}
// impl EventEmitter<ToolbarItemEvent> for NotebookControls {} // impl EventEmitter<ToolbarItemEvent> for NotebookControls {}
// impl Render for NotebookControls { // impl Render for NotebookControls {
// fn render(&mut self, window: &mut Window, cx: &mut ModelContext<Self>) -> impl IntoElement { // fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
// div().child("notebook controls") // div().child("notebook controls")
// } // }
// } // }
@ -684,7 +684,7 @@ impl EventEmitter<()> for NotebookEditor {}
// fn set_active_pane_item( // fn set_active_pane_item(
// &mut self, // &mut self,
// active_pane_item: Option<&dyn workspace::ItemHandle>, // active_pane_item: Option<&dyn workspace::ItemHandle>,
// window: &mut Window, cx: &mut ModelContext<Self>, // window: &mut Window, cx: &mut Context<Self>,
// ) -> workspace::ToolbarItemLocation { // ) -> workspace::ToolbarItemLocation {
// cx.notify(); // cx.notify();
// self.active_item = None; // self.active_item = None;
@ -696,7 +696,7 @@ impl EventEmitter<()> for NotebookEditor {}
// ToolbarItemLocation::PrimaryLeft // ToolbarItemLocation::PrimaryLeft
// } // }
// fn pane_focus_update(&mut self, pane_focused: bool, _window: &mut Window, _cx: &mut ModelContext<Self>) { // fn pane_focus_update(&mut self, pane_focused: bool, _window: &mut Window, _cx: &mut Context<Self>) {
// self.pane_focused = pane_focused; // self.pane_focused = pane_focused;
// } // }
// } // }

View file

@ -4,7 +4,7 @@ use futures::{
future::{BoxFuture, LocalBoxFuture}, future::{BoxFuture, LocalBoxFuture},
Future, FutureExt as _, Future, FutureExt as _,
}; };
use gpui::{AnyEntity, AnyWeakEntity, AsyncAppContext, Entity}; use gpui::{AnyEntity, AnyWeakEntity, AsyncApp, Entity};
use proto::{ use proto::{
error::ErrorExt as _, AnyTypedEnvelope, EntityMessage, Envelope, EnvelopedMessage, error::ErrorExt as _, AnyTypedEnvelope, EntityMessage, Envelope, EnvelopedMessage,
RequestMessage, TypedEnvelope, RequestMessage, TypedEnvelope,
@ -64,7 +64,7 @@ pub type ProtoMessageHandler = Arc<
AnyEntity, AnyEntity,
Box<dyn AnyTypedEnvelope>, Box<dyn AnyTypedEnvelope>,
AnyProtoClient, AnyProtoClient,
AsyncAppContext, AsyncApp,
) -> LocalBoxFuture<'static, anyhow::Result<()>>, ) -> LocalBoxFuture<'static, anyhow::Result<()>>,
>; >;
@ -111,7 +111,7 @@ impl ProtoMessageHandlerSet {
this: &parking_lot::Mutex<Self>, this: &parking_lot::Mutex<Self>,
message: Box<dyn AnyTypedEnvelope>, message: Box<dyn AnyTypedEnvelope>,
client: AnyProtoClient, client: AnyProtoClient,
cx: AsyncAppContext, cx: AsyncApp,
) -> Option<LocalBoxFuture<'static, anyhow::Result<()>>> { ) -> Option<LocalBoxFuture<'static, anyhow::Result<()>>> {
let payload_type_id = message.payload_type_id(); let payload_type_id = message.payload_type_id();
let mut this = this.lock(); let mut this = this.lock();
@ -211,7 +211,7 @@ impl AnyProtoClient {
where where
M: RequestMessage, M: RequestMessage,
E: 'static, E: 'static,
H: 'static + Sync + Fn(Entity<E>, TypedEnvelope<M>, AsyncAppContext) -> F + Send + Sync, H: 'static + Sync + Fn(Entity<E>, TypedEnvelope<M>, AsyncApp) -> F + Send + Sync,
F: 'static + Future<Output = anyhow::Result<M::Response>>, F: 'static + Future<Output = anyhow::Result<M::Response>>,
{ {
self.0.message_handler_set().lock().add_message_handler( self.0.message_handler_set().lock().add_message_handler(
@ -243,7 +243,7 @@ impl AnyProtoClient {
where where
M: EnvelopedMessage + RequestMessage + EntityMessage, M: EnvelopedMessage + RequestMessage + EntityMessage,
E: 'static, E: 'static,
H: 'static + Sync + Send + Fn(gpui::Entity<E>, TypedEnvelope<M>, AsyncAppContext) -> F, H: 'static + Sync + Send + Fn(gpui::Entity<E>, TypedEnvelope<M>, AsyncApp) -> F,
F: 'static + Future<Output = anyhow::Result<M::Response>>, F: 'static + Future<Output = anyhow::Result<M::Response>>,
{ {
let message_type_id = TypeId::of::<M>(); let message_type_id = TypeId::of::<M>();
@ -289,7 +289,7 @@ impl AnyProtoClient {
where where
M: EnvelopedMessage + EntityMessage, M: EnvelopedMessage + EntityMessage,
E: 'static, E: 'static,
H: 'static + Sync + Send + Fn(gpui::Entity<E>, TypedEnvelope<M>, AsyncAppContext) -> F, H: 'static + Sync + Send + Fn(gpui::Entity<E>, TypedEnvelope<M>, AsyncApp) -> F,
F: 'static + Future<Output = anyhow::Result<()>>, F: 'static + Future<Output = anyhow::Result<()>>,
{ {
let message_type_id = TypeId::of::<M>(); let message_type_id = TypeId::of::<M>();

View file

@ -1431,9 +1431,9 @@ mod tests {
}); });
let cx = cx.add_empty_window(); let cx = cx.add_empty_window();
let editor = let editor =
cx.new_window_model(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx)); cx.new_window_entity(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx));
let search_bar = cx.new_window_model(|window, cx| { let search_bar = cx.new_window_entity(|window, cx| {
let mut search_bar = BufferSearchBar::new(window, cx); let mut search_bar = BufferSearchBar::new(window, cx);
search_bar.set_active_pane_item(Some(&editor), window, cx); search_bar.set_active_pane_item(Some(&editor), window, cx);
search_bar.show(window, cx); search_bar.show(window, cx);
@ -2008,9 +2008,9 @@ mod tests {
let cx = cx.add_empty_window(); let cx = cx.add_empty_window();
let editor = let editor =
cx.new_window_model(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx)); cx.new_window_entity(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx));
let search_bar = cx.new_window_model(|window, cx| { let search_bar = cx.new_window_entity(|window, cx| {
let mut search_bar = BufferSearchBar::new(window, cx); let mut search_bar = BufferSearchBar::new(window, cx);
search_bar.set_active_pane_item(Some(&editor), window, cx); search_bar.set_active_pane_item(Some(&editor), window, cx);
search_bar.show(window, cx); search_bar.show(window, cx);
@ -2082,9 +2082,9 @@ mod tests {
let cx = cx.add_empty_window(); let cx = cx.add_empty_window();
let editor = let editor =
cx.new_window_model(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx)); cx.new_window_entity(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx));
let search_bar = cx.new_window_model(|window, cx| { let search_bar = cx.new_window_entity(|window, cx| {
let mut search_bar = BufferSearchBar::new(window, cx); let mut search_bar = BufferSearchBar::new(window, cx);
search_bar.set_active_pane_item(Some(&editor), window, cx); search_bar.set_active_pane_item(Some(&editor), window, cx);
search_bar.show(window, cx); search_bar.show(window, cx);
@ -2462,9 +2462,9 @@ mod tests {
}); });
let cx = cx.add_empty_window(); let cx = cx.add_empty_window();
let editor = let editor =
cx.new_window_model(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx)); cx.new_window_entity(|window, cx| Editor::for_buffer(buffer.clone(), None, window, cx));
let search_bar = cx.new_window_model(|window, cx| { let search_bar = cx.new_window_entity(|window, cx| {
let mut search_bar = BufferSearchBar::new(window, cx); let mut search_bar = BufferSearchBar::new(window, cx);
search_bar.set_active_pane_item(Some(&editor), window, cx); search_bar.set_active_pane_item(Some(&editor), window, cx);
search_bar.show(window, cx); search_bar.show(window, cx);
@ -2530,7 +2530,7 @@ mod tests {
.unindent(); .unindent();
let cx = cx.add_empty_window(); let cx = cx.add_empty_window();
let editor = cx.new_window_model(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
let multibuffer = MultiBuffer::build_multi( let multibuffer = MultiBuffer::build_multi(
[ [
( (
@ -2547,7 +2547,7 @@ mod tests {
Editor::for_multibuffer(multibuffer, None, false, window, cx) Editor::for_multibuffer(multibuffer, None, false, window, cx)
}); });
let search_bar = cx.new_window_model(|window, cx| { let search_bar = cx.new_window_entity(|window, cx| {
let mut search_bar = BufferSearchBar::new(window, cx); let mut search_bar = BufferSearchBar::new(window, cx);
search_bar.set_active_pane_item(Some(&editor), window, cx); search_bar.set_active_pane_item(Some(&editor), window, cx);
search_bar.show(window, cx); search_bar.show(window, cx);

View file

@ -3795,7 +3795,7 @@ pub mod tests {
// Wait for the unstaged changes to be loaded // Wait for the unstaged changes to be loaded
cx.run_until_parked(); cx.run_until_parked();
let buffer_search_bar = cx.new_window_model(|window, cx| { let buffer_search_bar = cx.new_window_entity(|window, cx| {
let mut search_bar = BufferSearchBar::new(window, cx); let mut search_bar = BufferSearchBar::new(window, cx);
search_bar.set_active_pane_item(Some(&editor), window, cx); search_bar.set_active_pane_item(Some(&editor), window, cx);
search_bar.show(window, cx); search_bar.show(window, cx);

View file

@ -11,9 +11,7 @@ mod worktree_index;
use anyhow::{Context as _, Result}; use anyhow::{Context as _, Result};
use collections::HashMap; use collections::HashMap;
use fs::Fs; use fs::Fs;
use gpui::{ use gpui::{App, AppContext as _, AsyncApp, BorrowAppContext, Context, Entity, Global, WeakEntity};
App, AppContext as _, AsyncAppContext, BorrowAppContext, Context, Entity, Global, WeakEntity,
};
use language::LineEnding; use language::LineEnding;
use project::{Project, Worktree}; use project::{Project, Worktree};
use std::{ use std::{
@ -41,7 +39,7 @@ impl SemanticDb {
pub async fn new( pub async fn new(
db_path: PathBuf, db_path: PathBuf,
embedding_provider: Arc<dyn EmbeddingProvider>, embedding_provider: Arc<dyn EmbeddingProvider>,
cx: &mut AsyncAppContext, cx: &mut AsyncApp,
) -> Result<Self> { ) -> Result<Self> {
let db_connection = cx let db_connection = cx
.background_executor() .background_executor()
@ -85,7 +83,7 @@ impl SemanticDb {
pub async fn load_results( pub async fn load_results(
mut results: Vec<SearchResult>, mut results: Vec<SearchResult>,
fs: &Arc<dyn Fs>, fs: &Arc<dyn Fs>,
cx: &AsyncAppContext, cx: &AsyncApp,
) -> Result<Vec<LoadedSearchResult>> { ) -> Result<Vec<LoadedSearchResult>> {
let mut max_scores_by_path = HashMap::<_, (f32, usize)>::default(); let mut max_scores_by_path = HashMap::<_, (f32, usize)>::default();
for result in &results { for result in &results {

Some files were not shown because too many files have changed in this diff Show more