diff options
Diffstat (limited to 'crates')
17 files changed, 57 insertions, 3 deletions
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 975b24aaf..d25c4bf83 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -21,7 +21,7 @@ env_logger = { version = "0.8.1", default-features = false } | |||
21 | itertools = "0.9.0" | 21 | itertools = "0.9.0" |
22 | jod-thread = "0.1.0" | 22 | jod-thread = "0.1.0" |
23 | log = "0.4.8" | 23 | log = "0.4.8" |
24 | lsp-types = { version = "0.82.0", features = ["proposed"] } | 24 | lsp-types = { version = "0.83.0", features = ["proposed"] } |
25 | parking_lot = "0.11.0" | 25 | parking_lot = "0.11.0" |
26 | pico-args = "0.3.1" | 26 | pico-args = "0.3.1" |
27 | oorandom = "11.1.2" | 27 | oorandom = "11.1.2" |
diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index c589afeaf..ff1ae9575 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs | |||
@@ -48,7 +48,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti | |||
48 | references_provider: Some(OneOf::Left(true)), | 48 | references_provider: Some(OneOf::Left(true)), |
49 | document_highlight_provider: Some(OneOf::Left(true)), | 49 | document_highlight_provider: Some(OneOf::Left(true)), |
50 | document_symbol_provider: Some(OneOf::Left(true)), | 50 | document_symbol_provider: Some(OneOf::Left(true)), |
51 | workspace_symbol_provider: Some(true), | 51 | workspace_symbol_provider: Some(OneOf::Left(true)), |
52 | code_action_provider: Some(code_action_provider), | 52 | code_action_provider: Some(code_action_provider), |
53 | code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(true) }), | 53 | code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(true) }), |
54 | document_formatting_provider: Some(OneOf::Left(true)), | 54 | document_formatting_provider: Some(OneOf::Left(true)), |
@@ -113,6 +113,7 @@ fn code_action_capabilities(client_caps: &ClientCapabilities) -> CodeActionProvi | |||
113 | CodeActionKind::REFACTOR_INLINE, | 113 | CodeActionKind::REFACTOR_INLINE, |
114 | CodeActionKind::REFACTOR_REWRITE, | 114 | CodeActionKind::REFACTOR_REWRITE, |
115 | ]), | 115 | ]), |
116 | resolve_provider: None, | ||
116 | work_done_progress_options: Default::default(), | 117 | work_done_progress_options: Default::default(), |
117 | }) | 118 | }) |
118 | }) | 119 | }) |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 1b9b24698..2ed6a0d82 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -47,6 +47,7 @@ pub struct Config { | |||
47 | pub call_info_full: bool, | 47 | pub call_info_full: bool, |
48 | pub lens: LensConfig, | 48 | pub lens: LensConfig, |
49 | pub hover: HoverConfig, | 49 | pub hover: HoverConfig, |
50 | pub semantic_tokens_refresh: bool, | ||
50 | 51 | ||
51 | pub with_sysroot: bool, | 52 | pub with_sysroot: bool, |
52 | pub linked_projects: Vec<LinkedProject>, | 53 | pub linked_projects: Vec<LinkedProject>, |
@@ -193,6 +194,7 @@ impl Config { | |||
193 | call_info_full: true, | 194 | call_info_full: true, |
194 | lens: LensConfig::default(), | 195 | lens: LensConfig::default(), |
195 | hover: HoverConfig::default(), | 196 | hover: HoverConfig::default(), |
197 | semantic_tokens_refresh: false, | ||
196 | linked_projects: Vec::new(), | 198 | linked_projects: Vec::new(), |
197 | root_path, | 199 | root_path, |
198 | } | 200 | } |
@@ -402,6 +404,14 @@ impl Config { | |||
402 | self.client_caps.hover_actions = get_bool("hoverActions"); | 404 | self.client_caps.hover_actions = get_bool("hoverActions"); |
403 | self.client_caps.status_notification = get_bool("statusNotification"); | 405 | self.client_caps.status_notification = get_bool("statusNotification"); |
404 | } | 406 | } |
407 | |||
408 | if let Some(workspace_caps) = caps.workspace.as_ref() { | ||
409 | if let Some(refresh_support) = | ||
410 | workspace_caps.semantic_tokens.as_ref().and_then(|it| it.refresh_support) | ||
411 | { | ||
412 | self.semantic_tokens_refresh = refresh_support; | ||
413 | } | ||
414 | } | ||
405 | } | 415 | } |
406 | } | 416 | } |
407 | 417 | ||
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt index d06517126..58d47d32a 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt | |||
@@ -20,6 +20,7 @@ | |||
20 | "trivially_copy_pass_by_ref", | 20 | "trivially_copy_pass_by_ref", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "clippy", | 25 | "clippy", |
25 | ), | 26 | ), |
@@ -61,6 +62,7 @@ | |||
61 | ], | 62 | ], |
62 | ), | 63 | ), |
63 | tags: None, | 64 | tags: None, |
65 | data: None, | ||
64 | }, | 66 | }, |
65 | fixes: [], | 67 | fixes: [], |
66 | }, | 68 | }, |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt b/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt index f5de2f07f..6aa26bf63 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt | |||
@@ -20,12 +20,14 @@ | |||
20 | "E0277", | 20 | "E0277", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "rustc", | 25 | "rustc", |
25 | ), | 26 | ), |
26 | message: "can\'t compare `{integer}` with `&str`\nthe trait `std::cmp::PartialEq<&str>` is not implemented for `{integer}`", | 27 | message: "can\'t compare `{integer}` with `&str`\nthe trait `std::cmp::PartialEq<&str>` is not implemented for `{integer}`", |
27 | related_information: None, | 28 | related_information: None, |
28 | tags: None, | 29 | tags: None, |
30 | data: None, | ||
29 | }, | 31 | }, |
30 | fixes: [], | 32 | fixes: [], |
31 | }, | 33 | }, |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt b/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt index 00e8da8a7..7aaffaba2 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt | |||
@@ -16,6 +16,7 @@ | |||
16 | Error, | 16 | Error, |
17 | ), | 17 | ), |
18 | code: None, | 18 | code: None, |
19 | code_description: None, | ||
19 | source: Some( | 20 | source: Some( |
20 | "rustc", | 21 | "rustc", |
21 | ), | 22 | ), |
@@ -41,6 +42,7 @@ | |||
41 | ], | 42 | ], |
42 | ), | 43 | ), |
43 | tags: None, | 44 | tags: None, |
45 | data: None, | ||
44 | }, | 46 | }, |
45 | fixes: [], | 47 | fixes: [], |
46 | }, | 48 | }, |
@@ -61,6 +63,7 @@ | |||
61 | Error, | 63 | Error, |
62 | ), | 64 | ), |
63 | code: None, | 65 | code: None, |
66 | code_description: None, | ||
64 | source: Some( | 67 | source: Some( |
65 | "rustc", | 68 | "rustc", |
66 | ), | 69 | ), |
@@ -86,6 +89,7 @@ | |||
86 | ], | 89 | ], |
87 | ), | 90 | ), |
88 | tags: None, | 91 | tags: None, |
92 | data: None, | ||
89 | }, | 93 | }, |
90 | fixes: [], | 94 | fixes: [], |
91 | }, | 95 | }, |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt index fc54440be..584213420 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt | |||
@@ -20,12 +20,14 @@ | |||
20 | "E0053", | 20 | "E0053", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "rustc", | 25 | "rustc", |
25 | ), | 26 | ), |
26 | message: "method `next` has an incompatible type for trait\nexpected type `fn(&mut ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&ty::Ref<M>>`\n found type `fn(&ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&\'list ty::Ref<M>>`", | 27 | message: "method `next` has an incompatible type for trait\nexpected type `fn(&mut ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&ty::Ref<M>>`\n found type `fn(&ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&\'list ty::Ref<M>>`", |
27 | related_information: None, | 28 | related_information: None, |
28 | tags: None, | 29 | tags: None, |
30 | data: None, | ||
29 | }, | 31 | }, |
30 | fixes: [], | 32 | fixes: [], |
31 | }, | 33 | }, |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt index c269af218..2610e4e20 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt | |||
@@ -20,12 +20,14 @@ | |||
20 | "E0308", | 20 | "E0308", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "rustc", | 25 | "rustc", |
25 | ), | 26 | ), |
26 | message: "mismatched types\nexpected usize, found u32", | 27 | message: "mismatched types\nexpected usize, found u32", |
27 | related_information: None, | 28 | related_information: None, |
28 | tags: None, | 29 | tags: None, |
30 | data: None, | ||
29 | }, | 31 | }, |
30 | fixes: [], | 32 | fixes: [], |
31 | }, | 33 | }, |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt index 74d91bc77..8dc53391e 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt | |||
@@ -20,6 +20,7 @@ | |||
20 | "unused_variables", | 20 | "unused_variables", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "rustc", | 25 | "rustc", |
25 | ), | 26 | ), |
@@ -30,6 +31,7 @@ | |||
30 | Unnecessary, | 31 | Unnecessary, |
31 | ], | 32 | ], |
32 | ), | 33 | ), |
34 | data: None, | ||
33 | }, | 35 | }, |
34 | fixes: [ | 36 | fixes: [ |
35 | CodeAction { | 37 | CodeAction { |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt index 8a420c949..c8703194c 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt | |||
@@ -20,6 +20,7 @@ | |||
20 | "unused_variables", | 20 | "unused_variables", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "rustc", | 25 | "rustc", |
25 | ), | 26 | ), |
@@ -30,6 +31,7 @@ | |||
30 | Unnecessary, | 31 | Unnecessary, |
31 | ], | 32 | ], |
32 | ), | 33 | ), |
34 | data: None, | ||
33 | }, | 35 | }, |
34 | fixes: [ | 36 | fixes: [ |
35 | CodeAction { | 37 | CodeAction { |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt index 79910660b..dc93227ad 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt | |||
@@ -20,6 +20,7 @@ | |||
20 | "unused_variables", | 20 | "unused_variables", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "rustc", | 25 | "rustc", |
25 | ), | 26 | ), |
@@ -30,6 +31,7 @@ | |||
30 | Unnecessary, | 31 | Unnecessary, |
31 | ], | 32 | ], |
32 | ), | 33 | ), |
34 | data: None, | ||
33 | }, | 35 | }, |
34 | fixes: [ | 36 | fixes: [ |
35 | CodeAction { | 37 | CodeAction { |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt index efe37261d..ba1b98b33 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt | |||
@@ -20,6 +20,7 @@ | |||
20 | "E0061", | 20 | "E0061", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "rustc", | 25 | "rustc", |
25 | ), | 26 | ), |
@@ -45,6 +46,7 @@ | |||
45 | ], | 46 | ], |
46 | ), | 47 | ), |
47 | tags: None, | 48 | tags: None, |
49 | data: None, | ||
48 | }, | 50 | }, |
49 | fixes: [], | 51 | fixes: [], |
50 | }, | 52 | }, |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt index 4f811ab64..81f752672 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt | |||
@@ -20,6 +20,7 @@ | |||
20 | "let_and_return", | 20 | "let_and_return", |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | code_description: None, | ||
23 | source: Some( | 24 | source: Some( |
24 | "clippy", | 25 | "clippy", |
25 | ), | 26 | ), |
@@ -45,6 +46,7 @@ | |||
45 | ], | 46 | ], |
46 | ), | 47 | ), |
47 | tags: None, | 48 | tags: None, |
49 | data: None, | ||
48 | }, | 50 | }, |
49 | fixes: [ | 51 | fixes: [ |
50 | CodeAction { | 52 | CodeAction { |
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 33606edda..b949577c1 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -248,10 +248,12 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
248 | range: in_macro_location.range, | 248 | range: in_macro_location.range, |
249 | severity, | 249 | severity, |
250 | code: code.clone().map(lsp_types::NumberOrString::String), | 250 | code: code.clone().map(lsp_types::NumberOrString::String), |
251 | code_description: None, | ||
251 | source: Some(source.clone()), | 252 | source: Some(source.clone()), |
252 | message: message.clone(), | 253 | message: message.clone(), |
253 | related_information: Some(information_for_additional_diagnostic), | 254 | related_information: Some(information_for_additional_diagnostic), |
254 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, | 255 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, |
256 | data: None, | ||
255 | }; | 257 | }; |
256 | 258 | ||
257 | Some(MappedRustDiagnostic { | 259 | Some(MappedRustDiagnostic { |
@@ -267,6 +269,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
267 | range: location.range, | 269 | range: location.range, |
268 | severity, | 270 | severity, |
269 | code: code.clone().map(lsp_types::NumberOrString::String), | 271 | code: code.clone().map(lsp_types::NumberOrString::String), |
272 | code_description: None, | ||
270 | source: Some(source.clone()), | 273 | source: Some(source.clone()), |
271 | message, | 274 | message, |
272 | related_information: if related_information.is_empty() { | 275 | related_information: if related_information.is_empty() { |
@@ -275,6 +278,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
275 | Some(related_information.clone()) | 278 | Some(related_information.clone()) |
276 | }, | 279 | }, |
277 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, | 280 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, |
281 | data: None, | ||
278 | }; | 282 | }; |
279 | 283 | ||
280 | let main_diagnostic = | 284 | let main_diagnostic = |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 2680e5f08..049c583a4 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -1121,10 +1121,12 @@ pub(crate) fn publish_diagnostics( | |||
1121 | range: to_proto::range(&line_index, d.range), | 1121 | range: to_proto::range(&line_index, d.range), |
1122 | severity: Some(to_proto::diagnostic_severity(d.severity)), | 1122 | severity: Some(to_proto::diagnostic_severity(d.severity)), |
1123 | code: None, | 1123 | code: None, |
1124 | code_description: None, | ||
1124 | source: Some("rust-analyzer".to_string()), | 1125 | source: Some("rust-analyzer".to_string()), |
1125 | message: d.message, | 1126 | message: d.message, |
1126 | related_information: None, | 1127 | related_information: None, |
1127 | tags: if d.unused { Some(vec![DiagnosticTag::Unnecessary]) } else { None }, | 1128 | tags: if d.unused { Some(vec![DiagnosticTag::Unnecessary]) } else { None }, |
1129 | data: None, | ||
1128 | }) | 1130 | }) |
1129 | .collect(); | 1131 | .collect(); |
1130 | Ok(diagnostics) | 1132 | Ok(diagnostics) |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index ed5292733..ff855fe1a 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -330,6 +330,12 @@ impl GlobalState { | |||
330 | .collect::<Vec<_>>(); | 330 | .collect::<Vec<_>>(); |
331 | 331 | ||
332 | self.update_file_notifications_on_threadpool(subscriptions); | 332 | self.update_file_notifications_on_threadpool(subscriptions); |
333 | |||
334 | // Refresh semantic tokens if the client supports it. | ||
335 | if self.config.semantic_tokens_refresh { | ||
336 | self.semantic_tokens_cache.lock().clear(); | ||
337 | self.send_request::<lsp_types::request::SemanticTokensRefesh>((), |_, _| ()); | ||
338 | } | ||
333 | } | 339 | } |
334 | 340 | ||
335 | if let Some(diagnostic_changes) = self.diagnostics.take_changes() { | 341 | if let Some(diagnostic_changes) = self.diagnostics.take_changes() { |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 24a658fc6..92b7c7b68 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -709,7 +709,16 @@ pub(crate) fn call_hierarchy_item( | |||
709 | let detail = target.description.clone(); | 709 | let detail = target.description.clone(); |
710 | let kind = symbol_kind(target.kind); | 710 | let kind = symbol_kind(target.kind); |
711 | let (uri, range, selection_range) = location_info(snap, target)?; | 711 | let (uri, range, selection_range) = location_info(snap, target)?; |
712 | Ok(lsp_types::CallHierarchyItem { name, kind, tags: None, detail, uri, range, selection_range }) | 712 | Ok(lsp_types::CallHierarchyItem { |
713 | name, | ||
714 | kind, | ||
715 | tags: None, | ||
716 | detail, | ||
717 | uri, | ||
718 | range, | ||
719 | selection_range, | ||
720 | data: None, | ||
721 | }) | ||
713 | } | 722 | } |
714 | 723 | ||
715 | pub(crate) fn code_action_kind(kind: AssistKind) -> lsp_types::CodeActionKind { | 724 | pub(crate) fn code_action_kind(kind: AssistKind) -> lsp_types::CodeActionKind { |