mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
feat(lsp): add workspace symbol provider (#12787)
This commit is contained in:
parent
3abe31252e
commit
bf5657cd59
8 changed files with 303 additions and 24 deletions
|
@ -2270,6 +2270,44 @@ impl Inner {
|
|||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
async fn symbol(
|
||||
&mut self,
|
||||
params: WorkspaceSymbolParams,
|
||||
) -> LspResult<Option<Vec<SymbolInformation>>> {
|
||||
let mark = self.performance.mark("symbol", Some(¶ms));
|
||||
|
||||
let req = tsc::RequestMethod::GetNavigateToItems {
|
||||
search: params.query,
|
||||
// this matches vscode's hard coded result count
|
||||
max_result_count: Some(256),
|
||||
file: None,
|
||||
};
|
||||
|
||||
let navigate_to_items: Vec<tsc::NavigateToItem> = self
|
||||
.ts_server
|
||||
.request(self.snapshot()?, req)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Failed request to tsserver: {}", err);
|
||||
LspError::invalid_request()
|
||||
})?;
|
||||
|
||||
let maybe_symbol_information = if navigate_to_items.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let mut symbol_information = Vec::new();
|
||||
for item in navigate_to_items {
|
||||
if let Some(info) = item.to_symbol_information(self).await {
|
||||
symbol_information.push(info);
|
||||
}
|
||||
}
|
||||
Some(symbol_information)
|
||||
};
|
||||
|
||||
self.performance.measure(mark);
|
||||
Ok(maybe_symbol_information)
|
||||
}
|
||||
}
|
||||
|
||||
#[lspower::async_trait]
|
||||
|
@ -2481,6 +2519,13 @@ impl lspower::LanguageServer for LanguageServer {
|
|||
) -> LspResult<Option<SignatureHelp>> {
|
||||
self.0.lock().await.signature_help(params).await
|
||||
}
|
||||
|
||||
async fn symbol(
|
||||
&self,
|
||||
params: WorkspaceSymbolParams,
|
||||
) -> LspResult<Option<Vec<SymbolInformation>>> {
|
||||
self.0.lock().await.symbol(params).await
|
||||
}
|
||||
}
|
||||
|
||||
// These are implementations of custom commands supported by the LSP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue