use join_all to build partial symbols and completions asynchronously
This commit is contained in:
parent
602fe14aa4
commit
0872e9b1a7
1 changed files with 40 additions and 37 deletions
|
@ -3311,7 +3311,6 @@ impl Project {
|
||||||
return Ok(Default::default());
|
return Ok(Default::default());
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(isaac): also use join_all
|
|
||||||
struct PartialSymbol {
|
struct PartialSymbol {
|
||||||
source_worktree_id: WorktreeId,
|
source_worktree_id: WorktreeId,
|
||||||
worktree_id: WorktreeId,
|
worktree_id: WorktreeId,
|
||||||
|
@ -3366,6 +3365,7 @@ impl Project {
|
||||||
|
|
||||||
let mut symbols = Vec::new();
|
let mut symbols = Vec::new();
|
||||||
for ps in partial_symbols.into_iter() {
|
for ps in partial_symbols.into_iter() {
|
||||||
|
symbols.push(async move {
|
||||||
let label = match ps.language {
|
let label = match ps.language {
|
||||||
Some(language) => language.label_for_symbol(&ps.name, ps.kind).await,
|
Some(language) => language.label_for_symbol(&ps.name, ps.kind).await,
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -3374,7 +3374,7 @@ impl Project {
|
||||||
|
|
||||||
let language_server_name = ps.adapter.name().await;
|
let language_server_name = ps.adapter.name().await;
|
||||||
|
|
||||||
symbols.push(Symbol {
|
Symbol {
|
||||||
source_worktree_id: ps.source_worktree_id,
|
source_worktree_id: ps.source_worktree_id,
|
||||||
worktree_id: ps.worktree_id,
|
worktree_id: ps.worktree_id,
|
||||||
language_server_name,
|
language_server_name,
|
||||||
|
@ -3384,10 +3384,11 @@ impl Project {
|
||||||
path: ps.path,
|
path: ps.path,
|
||||||
range: ps.range,
|
range: ps.range,
|
||||||
signature: ps.signature,
|
signature: ps.signature,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(symbols)
|
Ok(futures::future::join_all(symbols).await)
|
||||||
})
|
})
|
||||||
} else if let Some(project_id) = self.remote_id() {
|
} else if let Some(project_id) = self.remote_id() {
|
||||||
let request = self.client.request(proto::GetProjectSymbols {
|
let request = self.client.request(proto::GetProjectSymbols {
|
||||||
|
@ -3678,6 +3679,7 @@ impl Project {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
|
|
||||||
for pc in partial_completions.into_iter() {
|
for pc in partial_completions.into_iter() {
|
||||||
|
result.push(async move {
|
||||||
let label = match pc.language.as_ref() {
|
let label = match pc.language.as_ref() {
|
||||||
Some(l) => l.label_for_completion(&pc.lsp_completion).await,
|
Some(l) => l.label_for_completion(&pc.lsp_completion).await,
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -3696,10 +3698,11 @@ impl Project {
|
||||||
lsp_completion: pc.lsp_completion,
|
lsp_completion: pc.lsp_completion,
|
||||||
};
|
};
|
||||||
|
|
||||||
result.push(completion);
|
completion
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(result)
|
Ok(futures::future::join_all(result).await)
|
||||||
})
|
})
|
||||||
} else if let Some(project_id) = self.remote_id() {
|
} else if let Some(project_id) = self.remote_id() {
|
||||||
let rpc = self.client.clone();
|
let rpc = self.client.clone();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue