Skip to content

Commit 56ff9ef

Browse files
bors[bot]kjeremy
andauthored
Merge #5492
5492: Use symbol tags r=matklad a=kjeremy Currently the only spec'd tag is "deprecated". Co-authored-by: kjeremy <[email protected]>
2 parents e72c622 + 7eedf19 commit 56ff9ef

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
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
@@ -20,7 +20,7 @@ env_logger = { version = "0.7.1", default-features = false }
2020
itertools = "0.9.0"
2121
jod-thread = "0.1.0"
2222
log = "0.4.8"
23-
lsp-types = { version = "0.77.0", features = ["proposed"] }
23+
lsp-types = { version = "0.78.0", features = ["proposed"] }
2424
parking_lot = "0.11.0"
2525
pico-args = "0.3.1"
2626
rand = { version = "0.7.3", features = ["small_rng"] }

crates/rust-analyzer/src/handlers.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use lsp_types::{
1515
DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location,
1616
Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams,
1717
SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation,
18-
TextDocumentIdentifier, Url, WorkspaceEdit,
18+
SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit,
1919
};
2020
use ra_ide::{
2121
FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query,
@@ -253,10 +253,17 @@ pub(crate) fn handle_document_symbol(
253253
let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new();
254254

255255
for symbol in snap.analysis.file_structure(file_id)? {
256+
let mut tags = Vec::new();
257+
if symbol.deprecated {
258+
tags.push(SymbolTag::Deprecated)
259+
};
260+
261+
#[allow(deprecated)]
256262
let doc_symbol = DocumentSymbol {
257263
name: symbol.label,
258264
detail: symbol.detail,
259265
kind: to_proto::symbol_kind(symbol.kind),
266+
tags: Some(tags),
260267
deprecated: Some(symbol.deprecated),
261268
range: to_proto::range(&line_index, symbol.node_range),
262269
selection_range: to_proto::range(&line_index, symbol.navigation_range),
@@ -296,9 +303,19 @@ pub(crate) fn handle_document_symbol(
296303
url: &Url,
297304
res: &mut Vec<SymbolInformation>,
298305
) {
306+
let mut tags = Vec::new();
307+
308+
#[allow(deprecated)]
309+
match symbol.deprecated {
310+
Some(true) => tags.push(SymbolTag::Deprecated),
311+
_ => {}
312+
}
313+
314+
#[allow(deprecated)]
299315
res.push(SymbolInformation {
300316
name: symbol.name.clone(),
301317
kind: symbol.kind,
318+
tags: Some(tags),
302319
deprecated: symbol.deprecated,
303320
location: Location::new(url.clone(), symbol.range),
304321
container_name,
@@ -342,9 +359,12 @@ pub(crate) fn handle_workspace_symbol(
342359
let mut res = Vec::new();
343360
for nav in snap.analysis.symbol_search(query)? {
344361
let container_name = nav.container_name.as_ref().map(|v| v.to_string());
362+
363+
#[allow(deprecated)]
345364
let info = SymbolInformation {
346365
name: nav.name.to_string(),
347366
kind: to_proto::symbol_kind(nav.kind),
367+
tags: None,
348368
location: to_proto::location_from_nav(snap, nav)?,
349369
container_name,
350370
deprecated: None,

0 commit comments

Comments
 (0)