From b5272573300766d0c8417161c1a4f959abc9ff43 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Tue, 1 Sep 2020 12:53:07 -0400 Subject: Move to vscode-languageclient 7.0.0-next.9 Stabilizes call hierarchy and semantic tokens features. --- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/caps.rs | 8 +++----- crates/rust-analyzer/src/handlers.rs | 20 ++++++++++---------- crates/rust-analyzer/src/main_loop.rs | 8 +++++--- crates/rust-analyzer/src/semantic_tokens.rs | 1 - crates/rust-analyzer/src/to_proto.rs | 6 +++--- 6 files changed, 22 insertions(+), 23 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index e06956d6c..8db0b0d72 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -21,7 +21,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.79.0", features = ["proposed"] } +lsp-types = { version = "0.80.0", features = ["proposed"] } parking_lot = "0.11.0" pico-args = "0.3.1" oorandom = "11.1.2" diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index 92a743fd8..de4bc2813 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs @@ -6,7 +6,7 @@ use lsp_types::{ CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, HoverProviderCapability, ImplementationProviderCapability, RenameOptions, RenameProviderCapability, SaveOptions, - SelectionRangeProviderCapability, SemanticTokensDocumentProvider, SemanticTokensLegend, + SelectionRangeProviderCapability, SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, @@ -76,10 +76,8 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti token_modifiers: semantic_tokens::SUPPORTED_MODIFIERS.to_vec(), }, - document_provider: Some(SemanticTokensDocumentProvider::Edits { - edits: Some(true), - }), - range_provider: Some(true), + full: Some(SemanticTokensFullOptions::Delta { delta: Some(true) }), + range: Some(true), work_done_progress_options: Default::default(), } .into(), diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index d62dd0589..64cb4d96c 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -17,8 +17,8 @@ use lsp_types::{ CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams, CodeActionKind, CodeLens, Command, CompletionItem, Diagnostic, DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, - Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensEditResult, - SemanticTokensEditsParams, SemanticTokensParams, SemanticTokensRangeParams, + Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensDeltaParams, + SemanticTokensFullDeltaResult, SemanticTokensParams, SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit, }; @@ -1171,11 +1171,11 @@ pub(crate) fn handle_call_hierarchy_outgoing( Ok(Some(res)) } -pub(crate) fn handle_semantic_tokens( +pub(crate) fn handle_semantic_tokens_full( snap: GlobalStateSnapshot, params: SemanticTokensParams, ) -> Result> { - let _p = profile::span("handle_semantic_tokens"); + let _p = profile::span("handle_semantic_tokens_full"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let text = snap.analysis.file_text(file_id)?; @@ -1190,11 +1190,11 @@ pub(crate) fn handle_semantic_tokens( Ok(Some(semantic_tokens.into())) } -pub(crate) fn handle_semantic_tokens_edits( +pub(crate) fn handle_semantic_tokens_full_delta( snap: GlobalStateSnapshot, - params: SemanticTokensEditsParams, -) -> Result> { - let _p = profile::span("handle_semantic_tokens_edits"); + params: SemanticTokensDeltaParams, +) -> Result> { + let _p = profile::span("handle_semantic_tokens_full_delta"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let text = snap.analysis.file_text(file_id)?; @@ -1209,9 +1209,9 @@ pub(crate) fn handle_semantic_tokens_edits( if let Some(prev_id) = &cached_tokens.result_id { if *prev_id == params.previous_result_id { - let edits = to_proto::semantic_token_edits(&cached_tokens, &semantic_tokens); + let delta = to_proto::semantic_token_delta(&cached_tokens, &semantic_tokens); *cached_tokens = semantic_tokens; - return Ok(Some(edits.into())); + return Ok(Some(delta.into())); } } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 355caaee2..8d3132581 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -407,9 +407,11 @@ impl GlobalState { .on::( handlers::handle_call_hierarchy_outgoing, )? - .on::(handlers::handle_semantic_tokens)? - .on::( - handlers::handle_semantic_tokens_edits, + .on::( + handlers::handle_semantic_tokens_full, + )? + .on::( + handlers::handle_semantic_tokens_full_delta, )? .on::( handlers::handle_semantic_tokens_range, diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index 9db7b8af5..1225d3e35 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -31,7 +31,6 @@ macro_rules! define_semantic_token_types { SemanticTokenType::MACRO, SemanticTokenType::VARIABLE, SemanticTokenType::PARAMETER, - SemanticTokenType::LABEL, $($ident),* ]; }; diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index a8173a338..16aab52c2 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -334,13 +334,13 @@ pub(crate) fn semantic_tokens( builder.build() } -pub(crate) fn semantic_token_edits( +pub(crate) fn semantic_token_delta( previous: &lsp_types::SemanticTokens, current: &lsp_types::SemanticTokens, -) -> lsp_types::SemanticTokensEdits { +) -> lsp_types::SemanticTokensDelta { let result_id = current.result_id.clone(); let edits = semantic_tokens::diff_tokens(&previous.data, ¤t.data); - lsp_types::SemanticTokensEdits { result_id, edits } + lsp_types::SemanticTokensDelta { result_id, edits } } fn semantic_token_type_and_modifiers( -- cgit v1.2.3 From 36692bdffa59accee75e34647d83cbd8190b7906 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Tue, 1 Sep 2020 13:10:23 -0400 Subject: Switch to upstream ENUM_MEMBER --- crates/rust-analyzer/src/semantic_tokens.rs | 2 +- crates/rust-analyzer/src/to_proto.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index 1225d3e35..a6c4d6099 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -24,6 +24,7 @@ macro_rules! define_semantic_token_types { SemanticTokenType::CLASS, SemanticTokenType::INTERFACE, SemanticTokenType::ENUM, + SemanticTokenType::ENUM_MEMBER, SemanticTokenType::TYPE_PARAMETER, SemanticTokenType::FUNCTION, SemanticTokenType::MEMBER, @@ -40,7 +41,6 @@ define_semantic_token_types![ (ATTRIBUTE, "attribute"), (BOOLEAN, "boolean"), (BUILTIN_TYPE, "builtinType"), - (ENUM_MEMBER, "enumMember"), (ESCAPE_SEQUENCE, "escapeSequence"), (FORMAT_SPECIFIER, "formatSpecifier"), (GENERIC, "generic"), diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 16aab52c2..dcbf837d6 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -369,7 +369,7 @@ fn semantic_token_type_and_modifiers( mods |= lsp_types::SemanticTokenModifier::STATIC; lsp_types::SemanticTokenType::VARIABLE } - HighlightTag::EnumVariant => semantic_tokens::ENUM_MEMBER, + HighlightTag::EnumVariant => lsp_types::SemanticTokenType::ENUM_MEMBER, HighlightTag::Macro => lsp_types::SemanticTokenType::MACRO, HighlightTag::ValueParam => lsp_types::SemanticTokenType::PARAMETER, HighlightTag::Local => lsp_types::SemanticTokenType::VARIABLE, -- cgit v1.2.3