aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2020-09-01 17:53:07 +0100
committerkjeremy <[email protected]>2020-09-02 14:40:59 +0100
commitb5272573300766d0c8417161c1a4f959abc9ff43 (patch)
treea22977735d0e6de4efd0395ac9dc64c70d0fc486 /crates
parent3ffa915cbcf4d7a3988142cd94da0463acc87c8a (diff)
Move to vscode-languageclient 7.0.0-next.9
Stabilizes call hierarchy and semantic tokens features.
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/Cargo.toml2
-rw-r--r--crates/rust-analyzer/src/caps.rs8
-rw-r--r--crates/rust-analyzer/src/handlers.rs20
-rw-r--r--crates/rust-analyzer/src/main_loop.rs8
-rw-r--r--crates/rust-analyzer/src/semantic_tokens.rs1
-rw-r--r--crates/rust-analyzer/src/to_proto.rs6
6 files changed, 22 insertions, 23 deletions
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 }
21itertools = "0.9.0" 21itertools = "0.9.0"
22jod-thread = "0.1.0" 22jod-thread = "0.1.0"
23log = "0.4.8" 23log = "0.4.8"
24lsp-types = { version = "0.79.0", features = ["proposed"] } 24lsp-types = { version = "0.80.0", features = ["proposed"] }
25parking_lot = "0.11.0" 25parking_lot = "0.11.0"
26pico-args = "0.3.1" 26pico-args = "0.3.1"
27oorandom = "11.1.2" 27oorandom = "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::{
6 CodeActionProviderCapability, CodeLensOptions, CompletionOptions, 6 CodeActionProviderCapability, CodeLensOptions, CompletionOptions,
7 DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, HoverProviderCapability, 7 DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, HoverProviderCapability,
8 ImplementationProviderCapability, RenameOptions, RenameProviderCapability, SaveOptions, 8 ImplementationProviderCapability, RenameOptions, RenameProviderCapability, SaveOptions,
9 SelectionRangeProviderCapability, SemanticTokensDocumentProvider, SemanticTokensLegend, 9 SelectionRangeProviderCapability, SemanticTokensFullOptions, SemanticTokensLegend,
10 SemanticTokensOptions, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, 10 SemanticTokensOptions, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability,
11 TextDocumentSyncKind, TextDocumentSyncOptions, TypeDefinitionProviderCapability, 11 TextDocumentSyncKind, TextDocumentSyncOptions, TypeDefinitionProviderCapability,
12 WorkDoneProgressOptions, 12 WorkDoneProgressOptions,
@@ -76,10 +76,8 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
76 token_modifiers: semantic_tokens::SUPPORTED_MODIFIERS.to_vec(), 76 token_modifiers: semantic_tokens::SUPPORTED_MODIFIERS.to_vec(),
77 }, 77 },
78 78
79 document_provider: Some(SemanticTokensDocumentProvider::Edits { 79 full: Some(SemanticTokensFullOptions::Delta { delta: Some(true) }),
80 edits: Some(true), 80 range: Some(true),
81 }),
82 range_provider: Some(true),
83 work_done_progress_options: Default::default(), 81 work_done_progress_options: Default::default(),
84 } 82 }
85 .into(), 83 .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::{
17 CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams, 17 CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams,
18 CodeActionKind, CodeLens, Command, CompletionItem, Diagnostic, DocumentFormattingParams, 18 CodeActionKind, CodeLens, Command, CompletionItem, Diagnostic, DocumentFormattingParams,
19 DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, 19 DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location,
20 Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensEditResult, 20 Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensDeltaParams,
21 SemanticTokensEditsParams, SemanticTokensParams, SemanticTokensRangeParams, 21 SemanticTokensFullDeltaResult, SemanticTokensParams, SemanticTokensRangeParams,
22 SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag, 22 SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag,
23 TextDocumentIdentifier, Url, WorkspaceEdit, 23 TextDocumentIdentifier, Url, WorkspaceEdit,
24}; 24};
@@ -1171,11 +1171,11 @@ pub(crate) fn handle_call_hierarchy_outgoing(
1171 Ok(Some(res)) 1171 Ok(Some(res))
1172} 1172}
1173 1173
1174pub(crate) fn handle_semantic_tokens( 1174pub(crate) fn handle_semantic_tokens_full(
1175 snap: GlobalStateSnapshot, 1175 snap: GlobalStateSnapshot,
1176 params: SemanticTokensParams, 1176 params: SemanticTokensParams,
1177) -> Result<Option<SemanticTokensResult>> { 1177) -> Result<Option<SemanticTokensResult>> {
1178 let _p = profile::span("handle_semantic_tokens"); 1178 let _p = profile::span("handle_semantic_tokens_full");
1179 1179
1180 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 1180 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
1181 let text = snap.analysis.file_text(file_id)?; 1181 let text = snap.analysis.file_text(file_id)?;
@@ -1190,11 +1190,11 @@ pub(crate) fn handle_semantic_tokens(
1190 Ok(Some(semantic_tokens.into())) 1190 Ok(Some(semantic_tokens.into()))
1191} 1191}
1192 1192
1193pub(crate) fn handle_semantic_tokens_edits( 1193pub(crate) fn handle_semantic_tokens_full_delta(
1194 snap: GlobalStateSnapshot, 1194 snap: GlobalStateSnapshot,
1195 params: SemanticTokensEditsParams, 1195 params: SemanticTokensDeltaParams,
1196) -> Result<Option<SemanticTokensEditResult>> { 1196) -> Result<Option<SemanticTokensFullDeltaResult>> {
1197 let _p = profile::span("handle_semantic_tokens_edits"); 1197 let _p = profile::span("handle_semantic_tokens_full_delta");
1198 1198
1199 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 1199 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
1200 let text = snap.analysis.file_text(file_id)?; 1200 let text = snap.analysis.file_text(file_id)?;
@@ -1209,9 +1209,9 @@ pub(crate) fn handle_semantic_tokens_edits(
1209 1209
1210 if let Some(prev_id) = &cached_tokens.result_id { 1210 if let Some(prev_id) = &cached_tokens.result_id {
1211 if *prev_id == params.previous_result_id { 1211 if *prev_id == params.previous_result_id {
1212 let edits = to_proto::semantic_token_edits(&cached_tokens, &semantic_tokens); 1212 let delta = to_proto::semantic_token_delta(&cached_tokens, &semantic_tokens);
1213 *cached_tokens = semantic_tokens; 1213 *cached_tokens = semantic_tokens;
1214 return Ok(Some(edits.into())); 1214 return Ok(Some(delta.into()));
1215 } 1215 }
1216 } 1216 }
1217 1217
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 {
407 .on::<lsp_types::request::CallHierarchyOutgoingCalls>( 407 .on::<lsp_types::request::CallHierarchyOutgoingCalls>(
408 handlers::handle_call_hierarchy_outgoing, 408 handlers::handle_call_hierarchy_outgoing,
409 )? 409 )?
410 .on::<lsp_types::request::SemanticTokensRequest>(handlers::handle_semantic_tokens)? 410 .on::<lsp_types::request::SemanticTokensFullRequest>(
411 .on::<lsp_types::request::SemanticTokensEditsRequest>( 411 handlers::handle_semantic_tokens_full,
412 handlers::handle_semantic_tokens_edits, 412 )?
413 .on::<lsp_types::request::SemanticTokensFullDeltaRequest>(
414 handlers::handle_semantic_tokens_full_delta,
413 )? 415 )?
414 .on::<lsp_types::request::SemanticTokensRangeRequest>( 416 .on::<lsp_types::request::SemanticTokensRangeRequest>(
415 handlers::handle_semantic_tokens_range, 417 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 {
31 SemanticTokenType::MACRO, 31 SemanticTokenType::MACRO,
32 SemanticTokenType::VARIABLE, 32 SemanticTokenType::VARIABLE,
33 SemanticTokenType::PARAMETER, 33 SemanticTokenType::PARAMETER,
34 SemanticTokenType::LABEL,
35 $($ident),* 34 $($ident),*
36 ]; 35 ];
37 }; 36 };
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(
334 builder.build() 334 builder.build()
335} 335}
336 336
337pub(crate) fn semantic_token_edits( 337pub(crate) fn semantic_token_delta(
338 previous: &lsp_types::SemanticTokens, 338 previous: &lsp_types::SemanticTokens,
339 current: &lsp_types::SemanticTokens, 339 current: &lsp_types::SemanticTokens,
340) -> lsp_types::SemanticTokensEdits { 340) -> lsp_types::SemanticTokensDelta {
341 let result_id = current.result_id.clone(); 341 let result_id = current.result_id.clone();
342 let edits = semantic_tokens::diff_tokens(&previous.data, &current.data); 342 let edits = semantic_tokens::diff_tokens(&previous.data, &current.data);
343 lsp_types::SemanticTokensEdits { result_id, edits } 343 lsp_types::SemanticTokensDelta { result_id, edits }
344} 344}
345 345
346fn semantic_token_type_and_modifiers( 346fn semantic_token_type_and_modifiers(