diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-22 20:43:06 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-22 20:43:06 +0100 |
commit | 56ff9ef0262f5bad7fa1d0ac3b76974d88671afd (patch) | |
tree | af048a1c9c32c4a9d6449b6152b5c0e4727cd56d | |
parent | e72c6220cda30ebe2bde4e0bd7d344c248332ecc (diff) | |
parent | 7eedf19cfa334be06ae2efc6c97d7fff83ccc202 (diff) |
Merge #5492
5492: Use symbol tags r=matklad a=kjeremy
Currently the only spec'd tag is "deprecated".
Co-authored-by: kjeremy <[email protected]>
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 22 |
3 files changed, 24 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock index 280d97432..af7062815 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -619,9 +619,9 @@ dependencies = [ | |||
619 | 619 | ||
620 | [[package]] | 620 | [[package]] |
621 | name = "lsp-types" | 621 | name = "lsp-types" |
622 | version = "0.77.0" | 622 | version = "0.78.0" |
623 | source = "registry+https://github.com/rust-lang/crates.io-index" | 623 | source = "registry+https://github.com/rust-lang/crates.io-index" |
624 | checksum = "897c6c8930fbf12b67deffc83729287bb379dd5e5a4bd0ae2d81eff8d6503db6" | 624 | checksum = "d2e6cf68e3492cfa2035f0382c1da1b6ab045db0320feca505b86b4f13d66c27" |
625 | dependencies = [ | 625 | dependencies = [ |
626 | "base64", | 626 | "base64", |
627 | "bitflags", | 627 | "bitflags", |
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 023c104d1..758aa1c5d 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -20,7 +20,7 @@ env_logger = { version = "0.7.1", default-features = false } | |||
20 | itertools = "0.9.0" | 20 | itertools = "0.9.0" |
21 | jod-thread = "0.1.0" | 21 | jod-thread = "0.1.0" |
22 | log = "0.4.8" | 22 | log = "0.4.8" |
23 | lsp-types = { version = "0.77.0", features = ["proposed"] } | 23 | lsp-types = { version = "0.78.0", features = ["proposed"] } |
24 | parking_lot = "0.11.0" | 24 | parking_lot = "0.11.0" |
25 | pico-args = "0.3.1" | 25 | pico-args = "0.3.1" |
26 | rand = { version = "0.7.3", features = ["small_rng"] } | 26 | rand = { version = "0.7.3", features = ["small_rng"] } |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index d880570d2..8d8c9442b 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -15,7 +15,7 @@ use lsp_types::{ | |||
15 | DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, | 15 | DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, |
16 | Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, | 16 | Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, |
17 | SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, | 17 | SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, |
18 | TextDocumentIdentifier, Url, WorkspaceEdit, | 18 | SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit, |
19 | }; | 19 | }; |
20 | use ra_ide::{ | 20 | use ra_ide::{ |
21 | FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, | 21 | FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, |
@@ -253,10 +253,17 @@ pub(crate) fn handle_document_symbol( | |||
253 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); | 253 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); |
254 | 254 | ||
255 | for symbol in snap.analysis.file_structure(file_id)? { | 255 | 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)] | ||
256 | let doc_symbol = DocumentSymbol { | 262 | let doc_symbol = DocumentSymbol { |
257 | name: symbol.label, | 263 | name: symbol.label, |
258 | detail: symbol.detail, | 264 | detail: symbol.detail, |
259 | kind: to_proto::symbol_kind(symbol.kind), | 265 | kind: to_proto::symbol_kind(symbol.kind), |
266 | tags: Some(tags), | ||
260 | deprecated: Some(symbol.deprecated), | 267 | deprecated: Some(symbol.deprecated), |
261 | range: to_proto::range(&line_index, symbol.node_range), | 268 | range: to_proto::range(&line_index, symbol.node_range), |
262 | selection_range: to_proto::range(&line_index, symbol.navigation_range), | 269 | selection_range: to_proto::range(&line_index, symbol.navigation_range), |
@@ -296,9 +303,19 @@ pub(crate) fn handle_document_symbol( | |||
296 | url: &Url, | 303 | url: &Url, |
297 | res: &mut Vec<SymbolInformation>, | 304 | res: &mut Vec<SymbolInformation>, |
298 | ) { | 305 | ) { |
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)] | ||
299 | res.push(SymbolInformation { | 315 | res.push(SymbolInformation { |
300 | name: symbol.name.clone(), | 316 | name: symbol.name.clone(), |
301 | kind: symbol.kind, | 317 | kind: symbol.kind, |
318 | tags: Some(tags), | ||
302 | deprecated: symbol.deprecated, | 319 | deprecated: symbol.deprecated, |
303 | location: Location::new(url.clone(), symbol.range), | 320 | location: Location::new(url.clone(), symbol.range), |
304 | container_name, | 321 | container_name, |
@@ -342,9 +359,12 @@ pub(crate) fn handle_workspace_symbol( | |||
342 | let mut res = Vec::new(); | 359 | let mut res = Vec::new(); |
343 | for nav in snap.analysis.symbol_search(query)? { | 360 | for nav in snap.analysis.symbol_search(query)? { |
344 | let container_name = nav.container_name.as_ref().map(|v| v.to_string()); | 361 | let container_name = nav.container_name.as_ref().map(|v| v.to_string()); |
362 | |||
363 | #[allow(deprecated)] | ||
345 | let info = SymbolInformation { | 364 | let info = SymbolInformation { |
346 | name: nav.name.to_string(), | 365 | name: nav.name.to_string(), |
347 | kind: to_proto::symbol_kind(nav.kind), | 366 | kind: to_proto::symbol_kind(nav.kind), |
367 | tags: None, | ||
348 | location: to_proto::location_from_nav(snap, nav)?, | 368 | location: to_proto::location_from_nav(snap, nav)?, |
349 | container_name, | 369 | container_name, |
350 | deprecated: None, | 370 | deprecated: None, |