From 9a9c0e1105a57ccb231c64e1ebd2a200b4426b64 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Wed, 22 Jul 2020 12:18:48 -0400 Subject: Use symbol tags --- Cargo.lock | 4 ++-- crates/rust-analyzer/Cargo.toml | 2 +- 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 = [ [[package]] name = "lsp-types" -version = "0.77.0" +version = "0.78.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897c6c8930fbf12b67deffc83729287bb379dd5e5a4bd0ae2d81eff8d6503db6" +checksum = "d2e6cf68e3492cfa2035f0382c1da1b6ab045db0320feca505b86b4f13d66c27" dependencies = [ "base64", "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 } itertools = "0.9.0" jod-thread = "0.1.0" log = "0.4.8" -lsp-types = { version = "0.77.0", features = ["proposed"] } +lsp-types = { version = "0.78.0", features = ["proposed"] } parking_lot = "0.11.0" pico-args = "0.3.1" 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 @@ //! Protocol. The majority of requests are fulfilled by calling into the //! `ra_ide` crate. +#![allow(deprecated)] + use std::{ io::Write as _, process::{self, Stdio}, @@ -15,7 +17,7 @@ use lsp_types::{ DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, - TextDocumentIdentifier, Url, WorkspaceEdit, + SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit, }; use ra_ide::{ FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, @@ -253,10 +255,16 @@ pub(crate) fn handle_document_symbol( let mut parents: Vec<(DocumentSymbol, Option)> = Vec::new(); for symbol in snap.analysis.file_structure(file_id)? { + let mut tags = Vec::new(); + if symbol.deprecated { + tags.push(SymbolTag::Deprecated) + }; + let doc_symbol = DocumentSymbol { name: symbol.label, detail: symbol.detail, kind: to_proto::symbol_kind(symbol.kind), + tags: Some(tags), deprecated: Some(symbol.deprecated), range: to_proto::range(&line_index, symbol.node_range), selection_range: to_proto::range(&line_index, symbol.navigation_range), @@ -296,9 +304,16 @@ pub(crate) fn handle_document_symbol( url: &Url, res: &mut Vec, ) { + let mut tags = Vec::new(); + match symbol.deprecated { + Some(true) => tags.push(SymbolTag::Deprecated), + _ => {} + } + res.push(SymbolInformation { name: symbol.name.clone(), kind: symbol.kind, + tags: Some(tags), deprecated: symbol.deprecated, location: Location::new(url.clone(), symbol.range), container_name, @@ -345,6 +360,7 @@ pub(crate) fn handle_workspace_symbol( let info = SymbolInformation { name: nav.name.to_string(), kind: to_proto::symbol_kind(nav.kind), + tags: None, location: to_proto::location_from_nav(snap, nav)?, container_name, deprecated: None, -- cgit v1.2.3 From 7eedf19cfa334be06ae2efc6c97d7fff83ccc202 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Wed, 22 Jul 2020 15:41:38 -0400 Subject: Move deprecated attribute to where it is needed --- crates/rust-analyzer/src/handlers.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 2589002e7..8d8c9442b 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -2,8 +2,6 @@ //! Protocol. The majority of requests are fulfilled by calling into the //! `ra_ide` crate. -#![allow(deprecated)] - use std::{ io::Write as _, process::{self, Stdio}, @@ -260,6 +258,7 @@ pub(crate) fn handle_document_symbol( tags.push(SymbolTag::Deprecated) }; + #[allow(deprecated)] let doc_symbol = DocumentSymbol { name: symbol.label, detail: symbol.detail, @@ -305,11 +304,14 @@ pub(crate) fn handle_document_symbol( res: &mut Vec, ) { let mut tags = Vec::new(); + + #[allow(deprecated)] match symbol.deprecated { Some(true) => tags.push(SymbolTag::Deprecated), _ => {} } + #[allow(deprecated)] res.push(SymbolInformation { name: symbol.name.clone(), kind: symbol.kind, @@ -357,6 +359,8 @@ pub(crate) fn handle_workspace_symbol( let mut res = Vec::new(); for nav in snap.analysis.symbol_search(query)? { let container_name = nav.container_name.as_ref().map(|v| v.to_string()); + + #[allow(deprecated)] let info = SymbolInformation { name: nav.name.to_string(), kind: to_proto::symbol_kind(nav.kind), -- cgit v1.2.3