Use symbol tags

This commit is contained in:
kjeremy 2020-07-22 12:18:48 -04:00
parent e72c6220cd
commit 9a9c0e1105
3 changed files with 20 additions and 4 deletions

4
Cargo.lock generated
View file

@ -619,9 +619,9 @@ dependencies = [
[[package]] [[package]]
name = "lsp-types" name = "lsp-types"
version = "0.77.0" version = "0.78.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897c6c8930fbf12b67deffc83729287bb379dd5e5a4bd0ae2d81eff8d6503db6" checksum = "d2e6cf68e3492cfa2035f0382c1da1b6ab045db0320feca505b86b4f13d66c27"
dependencies = [ dependencies = [
"base64", "base64",
"bitflags", "bitflags",

View file

@ -20,7 +20,7 @@ env_logger = { version = "0.7.1", default-features = false }
itertools = "0.9.0" itertools = "0.9.0"
jod-thread = "0.1.0" jod-thread = "0.1.0"
log = "0.4.8" 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" parking_lot = "0.11.0"
pico-args = "0.3.1" pico-args = "0.3.1"
rand = { version = "0.7.3", features = ["small_rng"] } rand = { version = "0.7.3", features = ["small_rng"] }

View file

@ -2,6 +2,8 @@
//! Protocol. The majority of requests are fulfilled by calling into the //! Protocol. The majority of requests are fulfilled by calling into the
//! `ra_ide` crate. //! `ra_ide` crate.
#![allow(deprecated)]
use std::{ use std::{
io::Write as _, io::Write as _,
process::{self, Stdio}, process::{self, Stdio},
@ -15,7 +17,7 @@ use lsp_types::{
DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location,
Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams,
SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation,
TextDocumentIdentifier, Url, WorkspaceEdit, SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit,
}; };
use ra_ide::{ use ra_ide::{
FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query,
@ -253,10 +255,16 @@ pub(crate) fn handle_document_symbol(
let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new();
for symbol in snap.analysis.file_structure(file_id)? { 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 { let doc_symbol = DocumentSymbol {
name: symbol.label, name: symbol.label,
detail: symbol.detail, detail: symbol.detail,
kind: to_proto::symbol_kind(symbol.kind), kind: to_proto::symbol_kind(symbol.kind),
tags: Some(tags),
deprecated: Some(symbol.deprecated), deprecated: Some(symbol.deprecated),
range: to_proto::range(&line_index, symbol.node_range), range: to_proto::range(&line_index, symbol.node_range),
selection_range: to_proto::range(&line_index, symbol.navigation_range), selection_range: to_proto::range(&line_index, symbol.navigation_range),
@ -296,9 +304,16 @@ pub(crate) fn handle_document_symbol(
url: &Url, url: &Url,
res: &mut Vec<SymbolInformation>, res: &mut Vec<SymbolInformation>,
) { ) {
let mut tags = Vec::new();
match symbol.deprecated {
Some(true) => tags.push(SymbolTag::Deprecated),
_ => {}
}
res.push(SymbolInformation { res.push(SymbolInformation {
name: symbol.name.clone(), name: symbol.name.clone(),
kind: symbol.kind, kind: symbol.kind,
tags: Some(tags),
deprecated: symbol.deprecated, deprecated: symbol.deprecated,
location: Location::new(url.clone(), symbol.range), location: Location::new(url.clone(), symbol.range),
container_name, container_name,
@ -345,6 +360,7 @@ pub(crate) fn handle_workspace_symbol(
let info = SymbolInformation { let info = SymbolInformation {
name: nav.name.to_string(), name: nav.name.to_string(),
kind: to_proto::symbol_kind(nav.kind), kind: to_proto::symbol_kind(nav.kind),
tags: None,
location: to_proto::location_from_nav(snap, nav)?, location: to_proto::location_from_nav(snap, nav)?,
container_name, container_name,
deprecated: None, deprecated: None,