Finish ???-ing project2.rs

This commit is contained in:
Kirill Bulatov 2023-10-24 16:35:34 +02:00
parent 11953e613b
commit 1ad7f3a16d
2 changed files with 89 additions and 70 deletions

View file

@ -800,7 +800,7 @@ impl Project {
this.set_collaborators_from_proto(response.payload.collaborators, cx)?; this.set_collaborators_from_proto(response.payload.collaborators, cx)?;
this.client_subscriptions.push(subscription); this.client_subscriptions.push(subscription);
anyhow::Ok(()) anyhow::Ok(())
})?; })??;
Ok(this) Ok(this)
} }
@ -1832,7 +1832,8 @@ impl Project {
(worktree.read(cx).id(), language_server_name), (worktree.read(cx).id(), language_server_name),
language_server_id, language_server_id,
); );
}); })
.ok();
(worktree, PathBuf::new()) (worktree, PathBuf::new())
}; };
@ -1915,7 +1916,7 @@ impl Project {
if let Some(old_file) = &old_file { if let Some(old_file) = &old_file {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.unregister_buffer_from_language_servers(&buffer, old_file, cx); this.unregister_buffer_from_language_servers(&buffer, old_file, cx);
}); })?;
} }
let (worktree, path) = worktree_task.await?; let (worktree, path) = worktree_task.await?;
worktree worktree
@ -1930,7 +1931,7 @@ impl Project {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.detect_language_for_buffer(&buffer, cx); this.detect_language_for_buffer(&buffer, cx);
this.register_buffer_with_language_servers(&buffer, cx); this.register_buffer_with_language_servers(&buffer, cx);
}); })?;
Ok(()) Ok(())
}) })
} }
@ -2241,7 +2242,7 @@ impl Project {
is_local, is_local,
&mut cx, &mut cx,
) )
.await; .await?;
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, _| {
if let Some(project_id) = this.remote_id() { if let Some(project_id) = this.remote_id() {
@ -2253,7 +2254,7 @@ impl Project {
}) })
.log_err(); .log_err();
} }
}); })?;
} }
} }
} }
@ -2265,7 +2266,7 @@ impl Project {
is_local, is_local,
&mut cx, &mut cx,
) )
.await; .await?;
} }
Ok(()) Ok(())
@ -2446,7 +2447,7 @@ impl Project {
}, },
) )
.ok(); .ok();
}); }).ok();
} }
}); });
*simulate_disk_based_diagnostics_completion = Some(task); *simulate_disk_based_diagnostics_completion = Some(task);
@ -2587,22 +2588,29 @@ impl Project {
let reload_count = languages.reload_count(); let reload_count = languages.reload_count();
if reload_count > prev_reload_count { if reload_count > prev_reload_count {
prev_reload_count = reload_count; prev_reload_count = reload_count;
project.update(&mut cx, |this, cx| { project
.update(&mut cx, |this, cx| {
let buffers = this let buffers = this
.opened_buffers .opened_buffers
.values() .values()
.filter_map(|b| b.upgrade()) .filter_map(|b| b.upgrade())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for buffer in buffers { for buffer in buffers {
if let Some(f) = File::from_dyn(buffer.read(cx).file()).cloned() { if let Some(f) = File::from_dyn(buffer.read(cx).file()).cloned()
this.unregister_buffer_from_language_servers(&buffer, &f, cx); {
buffer.update(cx, |buffer, cx| buffer.set_language(None, cx)); this.unregister_buffer_from_language_servers(
&buffer, &f, cx,
);
buffer
.update(cx, |buffer, cx| buffer.set_language(None, cx));
} }
} }
}); })
.ok();
} }
project.update(&mut cx, |project, cx| { project
.update(&mut cx, |project, cx| {
let mut plain_text_buffers = Vec::new(); let mut plain_text_buffers = Vec::new();
let mut buffers_with_unknown_injections = Vec::new(); let mut buffers_with_unknown_injections = Vec::new();
for buffer in project.opened_buffers.values() { for buffer in project.opened_buffers.values() {
@ -2626,7 +2634,8 @@ impl Project {
for buffer in buffers_with_unknown_injections { for buffer in buffers_with_unknown_injections {
buffer.update(cx, |buffer, cx| buffer.reparse(cx)); buffer.update(cx, |buffer, cx| buffer.reparse(cx));
} }
}); })
.ok();
} }
} }
}) })
@ -2834,7 +2843,8 @@ impl Project {
installation_test_binary, installation_test_binary,
cx, cx,
) )
}); })
.ok();
} }
} }
@ -2948,7 +2958,7 @@ impl Project {
key, key,
cx, cx,
) )
})?; })??;
Ok(Some(language_server)) Ok(Some(language_server))
} }
@ -2983,7 +2993,8 @@ impl Project {
cx, cx,
) )
.log_err(); .log_err();
}); })
.ok();
} }
} }
}) })
@ -3111,7 +3122,8 @@ impl Project {
disk_based_diagnostics_progress_token.clone(), disk_based_diagnostics_progress_token.clone(),
cx, cx,
); );
}); })
.ok();
} }
}) })
.detach(); .detach();
@ -3321,7 +3333,8 @@ impl Project {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.language_server_statuses.remove(&server_id); this.language_server_statuses.remove(&server_id);
cx.notify(); cx.notify();
}); })
.ok();
} }
(root_path, orphaned_worktrees) (root_path, orphaned_worktrees)
@ -3411,7 +3424,8 @@ impl Project {
} }
} }
} }
}); })
.ok();
}) })
.detach(); .detach();
} }
@ -3757,7 +3771,7 @@ impl Project {
this.last_workspace_edits_by_language_server this.last_workspace_edits_by_language_server
.insert(server_id, transaction); .insert(server_id, transaction);
} }
}); })?;
Ok(lsp2::ApplyWorkspaceEditResponse { Ok(lsp2::ApplyWorkspaceEditResponse {
applied: true, applied: true,
failed_change: None, failed_change: None,
@ -4061,7 +4075,7 @@ impl Project {
} }
project_transaction.0.insert(cx.handle(), transaction); project_transaction.0.insert(cx.handle(), transaction);
} }
}); })?;
} }
Ok(project_transaction) Ok(project_transaction)
@ -4097,7 +4111,7 @@ impl Project {
this.buffers_being_formatted this.buffers_being_formatted
.insert(buffer.read(cx).remote_id()) .insert(buffer.read(cx).remote_id())
}); });
}); })?;
let _cleanup = defer({ let _cleanup = defer({
let this = this.clone(); let this = this.clone();
@ -4109,7 +4123,7 @@ impl Project {
this.buffers_being_formatted this.buffers_being_formatted
.remove(&buffer.read(cx).remote_id()); .remove(&buffer.read(cx).remote_id());
} }
}); }).ok();
} }
}); });
@ -4305,7 +4319,7 @@ impl Project {
} }
project_transaction.0.insert(buffer.clone(), transaction); project_transaction.0.insert(buffer.clone(), transaction);
} }
}); })?;
} }
Ok(project_transaction) Ok(project_transaction)
@ -4779,7 +4793,7 @@ impl Project {
cx, cx,
)); ));
} }
}); })?;
let mut completions = Vec::new(); let mut completions = Vec::new();
for task in tasks { for task in tasks {
@ -4896,7 +4910,7 @@ impl Project {
if push_to_history { if push_to_history {
buffer_handle.update(&mut cx, |buffer, _| { buffer_handle.update(&mut cx, |buffer, _| {
buffer.push_transaction(transaction.clone(), Instant::now()); buffer.push_transaction(transaction.clone(), Instant::now());
}); })?;
} }
Ok(Some(transaction)) Ok(Some(transaction))
} else { } else {
@ -4985,7 +4999,7 @@ impl Project {
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, _| {
this.last_workspace_edits_by_language_server this.last_workspace_edits_by_language_server
.remove(&lang_server.server_id()); .remove(&lang_server.server_id());
}); })?;
let result = lang_server let result = lang_server
.request::<lsp2::request::ExecuteCommand>(lsp2::ExecuteCommandParams { .request::<lsp2::request::ExecuteCommand>(lsp2::ExecuteCommandParams {
@ -5046,7 +5060,7 @@ impl Project {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.buffers_being_formatted this.buffers_being_formatted
.insert(buffer.read(cx).remote_id()) .insert(buffer.read(cx).remote_id())
}); })?;
let _cleanup = defer({ let _cleanup = defer({
let this = this.clone(); let this = this.clone();
@ -5056,7 +5070,8 @@ impl Project {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.buffers_being_formatted this.buffers_being_formatted
.remove(&closure_buffer.read(cx).remote_id()); .remove(&closure_buffer.read(cx).remote_id());
}); })
.ok();
} }
}); });
@ -6022,10 +6037,11 @@ impl Project {
project.update(&mut cx, |project, _| { project.update(&mut cx, |project, _| {
project.loading_local_worktrees.remove(&path); project.loading_local_worktrees.remove(&path);
}); })?;
let worktree = worktree?; let worktree = worktree?;
project.update(&mut cx, |project, cx| project.add_worktree(&worktree, cx)); project
.update(&mut cx, |project, cx| project.add_worktree(&worktree, cx))?;
Ok(worktree) Ok(worktree)
} }
.map_err(Arc::new) .map_err(Arc::new)
@ -6445,7 +6461,8 @@ impl Project {
} }
} }
}); });
}); })
.ok();
}) })
.detach(); .detach();
} }
@ -6649,7 +6666,7 @@ impl Project {
this.collaborators this.collaborators
.insert(collaborator.peer_id, collaborator); .insert(collaborator.peer_id, collaborator);
cx.notify(); cx.notify();
}); })?;
Ok(()) Ok(())
} }
@ -6879,7 +6896,7 @@ impl Project {
) -> 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);
this.update(&mut cx, |_, cx| cx.emit(Event::DeletedEntry(entry_id))); this.update(&mut cx, |_, cx| cx.emit(Event::DeletedEntry(entry_id)))?;
let worktree = this.update(&mut cx, |this, cx| { let worktree = this.update(&mut cx, |this, cx| {
this.worktree_for_entry(entry_id, cx) this.worktree_for_entry(entry_id, cx)
@ -6975,7 +6992,7 @@ impl Project {
}, },
); );
cx.notify(); cx.notify();
}); })?;
Ok(()) Ok(())
} }
@ -7346,7 +7363,7 @@ impl Project {
.detach(); .detach();
} }
} }
}); })?;
Ok(response) Ok(response)
} }
@ -7803,7 +7820,7 @@ impl Project {
if push_to_history { if push_to_history {
buffer.update(&mut cx, |buffer, _| { buffer.update(&mut cx, |buffer, _| {
buffer.push_transaction(transaction.clone(), Instant::now()); buffer.push_transaction(transaction.clone(), Instant::now());
}); })?;
} }
} }
@ -8524,7 +8541,8 @@ impl Project {
project project
.prettier_instances .prettier_instances
.insert((worktree_id, prettier_dir), new_prettier_task.clone()); .insert((worktree_id, prettier_dir), new_prettier_task.clone());
}); })
.ok();
Some(new_prettier_task) Some(new_prettier_task)
}) })
} else if self.remote_id().is_some() { } else if self.remote_id().is_some() {

View file

@ -358,7 +358,8 @@ impl Worktree {
} }
} }
cx.notify(); cx.notify();
}); })
.ok();
} }
}) })
.detach(); .detach();
@ -962,7 +963,7 @@ impl LocalWorktree {
if has_changed_file { if has_changed_file {
buffer.file_updated(new_file, cx).detach(); buffer.file_updated(new_file, cx).detach();
} }
}); })?;
} }
if let Some(project_id) = project_id { if let Some(project_id) = project_id {
@ -977,7 +978,7 @@ impl LocalWorktree {
buffer_handle.update(&mut cx, |buffer, cx| { buffer_handle.update(&mut cx, |buffer, cx| {
buffer.did_save(version.clone(), fingerprint, entry.mtime, cx); buffer.did_save(version.clone(), fingerprint, entry.mtime, cx);
}); })?;
Ok(()) Ok(())
}) })
@ -1453,7 +1454,7 @@ impl RemoteWorktree {
let mut snapshot = worktree.background_snapshot.lock(); let mut snapshot = worktree.background_snapshot.lock();
snapshot.delete_entry(id); snapshot.delete_entry(id);
worktree.snapshot = snapshot.clone(); worktree.snapshot = snapshot.clone();
}); })?;
Ok(()) Ok(())
}) })
} }