aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
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.rs3
-rw-r--r--crates/rust-analyzer/src/to_proto.rs8
6 files changed, 24 insertions, 25 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..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 {
24 SemanticTokenType::CLASS, 24 SemanticTokenType::CLASS,
25 SemanticTokenType::INTERFACE, 25 SemanticTokenType::INTERFACE,
26 SemanticTokenType::ENUM, 26 SemanticTokenType::ENUM,
27 SemanticTokenType::ENUM_MEMBER,
27 SemanticTokenType::TYPE_PARAMETER, 28 SemanticTokenType::TYPE_PARAMETER,
28 SemanticTokenType::FUNCTION, 29 SemanticTokenType::FUNCTION,
29 SemanticTokenType::MEMBER, 30 SemanticTokenType::MEMBER,
@@ -31,7 +32,6 @@ macro_rules! define_semantic_token_types {
31 SemanticTokenType::MACRO, 32 SemanticTokenType::MACRO,
32 SemanticTokenType::VARIABLE, 33 SemanticTokenType::VARIABLE,
33 SemanticTokenType::PARAMETER, 34 SemanticTokenType::PARAMETER,
34 SemanticTokenType::LABEL,
35 $($ident),* 35 $($ident),*
36 ]; 36 ];
37 }; 37 };
@@ -41,7 +41,6 @@ define_semantic_token_types![
41 (ATTRIBUTE, "attribute"), 41 (ATTRIBUTE, "attribute"),
42 (BOOLEAN, "boolean"), 42 (BOOLEAN, "boolean"),
43 (BUILTIN_TYPE, "builtinType"), 43 (BUILTIN_TYPE, "builtinType"),
44 (ENUM_MEMBER, "enumMember"),
45 (ESCAPE_SEQUENCE, "escapeSequence"), 44 (ESCAPE_SEQUENCE, "escapeSequence"),
46 (FORMAT_SPECIFIER, "formatSpecifier"), 45 (FORMAT_SPECIFIER, "formatSpecifier"),
47 (GENERIC, "generic"), 46 (GENERIC, "generic"),
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index a8173a338..dcbf837d6 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(
@@ -369,7 +369,7 @@ fn semantic_token_type_and_modifiers(
369 mods |= lsp_types::SemanticTokenModifier::STATIC; 369 mods |= lsp_types::SemanticTokenModifier::STATIC;
370 lsp_types::SemanticTokenType::VARIABLE 370 lsp_types::SemanticTokenType::VARIABLE
371 } 371 }
372 HighlightTag::EnumVariant => semantic_tokens::ENUM_MEMBER, 372 HighlightTag::EnumVariant => lsp_types::SemanticTokenType::ENUM_MEMBER,
373 HighlightTag::Macro => lsp_types::SemanticTokenType::MACRO, 373 HighlightTag::Macro => lsp_types::SemanticTokenType::MACRO,
374 HighlightTag::ValueParam => lsp_types::SemanticTokenType::PARAMETER, 374 HighlightTag::ValueParam => lsp_types::SemanticTokenType::PARAMETER,
375 HighlightTag::Local => lsp_types::SemanticTokenType::VARIABLE, 375 HighlightTag::Local => lsp_types::SemanticTokenType::VARIABLE,