mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
internal: Update world symbols request definiton, prefer focus range for macros
This commit is contained in:
parent
5761b50ed8
commit
2a5b60b186
8 changed files with 16 additions and 14 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -969,9 +969,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lsp-types"
|
name = "lsp-types"
|
||||||
version = "0.94.0"
|
version = "0.95.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b63735a13a1f9cd4f4835223d828ed9c2e35c8c5e61837774399f558b6a1237"
|
checksum = "158c1911354ef73e8fe42da6b10c0484cb65c7f1007f28022e847706c1ab6984"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -24,7 +24,7 @@ crossbeam-channel = "0.5.5"
|
||||||
dissimilar.workspace = true
|
dissimilar.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
scip = "0.3.1"
|
scip = "0.3.1"
|
||||||
lsp-types = { version = "=0.94.0", features = ["proposed"] }
|
lsp-types = { version = "=0.95.0", features = ["proposed"] }
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
xflags = "0.3.0"
|
xflags = "0.3.0"
|
||||||
oorandom = "11.1.3"
|
oorandom = "11.1.3"
|
||||||
|
|
|
@ -157,6 +157,8 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
|
||||||
"ssr": true,
|
"ssr": true,
|
||||||
"workspaceSymbolScopeKindFiltering": true,
|
"workspaceSymbolScopeKindFiltering": true,
|
||||||
})),
|
})),
|
||||||
|
diagnostic_provider: None,
|
||||||
|
inline_completion_provider: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -453,7 +453,7 @@ pub(crate) fn handle_document_symbol(
|
||||||
pub(crate) fn handle_workspace_symbol(
|
pub(crate) fn handle_workspace_symbol(
|
||||||
snap: GlobalStateSnapshot,
|
snap: GlobalStateSnapshot,
|
||||||
params: WorkspaceSymbolParams,
|
params: WorkspaceSymbolParams,
|
||||||
) -> anyhow::Result<Option<Vec<SymbolInformation>>> {
|
) -> anyhow::Result<Option<lsp_types::WorkspaceSymbolResponse>> {
|
||||||
let _p = profile::span("handle_workspace_symbol");
|
let _p = profile::span("handle_workspace_symbol");
|
||||||
|
|
||||||
let config = snap.config.workspace_symbol();
|
let config = snap.config.workspace_symbol();
|
||||||
|
@ -479,7 +479,7 @@ pub(crate) fn handle_workspace_symbol(
|
||||||
res = exec_query(&snap, query)?;
|
res = exec_query(&snap, query)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(Some(res));
|
return Ok(Some(lsp_types::WorkspaceSymbolResponse::Nested(res)));
|
||||||
|
|
||||||
fn decide_search_scope_and_kind(
|
fn decide_search_scope_and_kind(
|
||||||
params: &WorkspaceSymbolParams,
|
params: &WorkspaceSymbolParams,
|
||||||
|
@ -519,13 +519,12 @@ pub(crate) fn handle_workspace_symbol(
|
||||||
fn exec_query(
|
fn exec_query(
|
||||||
snap: &GlobalStateSnapshot,
|
snap: &GlobalStateSnapshot,
|
||||||
query: Query,
|
query: Query,
|
||||||
) -> anyhow::Result<Vec<SymbolInformation>> {
|
) -> anyhow::Result<Vec<lsp_types::WorkspaceSymbol>> {
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
for nav in snap.analysis.symbol_search(query)? {
|
for nav in snap.analysis.symbol_search(query)? {
|
||||||
let container_name = nav.container_name.as_ref().map(|v| v.to_string());
|
let container_name = nav.container_name.as_ref().map(|v| v.to_string());
|
||||||
|
|
||||||
#[allow(deprecated)]
|
let info = lsp_types::WorkspaceSymbol {
|
||||||
let info = SymbolInformation {
|
|
||||||
name: match &nav.alias {
|
name: match &nav.alias {
|
||||||
Some(alias) => format!("{} (alias for {})", alias, nav.name),
|
Some(alias) => format!("{} (alias for {})", alias, nav.name),
|
||||||
None => format!("{}", nav.name),
|
None => format!("{}", nav.name),
|
||||||
|
@ -534,10 +533,11 @@ pub(crate) fn handle_workspace_symbol(
|
||||||
.kind
|
.kind
|
||||||
.map(to_proto::symbol_kind)
|
.map(to_proto::symbol_kind)
|
||||||
.unwrap_or(lsp_types::SymbolKind::VARIABLE),
|
.unwrap_or(lsp_types::SymbolKind::VARIABLE),
|
||||||
|
// FIXME: Set deprecation
|
||||||
tags: None,
|
tags: None,
|
||||||
location: to_proto::location_from_nav(snap, nav)?,
|
|
||||||
container_name,
|
container_name,
|
||||||
deprecated: None,
|
location: lsp_types::OneOf::Left(to_proto::location_from_nav(snap, nav)?),
|
||||||
|
data: None,
|
||||||
};
|
};
|
||||||
res.push(info);
|
res.push(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,7 +627,7 @@ pub enum WorkspaceSymbol {}
|
||||||
|
|
||||||
impl Request for WorkspaceSymbol {
|
impl Request for WorkspaceSymbol {
|
||||||
type Params = WorkspaceSymbolParams;
|
type Params = WorkspaceSymbolParams;
|
||||||
type Result = Option<Vec<lsp_types::SymbolInformation>>;
|
type Result = Option<lsp_types::WorkspaceSymbolResponse>;
|
||||||
const METHOD: &'static str = "workspace/symbol";
|
const METHOD: &'static str = "workspace/symbol";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -857,7 +857,7 @@ pub(crate) fn location_from_nav(
|
||||||
) -> Cancellable<lsp_types::Location> {
|
) -> Cancellable<lsp_types::Location> {
|
||||||
let url = url(snap, nav.file_id);
|
let url = url(snap, nav.file_id);
|
||||||
let line_index = snap.file_line_index(nav.file_id)?;
|
let line_index = snap.file_line_index(nav.file_id)?;
|
||||||
let range = range(&line_index, nav.full_range);
|
let range = range(&line_index, nav.focus_or_full_range());
|
||||||
let loc = lsp_types::Location::new(url, range);
|
let loc = lsp_types::Location::new(url, range);
|
||||||
Ok(loc)
|
Ok(loc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!---
|
<!---
|
||||||
lsp/ext.rs hash: 121482ee911854da
|
lsp/ext.rs hash: dff0b009e82ef06a
|
||||||
|
|
||||||
If you need to change the above hash to make the test pass, please check if you
|
If you need to change the above hash to make the test pass, please check if you
|
||||||
need to adjust this doc as well and ping this issue:
|
need to adjust this doc as well and ping this issue:
|
||||||
|
|
|
@ -13,5 +13,5 @@ serde = { version = "1.0.192", features = ["derive"] }
|
||||||
crossbeam-channel = "0.5.6"
|
crossbeam-channel = "0.5.6"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
lsp-types = "=0.94"
|
lsp-types = "=0.95"
|
||||||
ctrlc = "3.4.1"
|
ctrlc = "3.4.1"
|
||||||
|
|
Loading…
Reference in a new issue