Skip to content

Commit d2dacc0

Browse files
committed
Auto merge of #16182 - Veykril:world-symbols-focus-range, r=Veykril
internal: Update world symbols request definiton, prefer focus range for macros Prior to this, the symbol search would always jump to the defining macro call, not it jumps to the name in the macro call input if possible. This is a large improvement for assoc items in an attribute impl or trait.
2 parents 23a1280 + 2a5b60b commit d2dacc0

File tree

8 files changed

+16
-14
lines changed

8 files changed

+16
-14
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rust-analyzer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ crossbeam-channel = "0.5.5"
2424
dissimilar.workspace = true
2525
itertools.workspace = true
2626
scip = "0.3.1"
27-
lsp-types = { version = "=0.94.0", features = ["proposed"] }
27+
lsp-types = { version = "=0.95.0", features = ["proposed"] }
2828
parking_lot = "0.12.1"
2929
xflags = "0.3.0"
3030
oorandom = "11.1.3"

crates/rust-analyzer/src/caps.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
157157
"ssr": true,
158158
"workspaceSymbolScopeKindFiltering": true,
159159
})),
160+
diagnostic_provider: None,
161+
inline_completion_provider: None,
160162
}
161163
}
162164

crates/rust-analyzer/src/handlers/request.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ pub(crate) fn handle_document_symbol(
453453
pub(crate) fn handle_workspace_symbol(
454454
snap: GlobalStateSnapshot,
455455
params: WorkspaceSymbolParams,
456-
) -> anyhow::Result<Option<Vec<SymbolInformation>>> {
456+
) -> anyhow::Result<Option<lsp_types::WorkspaceSymbolResponse>> {
457457
let _p = profile::span("handle_workspace_symbol");
458458

459459
let config = snap.config.workspace_symbol();
@@ -479,7 +479,7 @@ pub(crate) fn handle_workspace_symbol(
479479
res = exec_query(&snap, query)?;
480480
}
481481

482-
return Ok(Some(res));
482+
return Ok(Some(lsp_types::WorkspaceSymbolResponse::Nested(res)));
483483

484484
fn decide_search_scope_and_kind(
485485
params: &WorkspaceSymbolParams,
@@ -519,13 +519,12 @@ pub(crate) fn handle_workspace_symbol(
519519
fn exec_query(
520520
snap: &GlobalStateSnapshot,
521521
query: Query,
522-
) -> anyhow::Result<Vec<SymbolInformation>> {
522+
) -> anyhow::Result<Vec<lsp_types::WorkspaceSymbol>> {
523523
let mut res = Vec::new();
524524
for nav in snap.analysis.symbol_search(query)? {
525525
let container_name = nav.container_name.as_ref().map(|v| v.to_string());
526526

527-
#[allow(deprecated)]
528-
let info = SymbolInformation {
527+
let info = lsp_types::WorkspaceSymbol {
529528
name: match &nav.alias {
530529
Some(alias) => format!("{} (alias for {})", alias, nav.name),
531530
None => format!("{}", nav.name),
@@ -534,10 +533,11 @@ pub(crate) fn handle_workspace_symbol(
534533
.kind
535534
.map(to_proto::symbol_kind)
536535
.unwrap_or(lsp_types::SymbolKind::VARIABLE),
536+
// FIXME: Set deprecation
537537
tags: None,
538-
location: to_proto::location_from_nav(snap, nav)?,
539538
container_name,
540-
deprecated: None,
539+
location: lsp_types::OneOf::Left(to_proto::location_from_nav(snap, nav)?),
540+
data: None,
541541
};
542542
res.push(info);
543543
}

crates/rust-analyzer/src/lsp/ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ pub enum WorkspaceSymbol {}
627627

628628
impl Request for WorkspaceSymbol {
629629
type Params = WorkspaceSymbolParams;
630-
type Result = Option<Vec<lsp_types::SymbolInformation>>;
630+
type Result = Option<lsp_types::WorkspaceSymbolResponse>;
631631
const METHOD: &'static str = "workspace/symbol";
632632
}
633633

crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ pub(crate) fn location_from_nav(
857857
) -> Cancellable<lsp_types::Location> {
858858
let url = url(snap, nav.file_id);
859859
let line_index = snap.file_line_index(nav.file_id)?;
860-
let range = range(&line_index, nav.full_range);
860+
let range = range(&line_index, nav.focus_or_full_range());
861861
let loc = lsp_types::Location::new(url, range);
862862
Ok(loc)
863863
}

docs/dev/lsp-extensions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!---
2-
lsp/ext.rs hash: 121482ee911854da
2+
lsp/ext.rs hash: dff0b009e82ef06a
33
44
If you need to change the above hash to make the test pass, please check if you
55
need to adjust this doc as well and ping this issue:

lib/lsp-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ serde = { version = "1.0.192", features = ["derive"] }
1313
crossbeam-channel = "0.5.6"
1414

1515
[dev-dependencies]
16-
lsp-types = "=0.94"
16+
lsp-types = "=0.95"
1717
ctrlc = "3.4.1"

0 commit comments

Comments
 (0)