diff options
author | kjeremy <[email protected]> | 2020-07-22 17:18:48 +0100 |
---|---|---|
committer | kjeremy <[email protected]> | 2020-07-22 17:18:48 +0100 |
commit | 9a9c0e1105a57ccb231c64e1ebd2a200b4426b64 (patch) | |
tree | f81eff0227c84dffd23ba1e9b8c4c839db621261 | |
parent | e72c6220cda30ebe2bde4e0bd7d344c248332ecc (diff) |
Use symbol tags
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 18 |
3 files changed, 20 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..2589002e7 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -2,6 +2,8 @@ | |||
2 | //! Protocol. The majority of requests are fulfilled by calling into the | 2 | //! Protocol. The majority of requests are fulfilled by calling into the |
3 | //! `ra_ide` crate. | 3 | //! `ra_ide` crate. |
4 | 4 | ||
5 | #![allow(deprecated)] | ||
6 | |||
5 | use std::{ | 7 | use std::{ |
6 | io::Write as _, | 8 | io::Write as _, |
7 | process::{self, Stdio}, | 9 | process::{self, Stdio}, |
@@ -15,7 +17,7 @@ use lsp_types::{ | |||
15 | DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, | 17 | DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, |
16 | Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, | 18 | Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, |
17 | SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, | 19 | SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, |
18 | TextDocumentIdentifier, Url, WorkspaceEdit, | 20 | SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit, |
19 | }; | 21 | }; |
20 | use ra_ide::{ | 22 | use ra_ide::{ |
21 | FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, | 23 | FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, |
@@ -253,10 +255,16 @@ pub(crate) fn handle_document_symbol( | |||
253 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); | 255 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); |
254 | 256 | ||
255 | for symbol in snap.analysis.file_structure(file_id)? { | 257 | for symbol in snap.analysis.file_structure(file_id)? { |
258 | let mut tags = Vec::new(); | ||
259 | if symbol.deprecated { | ||
260 | tags.push(SymbolTag::Deprecated) | ||
261 | }; | ||
262 | |||
256 | let doc_symbol = DocumentSymbol { | 263 | let doc_symbol = DocumentSymbol { |
257 | name: symbol.label, | 264 | name: symbol.label, |
258 | detail: symbol.detail, | 265 | detail: symbol.detail, |
259 | kind: to_proto::symbol_kind(symbol.kind), | 266 | kind: to_proto::symbol_kind(symbol.kind), |
267 | tags: Some(tags), | ||
260 | deprecated: Some(symbol.deprecated), | 268 | deprecated: Some(symbol.deprecated), |
261 | range: to_proto::range(&line_index, symbol.node_range), | 269 | range: to_proto::range(&line_index, symbol.node_range), |
262 | selection_range: to_proto::range(&line_index, symbol.navigation_range), | 270 | selection_range: to_proto::range(&line_index, symbol.navigation_range), |
@@ -296,9 +304,16 @@ pub(crate) fn handle_document_symbol( | |||
296 | url: &Url, | 304 | url: &Url, |
297 | res: &mut Vec<SymbolInformation>, | 305 | res: &mut Vec<SymbolInformation>, |
298 | ) { | 306 | ) { |
307 | let mut tags = Vec::new(); | ||
308 | match symbol.deprecated { | ||
309 | Some(true) => tags.push(SymbolTag::Deprecated), | ||
310 | _ => {} | ||
311 | } | ||
312 | |||
299 | res.push(SymbolInformation { | 313 | res.push(SymbolInformation { |
300 | name: symbol.name.clone(), | 314 | name: symbol.name.clone(), |
301 | kind: symbol.kind, | 315 | kind: symbol.kind, |
316 | tags: Some(tags), | ||
302 | deprecated: symbol.deprecated, | 317 | deprecated: symbol.deprecated, |
303 | location: Location::new(url.clone(), symbol.range), | 318 | location: Location::new(url.clone(), symbol.range), |
304 | container_name, | 319 | container_name, |
@@ -345,6 +360,7 @@ pub(crate) fn handle_workspace_symbol( | |||
345 | let info = SymbolInformation { | 360 | let info = SymbolInformation { |
346 | name: nav.name.to_string(), | 361 | name: nav.name.to_string(), |
347 | kind: to_proto::symbol_kind(nav.kind), | 362 | kind: to_proto::symbol_kind(nav.kind), |
363 | tags: None, | ||
348 | location: to_proto::location_from_nav(snap, nav)?, | 364 | location: to_proto::location_from_nav(snap, nav)?, |
349 | container_name, | 365 | container_name, |
350 | deprecated: None, | 366 | deprecated: None, |