Auto-fix clippy::collapsible_if violations (#36428)
Release Notes: - N/A
This commit is contained in:
parent
9e8ec72bd5
commit
8f567383e4
281 changed files with 6628 additions and 7089 deletions
|
@ -701,10 +701,9 @@ impl LocalLspStore {
|
|||
async move {
|
||||
this.update(&mut cx, |this, _| {
|
||||
if let Some(status) = this.language_server_statuses.get_mut(&server_id)
|
||||
&& let lsp::NumberOrString::String(token) = params.token
|
||||
{
|
||||
if let lsp::NumberOrString::String(token) = params.token {
|
||||
status.progress_tokens.insert(token);
|
||||
}
|
||||
status.progress_tokens.insert(token);
|
||||
}
|
||||
})?;
|
||||
|
||||
|
@ -1015,10 +1014,10 @@ impl LocalLspStore {
|
|||
}
|
||||
}
|
||||
LanguageServerState::Starting { startup, .. } => {
|
||||
if let Some(server) = startup.await {
|
||||
if let Some(shutdown) = server.shutdown() {
|
||||
shutdown.await;
|
||||
}
|
||||
if let Some(server) = startup.await
|
||||
&& let Some(shutdown) = server.shutdown()
|
||||
{
|
||||
shutdown.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2384,15 +2383,15 @@ impl LocalLspStore {
|
|||
return None;
|
||||
}
|
||||
if !only_register_servers.is_empty() {
|
||||
if let Some(server_id) = server_node.server_id() {
|
||||
if !only_register_servers.contains(&LanguageServerSelector::Id(server_id)) {
|
||||
return None;
|
||||
}
|
||||
if let Some(server_id) = server_node.server_id()
|
||||
&& !only_register_servers.contains(&LanguageServerSelector::Id(server_id))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
if let Some(name) = server_node.name() {
|
||||
if !only_register_servers.contains(&LanguageServerSelector::Name(name)) {
|
||||
return None;
|
||||
}
|
||||
if let Some(name) = server_node.name()
|
||||
&& !only_register_servers.contains(&LanguageServerSelector::Name(name))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2410,11 +2409,11 @@ impl LocalLspStore {
|
|||
cx,
|
||||
);
|
||||
|
||||
if let Some(state) = self.language_servers.get(&server_id) {
|
||||
if let Ok(uri) = uri {
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
}
|
||||
if let Some(state) = self.language_servers.get(&server_id)
|
||||
&& let Ok(uri) = uri
|
||||
{
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
server_id
|
||||
};
|
||||
|
||||
|
@ -3844,13 +3843,13 @@ impl LspStore {
|
|||
}
|
||||
BufferStoreEvent::BufferChangedFilePath { buffer, old_file } => {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
if let Some(local) = self.as_local_mut() {
|
||||
if let Some(old_file) = File::from_dyn(old_file.as_ref()) {
|
||||
local.reset_buffer(buffer, old_file, cx);
|
||||
if let Some(local) = self.as_local_mut()
|
||||
&& let Some(old_file) = File::from_dyn(old_file.as_ref())
|
||||
{
|
||||
local.reset_buffer(buffer, old_file, cx);
|
||||
|
||||
if local.registered_buffers.contains_key(&buffer_id) {
|
||||
local.unregister_old_buffer_from_language_servers(buffer, old_file, cx);
|
||||
}
|
||||
if local.registered_buffers.contains_key(&buffer_id) {
|
||||
local.unregister_old_buffer_from_language_servers(buffer, old_file, cx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4201,14 +4200,12 @@ impl LspStore {
|
|||
if local
|
||||
.registered_buffers
|
||||
.contains_key(&buffer.read(cx).remote_id())
|
||||
{
|
||||
if let Some(file_url) =
|
||||
&& let Some(file_url) =
|
||||
file_path_to_lsp_url(&f.abs_path(cx)).log_err()
|
||||
{
|
||||
local.unregister_buffer_from_language_servers(
|
||||
&buffer, &file_url, cx,
|
||||
);
|
||||
}
|
||||
{
|
||||
local.unregister_buffer_from_language_servers(
|
||||
&buffer, &file_url, cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4306,20 +4303,13 @@ impl LspStore {
|
|||
let buffer = buffer_entity.read(cx);
|
||||
let buffer_file = buffer.file().cloned();
|
||||
let buffer_id = buffer.remote_id();
|
||||
if let Some(local_store) = self.as_local_mut() {
|
||||
if local_store.registered_buffers.contains_key(&buffer_id) {
|
||||
if let Some(abs_path) =
|
||||
File::from_dyn(buffer_file.as_ref()).map(|file| file.abs_path(cx))
|
||||
{
|
||||
if let Some(file_url) = file_path_to_lsp_url(&abs_path).log_err() {
|
||||
local_store.unregister_buffer_from_language_servers(
|
||||
buffer_entity,
|
||||
&file_url,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(local_store) = self.as_local_mut()
|
||||
&& local_store.registered_buffers.contains_key(&buffer_id)
|
||||
&& let Some(abs_path) =
|
||||
File::from_dyn(buffer_file.as_ref()).map(|file| file.abs_path(cx))
|
||||
&& let Some(file_url) = file_path_to_lsp_url(&abs_path).log_err()
|
||||
{
|
||||
local_store.unregister_buffer_from_language_servers(buffer_entity, &file_url, cx);
|
||||
}
|
||||
buffer_entity.update(cx, |buffer, cx| {
|
||||
if buffer.language().map_or(true, |old_language| {
|
||||
|
@ -4336,33 +4326,28 @@ impl LspStore {
|
|||
let worktree_id = if let Some(file) = buffer_file {
|
||||
let worktree = file.worktree.clone();
|
||||
|
||||
if let Some(local) = self.as_local_mut() {
|
||||
if local.registered_buffers.contains_key(&buffer_id) {
|
||||
local.register_buffer_with_language_servers(
|
||||
buffer_entity,
|
||||
HashSet::default(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
if let Some(local) = self.as_local_mut()
|
||||
&& local.registered_buffers.contains_key(&buffer_id)
|
||||
{
|
||||
local.register_buffer_with_language_servers(buffer_entity, HashSet::default(), cx);
|
||||
}
|
||||
Some(worktree.read(cx).id())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if settings.prettier.allowed {
|
||||
if let Some(prettier_plugins) = prettier_store::prettier_plugins_for_language(&settings)
|
||||
{
|
||||
let prettier_store = self.as_local().map(|s| s.prettier_store.clone());
|
||||
if let Some(prettier_store) = prettier_store {
|
||||
prettier_store.update(cx, |prettier_store, cx| {
|
||||
prettier_store.install_default_prettier(
|
||||
worktree_id,
|
||||
prettier_plugins.iter().map(|s| Arc::from(s.as_str())),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
if settings.prettier.allowed
|
||||
&& let Some(prettier_plugins) = prettier_store::prettier_plugins_for_language(&settings)
|
||||
{
|
||||
let prettier_store = self.as_local().map(|s| s.prettier_store.clone());
|
||||
if let Some(prettier_store) = prettier_store {
|
||||
prettier_store.update(cx, |prettier_store, cx| {
|
||||
prettier_store.install_default_prettier(
|
||||
worktree_id,
|
||||
prettier_plugins.iter().map(|s| Arc::from(s.as_str())),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4381,26 +4366,25 @@ impl LspStore {
|
|||
}
|
||||
|
||||
pub(crate) fn send_diagnostic_summaries(&self, worktree: &mut Worktree) {
|
||||
if let Some((client, downstream_project_id)) = self.downstream_client.clone() {
|
||||
if let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id()) {
|
||||
let mut summaries =
|
||||
diangostic_summaries
|
||||
if let Some((client, downstream_project_id)) = self.downstream_client.clone()
|
||||
&& let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id())
|
||||
{
|
||||
let mut summaries = diangostic_summaries
|
||||
.into_iter()
|
||||
.flat_map(|(path, summaries)| {
|
||||
summaries
|
||||
.into_iter()
|
||||
.flat_map(|(path, summaries)| {
|
||||
summaries
|
||||
.into_iter()
|
||||
.map(|(server_id, summary)| summary.to_proto(*server_id, path))
|
||||
});
|
||||
if let Some(summary) = summaries.next() {
|
||||
client
|
||||
.send(proto::UpdateDiagnosticSummary {
|
||||
project_id: downstream_project_id,
|
||||
worktree_id: worktree.id().to_proto(),
|
||||
summary: Some(summary),
|
||||
more_summaries: summaries.collect(),
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
.map(|(server_id, summary)| summary.to_proto(*server_id, path))
|
||||
});
|
||||
if let Some(summary) = summaries.next() {
|
||||
client
|
||||
.send(proto::UpdateDiagnosticSummary {
|
||||
project_id: downstream_project_id,
|
||||
worktree_id: worktree.id().to_proto(),
|
||||
summary: Some(summary),
|
||||
more_summaries: summaries.collect(),
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4730,11 +4714,11 @@ impl LspStore {
|
|||
&language.name(),
|
||||
cx,
|
||||
);
|
||||
if let Some(state) = local.language_servers.get(&server_id) {
|
||||
if let Ok(uri) = uri {
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
}
|
||||
if let Some(state) = local.language_servers.get(&server_id)
|
||||
&& let Ok(uri) = uri
|
||||
{
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
server_id
|
||||
});
|
||||
|
||||
|
@ -4805,8 +4789,8 @@ impl LspStore {
|
|||
LocalLspStore::try_resolve_code_action(&lang_server, &mut action)
|
||||
.await
|
||||
.context("resolving a code action")?;
|
||||
if let Some(edit) = action.lsp_action.edit() {
|
||||
if edit.changes.is_some() || edit.document_changes.is_some() {
|
||||
if let Some(edit) = action.lsp_action.edit()
|
||||
&& (edit.changes.is_some() || edit.document_changes.is_some()) {
|
||||
return LocalLspStore::deserialize_workspace_edit(
|
||||
this.upgrade().context("no app present")?,
|
||||
edit.clone(),
|
||||
|
@ -4817,7 +4801,6 @@ impl LspStore {
|
|||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(command) = action.lsp_action.command() {
|
||||
let server_capabilities = lang_server.capabilities();
|
||||
|
@ -5736,28 +5719,28 @@ impl LspStore {
|
|||
let version_queried_for = buffer.read(cx).version();
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
|
||||
if let Some(cached_data) = self.lsp_code_lens.get(&buffer_id) {
|
||||
if !version_queried_for.changed_since(&cached_data.lens_for_version) {
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.lens.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
return Task::ready(Ok(cached_data.lens.values().flatten().cloned().collect()))
|
||||
.shared();
|
||||
}
|
||||
if let Some(cached_data) = self.lsp_code_lens.get(&buffer_id)
|
||||
&& !version_queried_for.changed_since(&cached_data.lens_for_version)
|
||||
{
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.lens.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
return Task::ready(Ok(cached_data.lens.values().flatten().cloned().collect()))
|
||||
.shared();
|
||||
}
|
||||
}
|
||||
|
||||
let lsp_data = self.lsp_code_lens.entry(buffer_id).or_default();
|
||||
if let Some((updating_for, running_update)) = &lsp_data.update {
|
||||
if !version_queried_for.changed_since(updating_for) {
|
||||
return running_update.clone();
|
||||
}
|
||||
if let Some((updating_for, running_update)) = &lsp_data.update
|
||||
&& !version_queried_for.changed_since(updating_for)
|
||||
{
|
||||
return running_update.clone();
|
||||
}
|
||||
let buffer = buffer.clone();
|
||||
let query_version_queried_for = version_queried_for.clone();
|
||||
|
@ -6372,11 +6355,11 @@ impl LspStore {
|
|||
.old_replace_start
|
||||
.and_then(deserialize_anchor)
|
||||
.zip(response.old_replace_end.and_then(deserialize_anchor));
|
||||
if let Some((old_replace_start, old_replace_end)) = replace_range {
|
||||
if !response.new_text.is_empty() {
|
||||
completion.new_text = response.new_text;
|
||||
completion.replace_range = old_replace_start..old_replace_end;
|
||||
}
|
||||
if let Some((old_replace_start, old_replace_end)) = replace_range
|
||||
&& !response.new_text.is_empty()
|
||||
{
|
||||
completion.new_text = response.new_text;
|
||||
completion.replace_range = old_replace_start..old_replace_end;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -6751,33 +6734,33 @@ impl LspStore {
|
|||
LspFetchStrategy::UseCache {
|
||||
known_cache_version,
|
||||
} => {
|
||||
if let Some(cached_data) = self.lsp_document_colors.get(&buffer_id) {
|
||||
if !version_queried_for.changed_since(&cached_data.colors_for_version) {
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.colors.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
if Some(cached_data.cache_version) == known_cache_version {
|
||||
return None;
|
||||
} else {
|
||||
return Some(
|
||||
Task::ready(Ok(DocumentColors {
|
||||
colors: cached_data
|
||||
.colors
|
||||
.values()
|
||||
.flatten()
|
||||
.cloned()
|
||||
.collect(),
|
||||
cache_version: Some(cached_data.cache_version),
|
||||
}))
|
||||
.shared(),
|
||||
);
|
||||
}
|
||||
if let Some(cached_data) = self.lsp_document_colors.get(&buffer_id)
|
||||
&& !version_queried_for.changed_since(&cached_data.colors_for_version)
|
||||
{
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.colors.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
if Some(cached_data.cache_version) == known_cache_version {
|
||||
return None;
|
||||
} else {
|
||||
return Some(
|
||||
Task::ready(Ok(DocumentColors {
|
||||
colors: cached_data
|
||||
.colors
|
||||
.values()
|
||||
.flatten()
|
||||
.cloned()
|
||||
.collect(),
|
||||
cache_version: Some(cached_data.cache_version),
|
||||
}))
|
||||
.shared(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6785,10 +6768,10 @@ impl LspStore {
|
|||
}
|
||||
|
||||
let lsp_data = self.lsp_document_colors.entry(buffer_id).or_default();
|
||||
if let Some((updating_for, running_update)) = &lsp_data.colors_update {
|
||||
if !version_queried_for.changed_since(updating_for) {
|
||||
return Some(running_update.clone());
|
||||
}
|
||||
if let Some((updating_for, running_update)) = &lsp_data.colors_update
|
||||
&& !version_queried_for.changed_since(updating_for)
|
||||
{
|
||||
return Some(running_update.clone());
|
||||
}
|
||||
let query_version_queried_for = version_queried_for.clone();
|
||||
let new_task = cx
|
||||
|
@ -8785,12 +8768,11 @@ impl LspStore {
|
|||
if summary.is_empty() {
|
||||
if let Some(worktree_summaries) =
|
||||
lsp_store.diagnostic_summaries.get_mut(&worktree_id)
|
||||
&& let Some(summaries) = worktree_summaries.get_mut(&path)
|
||||
{
|
||||
if let Some(summaries) = worktree_summaries.get_mut(&path) {
|
||||
summaries.remove(&server_id);
|
||||
if summaries.is_empty() {
|
||||
worktree_summaries.remove(&path);
|
||||
}
|
||||
summaries.remove(&server_id);
|
||||
if summaries.is_empty() {
|
||||
worktree_summaries.remove(&path);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -9491,10 +9473,10 @@ impl LspStore {
|
|||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) {
|
||||
if let Some(work) = status.pending_work.remove(&token) {
|
||||
if !work.is_disk_based_diagnostics_progress {
|
||||
cx.emit(LspStoreEvent::RefreshInlayHints);
|
||||
}
|
||||
if let Some(work) = status.pending_work.remove(&token)
|
||||
&& !work.is_disk_based_diagnostics_progress
|
||||
{
|
||||
cx.emit(LspStoreEvent::RefreshInlayHints);
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -10288,10 +10270,10 @@ impl LspStore {
|
|||
None => None,
|
||||
};
|
||||
|
||||
if let Some(server) = server {
|
||||
if let Some(shutdown) = server.shutdown() {
|
||||
shutdown.await;
|
||||
}
|
||||
if let Some(server) = server
|
||||
&& let Some(shutdown) = server.shutdown()
|
||||
{
|
||||
shutdown.await;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10565,18 +10547,18 @@ impl LspStore {
|
|||
for buffer in buffers {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
language_servers_to_stop.extend(local.language_server_ids_for_buffer(buffer, cx));
|
||||
if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx)) {
|
||||
if covered_worktrees.insert(worktree_id) {
|
||||
language_server_names_to_stop.retain(|name| {
|
||||
let old_ids_count = language_servers_to_stop.len();
|
||||
let all_language_servers_with_this_name = local
|
||||
.language_server_ids
|
||||
.iter()
|
||||
.filter_map(|(seed, state)| seed.name.eq(name).then(|| state.id));
|
||||
language_servers_to_stop.extend(all_language_servers_with_this_name);
|
||||
old_ids_count == language_servers_to_stop.len()
|
||||
});
|
||||
}
|
||||
if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx))
|
||||
&& covered_worktrees.insert(worktree_id)
|
||||
{
|
||||
language_server_names_to_stop.retain(|name| {
|
||||
let old_ids_count = language_servers_to_stop.len();
|
||||
let all_language_servers_with_this_name = local
|
||||
.language_server_ids
|
||||
.iter()
|
||||
.filter_map(|(seed, state)| seed.name.eq(name).then(|| state.id));
|
||||
language_servers_to_stop.extend(all_language_servers_with_this_name);
|
||||
old_ids_count == language_servers_to_stop.len()
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -11081,10 +11063,10 @@ impl LspStore {
|
|||
if let Some((LanguageServerState::Running { server, .. }, status)) = server.zip(status)
|
||||
{
|
||||
for (token, progress) in &status.pending_work {
|
||||
if let Some(token_to_cancel) = token_to_cancel.as_ref() {
|
||||
if token != token_to_cancel {
|
||||
continue;
|
||||
}
|
||||
if let Some(token_to_cancel) = token_to_cancel.as_ref()
|
||||
&& token != token_to_cancel
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if progress.is_cancellable {
|
||||
server
|
||||
|
@ -11191,38 +11173,36 @@ impl LspStore {
|
|||
for server_id in &language_server_ids {
|
||||
if let Some(LanguageServerState::Running { server, .. }) =
|
||||
local.language_servers.get(server_id)
|
||||
{
|
||||
if let Some(watched_paths) = local
|
||||
&& let Some(watched_paths) = local
|
||||
.language_server_watched_paths
|
||||
.get(server_id)
|
||||
.and_then(|paths| paths.worktree_paths.get(&worktree_id))
|
||||
{
|
||||
let params = lsp::DidChangeWatchedFilesParams {
|
||||
changes: changes
|
||||
.iter()
|
||||
.filter_map(|(path, _, change)| {
|
||||
if !watched_paths.is_match(path) {
|
||||
return None;
|
||||
}
|
||||
let typ = match change {
|
||||
PathChange::Loaded => return None,
|
||||
PathChange::Added => lsp::FileChangeType::CREATED,
|
||||
PathChange::Removed => lsp::FileChangeType::DELETED,
|
||||
PathChange::Updated => lsp::FileChangeType::CHANGED,
|
||||
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
|
||||
};
|
||||
Some(lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
|
||||
typ,
|
||||
})
|
||||
{
|
||||
let params = lsp::DidChangeWatchedFilesParams {
|
||||
changes: changes
|
||||
.iter()
|
||||
.filter_map(|(path, _, change)| {
|
||||
if !watched_paths.is_match(path) {
|
||||
return None;
|
||||
}
|
||||
let typ = match change {
|
||||
PathChange::Loaded => return None,
|
||||
PathChange::Added => lsp::FileChangeType::CREATED,
|
||||
PathChange::Removed => lsp::FileChangeType::DELETED,
|
||||
PathChange::Updated => lsp::FileChangeType::CHANGED,
|
||||
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
|
||||
};
|
||||
Some(lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
|
||||
typ,
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
if !params.changes.is_empty() {
|
||||
server
|
||||
.notify::<lsp::notification::DidChangeWatchedFiles>(¶ms)
|
||||
.ok();
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
if !params.changes.is_empty() {
|
||||
server
|
||||
.notify::<lsp::notification::DidChangeWatchedFiles>(¶ms)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue