Rename model
based variable names to entity
(#24198)
## Context While looking through the client crate, I noticed that some of the old functions and variables were still using gpui::model name that was deprecated during the gpui3 transition. This PR renames those instances of model to entity to be more inline with gpui3. In addition, I also renamed `model` to `entity` in cases found by the below search terms given by @someone13574 - model = cx. - model: Entity - model: &Entity - OpenedModelHandle - model.update - model.upgrade - model = .*\.root (regex) - parent_model - model = cx.new - cx.spawn(move |model Release Notes: - N/A
This commit is contained in:
parent
27d1c689cf
commit
8c7096f7a6
40 changed files with 332 additions and 327 deletions
|
@ -894,15 +894,15 @@ impl LocalBufferStore {
|
|||
|
||||
impl BufferStore {
|
||||
pub fn init(client: &AnyProtoClient) {
|
||||
client.add_model_message_handler(Self::handle_buffer_reloaded);
|
||||
client.add_model_message_handler(Self::handle_buffer_saved);
|
||||
client.add_model_message_handler(Self::handle_update_buffer_file);
|
||||
client.add_model_request_handler(Self::handle_save_buffer);
|
||||
client.add_model_request_handler(Self::handle_blame_buffer);
|
||||
client.add_model_request_handler(Self::handle_reload_buffers);
|
||||
client.add_model_request_handler(Self::handle_get_permalink_to_line);
|
||||
client.add_model_request_handler(Self::handle_get_staged_text);
|
||||
client.add_model_message_handler(Self::handle_update_diff_base);
|
||||
client.add_entity_message_handler(Self::handle_buffer_reloaded);
|
||||
client.add_entity_message_handler(Self::handle_buffer_saved);
|
||||
client.add_entity_message_handler(Self::handle_update_buffer_file);
|
||||
client.add_entity_request_handler(Self::handle_save_buffer);
|
||||
client.add_entity_request_handler(Self::handle_blame_buffer);
|
||||
client.add_entity_request_handler(Self::handle_reload_buffers);
|
||||
client.add_entity_request_handler(Self::handle_get_permalink_to_line);
|
||||
client.add_entity_request_handler(Self::handle_get_staged_text);
|
||||
client.add_entity_message_handler(Self::handle_update_diff_base);
|
||||
}
|
||||
|
||||
/// Creates a buffer store, optionally retaining its buffers.
|
||||
|
|
|
@ -35,7 +35,7 @@ impl<E: 'static> DebouncedDelay<E> {
|
|||
self.cancel_channel = Some(sender);
|
||||
|
||||
let previous_task = self.task.take();
|
||||
self.task = Some(cx.spawn(move |model, mut cx| async move {
|
||||
self.task = Some(cx.spawn(move |entity, mut cx| async move {
|
||||
let mut timer = cx.background_executor().timer(delay).fuse();
|
||||
if let Some(previous_task) = previous_task {
|
||||
previous_task.await;
|
||||
|
@ -46,7 +46,7 @@ impl<E: 'static> DebouncedDelay<E> {
|
|||
_ = timer => {}
|
||||
}
|
||||
|
||||
if let Ok(task) = model.update(&mut cx, |project, cx| (func)(project, cx)) {
|
||||
if let Ok(task) = entity.update(&mut cx, |project, cx| (func)(project, cx)) {
|
||||
task.await;
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -387,18 +387,18 @@ impl ImageStoreImpl for Entity<LocalImageStore> {
|
|||
let LoadedBinaryFile { file, content } = load_file.await?;
|
||||
let image = create_gpui_image(content)?;
|
||||
|
||||
let model = cx.new(|cx| ImageItem {
|
||||
let entity = cx.new(|cx| ImageItem {
|
||||
id: cx.entity_id().as_non_zero_u64().into(),
|
||||
file: file.clone(),
|
||||
image,
|
||||
reload_task: None,
|
||||
})?;
|
||||
|
||||
let image_id = cx.read_entity(&model, |model, _| model.id)?;
|
||||
let image_id = cx.read_entity(&entity, |model, _| model.id)?;
|
||||
|
||||
this.update(&mut cx, |this, cx| {
|
||||
image_store.update(cx, |image_store, cx| {
|
||||
image_store.add_image(model.clone(), cx)
|
||||
image_store.add_image(entity.clone(), cx)
|
||||
})??;
|
||||
this.local_image_ids_by_path.insert(
|
||||
ProjectPath {
|
||||
|
@ -415,7 +415,7 @@ impl ImageStoreImpl for Entity<LocalImageStore> {
|
|||
anyhow::Ok(())
|
||||
})??;
|
||||
|
||||
Ok(model)
|
||||
Ok(entity)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -2854,37 +2854,37 @@ struct CoreSymbol {
|
|||
|
||||
impl LspStore {
|
||||
pub fn init(client: &AnyProtoClient) {
|
||||
client.add_model_request_handler(Self::handle_multi_lsp_query);
|
||||
client.add_model_request_handler(Self::handle_restart_language_servers);
|
||||
client.add_model_request_handler(Self::handle_cancel_language_server_work);
|
||||
client.add_model_message_handler(Self::handle_start_language_server);
|
||||
client.add_model_message_handler(Self::handle_update_language_server);
|
||||
client.add_model_message_handler(Self::handle_language_server_log);
|
||||
client.add_model_message_handler(Self::handle_update_diagnostic_summary);
|
||||
client.add_model_request_handler(Self::handle_format_buffers);
|
||||
client.add_model_request_handler(Self::handle_resolve_completion_documentation);
|
||||
client.add_model_request_handler(Self::handle_apply_code_action);
|
||||
client.add_model_request_handler(Self::handle_inlay_hints);
|
||||
client.add_model_request_handler(Self::handle_get_project_symbols);
|
||||
client.add_model_request_handler(Self::handle_resolve_inlay_hint);
|
||||
client.add_model_request_handler(Self::handle_open_buffer_for_symbol);
|
||||
client.add_model_request_handler(Self::handle_refresh_inlay_hints);
|
||||
client.add_model_request_handler(Self::handle_on_type_formatting);
|
||||
client.add_model_request_handler(Self::handle_apply_additional_edits_for_completion);
|
||||
client.add_model_request_handler(Self::handle_register_buffer_with_language_servers);
|
||||
client.add_model_request_handler(Self::handle_rename_project_entry);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetCodeActions>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetCompletions>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetHover>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetDefinition>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetDeclaration>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetTypeDefinition>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetDocumentHighlights>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<GetReferences>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<PrepareRename>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<PerformRename>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<lsp_ext_command::ExpandMacro>);
|
||||
client.add_model_request_handler(Self::handle_lsp_command::<LinkedEditingRange>);
|
||||
client.add_entity_request_handler(Self::handle_multi_lsp_query);
|
||||
client.add_entity_request_handler(Self::handle_restart_language_servers);
|
||||
client.add_entity_request_handler(Self::handle_cancel_language_server_work);
|
||||
client.add_entity_message_handler(Self::handle_start_language_server);
|
||||
client.add_entity_message_handler(Self::handle_update_language_server);
|
||||
client.add_entity_message_handler(Self::handle_language_server_log);
|
||||
client.add_entity_message_handler(Self::handle_update_diagnostic_summary);
|
||||
client.add_entity_request_handler(Self::handle_format_buffers);
|
||||
client.add_entity_request_handler(Self::handle_resolve_completion_documentation);
|
||||
client.add_entity_request_handler(Self::handle_apply_code_action);
|
||||
client.add_entity_request_handler(Self::handle_inlay_hints);
|
||||
client.add_entity_request_handler(Self::handle_get_project_symbols);
|
||||
client.add_entity_request_handler(Self::handle_resolve_inlay_hint);
|
||||
client.add_entity_request_handler(Self::handle_open_buffer_for_symbol);
|
||||
client.add_entity_request_handler(Self::handle_refresh_inlay_hints);
|
||||
client.add_entity_request_handler(Self::handle_on_type_formatting);
|
||||
client.add_entity_request_handler(Self::handle_apply_additional_edits_for_completion);
|
||||
client.add_entity_request_handler(Self::handle_register_buffer_with_language_servers);
|
||||
client.add_entity_request_handler(Self::handle_rename_project_entry);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetCodeActions>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetCompletions>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetHover>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetDefinition>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetDeclaration>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetTypeDefinition>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetDocumentHighlights>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetReferences>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<PrepareRename>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<PerformRename>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<lsp_ext_command::ExpandMacro>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<LinkedEditingRange>);
|
||||
}
|
||||
|
||||
pub fn as_remote(&self) -> Option<&RemoteLspStore> {
|
||||
|
|
|
@ -592,25 +592,25 @@ impl Project {
|
|||
Self::init_settings(cx);
|
||||
|
||||
let client: AnyProtoClient = client.clone().into();
|
||||
client.add_model_message_handler(Self::handle_add_collaborator);
|
||||
client.add_model_message_handler(Self::handle_update_project_collaborator);
|
||||
client.add_model_message_handler(Self::handle_remove_collaborator);
|
||||
client.add_model_message_handler(Self::handle_update_project);
|
||||
client.add_model_message_handler(Self::handle_unshare_project);
|
||||
client.add_model_request_handler(Self::handle_update_buffer);
|
||||
client.add_model_message_handler(Self::handle_update_worktree);
|
||||
client.add_model_request_handler(Self::handle_synchronize_buffers);
|
||||
client.add_entity_message_handler(Self::handle_add_collaborator);
|
||||
client.add_entity_message_handler(Self::handle_update_project_collaborator);
|
||||
client.add_entity_message_handler(Self::handle_remove_collaborator);
|
||||
client.add_entity_message_handler(Self::handle_update_project);
|
||||
client.add_entity_message_handler(Self::handle_unshare_project);
|
||||
client.add_entity_request_handler(Self::handle_update_buffer);
|
||||
client.add_entity_message_handler(Self::handle_update_worktree);
|
||||
client.add_entity_request_handler(Self::handle_synchronize_buffers);
|
||||
|
||||
client.add_model_request_handler(Self::handle_search_candidate_buffers);
|
||||
client.add_model_request_handler(Self::handle_open_buffer_by_id);
|
||||
client.add_model_request_handler(Self::handle_open_buffer_by_path);
|
||||
client.add_model_request_handler(Self::handle_open_new_buffer);
|
||||
client.add_model_message_handler(Self::handle_create_buffer_for_peer);
|
||||
client.add_entity_request_handler(Self::handle_search_candidate_buffers);
|
||||
client.add_entity_request_handler(Self::handle_open_buffer_by_id);
|
||||
client.add_entity_request_handler(Self::handle_open_buffer_by_path);
|
||||
client.add_entity_request_handler(Self::handle_open_new_buffer);
|
||||
client.add_entity_message_handler(Self::handle_create_buffer_for_peer);
|
||||
|
||||
client.add_model_request_handler(Self::handle_stage);
|
||||
client.add_model_request_handler(Self::handle_unstage);
|
||||
client.add_model_request_handler(Self::handle_commit);
|
||||
client.add_model_request_handler(Self::handle_open_commit_message_buffer);
|
||||
client.add_entity_request_handler(Self::handle_stage);
|
||||
client.add_entity_request_handler(Self::handle_unstage);
|
||||
client.add_entity_request_handler(Self::handle_commit);
|
||||
client.add_entity_request_handler(Self::handle_open_commit_message_buffer);
|
||||
|
||||
WorktreeStore::init(&client);
|
||||
BufferStore::init(&client);
|
||||
|
@ -893,13 +893,13 @@ impl Project {
|
|||
ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.lsp_store);
|
||||
ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.settings_observer);
|
||||
|
||||
ssh_proto.add_model_message_handler(Self::handle_create_buffer_for_peer);
|
||||
ssh_proto.add_model_message_handler(Self::handle_update_worktree);
|
||||
ssh_proto.add_model_message_handler(Self::handle_update_project);
|
||||
ssh_proto.add_model_message_handler(Self::handle_toast);
|
||||
ssh_proto.add_model_request_handler(Self::handle_language_server_prompt_request);
|
||||
ssh_proto.add_model_message_handler(Self::handle_hide_toast);
|
||||
ssh_proto.add_model_request_handler(Self::handle_update_buffer_from_ssh);
|
||||
ssh_proto.add_entity_message_handler(Self::handle_create_buffer_for_peer);
|
||||
ssh_proto.add_entity_message_handler(Self::handle_update_worktree);
|
||||
ssh_proto.add_entity_message_handler(Self::handle_update_project);
|
||||
ssh_proto.add_entity_message_handler(Self::handle_toast);
|
||||
ssh_proto.add_entity_request_handler(Self::handle_language_server_prompt_request);
|
||||
ssh_proto.add_entity_message_handler(Self::handle_hide_toast);
|
||||
ssh_proto.add_entity_request_handler(Self::handle_update_buffer_from_ssh);
|
||||
BufferStore::init(&ssh_proto);
|
||||
LspStore::init(&ssh_proto);
|
||||
SettingsObserver::init(&ssh_proto);
|
||||
|
@ -1110,17 +1110,19 @@ impl Project {
|
|||
.into_iter()
|
||||
.map(|s| match s {
|
||||
EntitySubscription::BufferStore(subscription) => {
|
||||
subscription.set_model(&buffer_store, &mut cx)
|
||||
subscription.set_entity(&buffer_store, &mut cx)
|
||||
}
|
||||
EntitySubscription::WorktreeStore(subscription) => {
|
||||
subscription.set_model(&worktree_store, &mut cx)
|
||||
subscription.set_entity(&worktree_store, &mut cx)
|
||||
}
|
||||
EntitySubscription::SettingsObserver(subscription) => {
|
||||
subscription.set_model(&settings_observer, &mut cx)
|
||||
subscription.set_entity(&settings_observer, &mut cx)
|
||||
}
|
||||
EntitySubscription::Project(subscription) => {
|
||||
subscription.set_entity(&this, &mut cx)
|
||||
}
|
||||
EntitySubscription::Project(subscription) => subscription.set_model(&this, &mut cx),
|
||||
EntitySubscription::LspStore(subscription) => {
|
||||
subscription.set_model(&lsp_store, &mut cx)
|
||||
subscription.set_entity(&lsp_store, &mut cx)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -1631,19 +1633,19 @@ impl Project {
|
|||
self.client_subscriptions.extend([
|
||||
self.client
|
||||
.subscribe_to_entity(project_id)?
|
||||
.set_model(&cx.entity(), &mut cx.to_async()),
|
||||
.set_entity(&cx.entity(), &mut cx.to_async()),
|
||||
self.client
|
||||
.subscribe_to_entity(project_id)?
|
||||
.set_model(&self.worktree_store, &mut cx.to_async()),
|
||||
.set_entity(&self.worktree_store, &mut cx.to_async()),
|
||||
self.client
|
||||
.subscribe_to_entity(project_id)?
|
||||
.set_model(&self.buffer_store, &mut cx.to_async()),
|
||||
.set_entity(&self.buffer_store, &mut cx.to_async()),
|
||||
self.client
|
||||
.subscribe_to_entity(project_id)?
|
||||
.set_model(&self.lsp_store, &mut cx.to_async()),
|
||||
.set_entity(&self.lsp_store, &mut cx.to_async()),
|
||||
self.client
|
||||
.subscribe_to_entity(project_id)?
|
||||
.set_model(&self.settings_observer, &mut cx.to_async()),
|
||||
.set_entity(&self.settings_observer, &mut cx.to_async()),
|
||||
]);
|
||||
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
|
|
|
@ -240,7 +240,7 @@ pub struct SettingsObserver {
|
|||
/// upstream.
|
||||
impl SettingsObserver {
|
||||
pub fn init(client: &AnyProtoClient) {
|
||||
client.add_model_message_handler(Self::handle_update_worktree_settings);
|
||||
client.add_entity_message_handler(Self::handle_update_worktree_settings);
|
||||
}
|
||||
|
||||
pub fn new_local(
|
||||
|
|
|
@ -51,7 +51,7 @@ impl EventEmitter<crate::Event> for TaskStore {}
|
|||
impl TaskStore {
|
||||
pub fn init(client: Option<&AnyProtoClient>) {
|
||||
if let Some(client) = client {
|
||||
client.add_model_request_handler(Self::handle_task_context_for_location);
|
||||
client.add_entity_request_handler(Self::handle_task_context_for_location);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ enum ToolchainStoreInner {
|
|||
impl EventEmitter<ToolchainStoreEvent> for ToolchainStore {}
|
||||
impl ToolchainStore {
|
||||
pub fn init(client: &AnyProtoClient) {
|
||||
client.add_model_request_handler(Self::handle_activate_toolchain);
|
||||
client.add_model_request_handler(Self::handle_list_toolchains);
|
||||
client.add_model_request_handler(Self::handle_active_toolchain);
|
||||
client.add_entity_request_handler(Self::handle_activate_toolchain);
|
||||
client.add_entity_request_handler(Self::handle_list_toolchains);
|
||||
client.add_entity_request_handler(Self::handle_active_toolchain);
|
||||
}
|
||||
|
||||
pub fn local(
|
||||
|
@ -37,16 +37,16 @@ impl ToolchainStore {
|
|||
project_environment: Entity<ProjectEnvironment>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let model = cx.new(|_| LocalToolchainStore {
|
||||
let entity = cx.new(|_| LocalToolchainStore {
|
||||
languages,
|
||||
worktree_store,
|
||||
project_environment,
|
||||
active_toolchains: Default::default(),
|
||||
});
|
||||
let subscription = cx.subscribe(&model, |_, _, e: &ToolchainStoreEvent, cx| {
|
||||
let subscription = cx.subscribe(&entity, |_, _, e: &ToolchainStoreEvent, cx| {
|
||||
cx.emit(e.clone())
|
||||
});
|
||||
Self(ToolchainStoreInner::Local(model, subscription))
|
||||
Self(ToolchainStoreInner::Local(entity, subscription))
|
||||
}
|
||||
pub(super) fn remote(project_id: u64, client: AnyProtoClient, cx: &mut App) -> Self {
|
||||
Self(ToolchainStoreInner::Remote(
|
||||
|
|
|
@ -72,13 +72,13 @@ impl EventEmitter<WorktreeStoreEvent> for WorktreeStore {}
|
|||
|
||||
impl WorktreeStore {
|
||||
pub fn init(client: &AnyProtoClient) {
|
||||
client.add_model_request_handler(Self::handle_create_project_entry);
|
||||
client.add_model_request_handler(Self::handle_copy_project_entry);
|
||||
client.add_model_request_handler(Self::handle_delete_project_entry);
|
||||
client.add_model_request_handler(Self::handle_expand_project_entry);
|
||||
client.add_model_request_handler(Self::handle_expand_all_for_project_entry);
|
||||
client.add_model_request_handler(Self::handle_git_branches);
|
||||
client.add_model_request_handler(Self::handle_update_branch);
|
||||
client.add_entity_request_handler(Self::handle_create_project_entry);
|
||||
client.add_entity_request_handler(Self::handle_copy_project_entry);
|
||||
client.add_entity_request_handler(Self::handle_delete_project_entry);
|
||||
client.add_entity_request_handler(Self::handle_expand_project_entry);
|
||||
client.add_entity_request_handler(Self::handle_expand_all_for_project_entry);
|
||||
client.add_entity_request_handler(Self::handle_git_branches);
|
||||
client.add_entity_request_handler(Self::handle_update_branch);
|
||||
}
|
||||
|
||||
pub fn local(retain_worktrees: bool, fs: Arc<dyn Fs>) -> Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue