diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-17 12:12:40 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-17 12:12:40 +0100 |
commit | 2ca0e9e00e5a55bd591ae0a85fb00918b111e063 (patch) | |
tree | a53047df1fe84176007828f098184df7d394d9a5 /crates | |
parent | 9b5ac1d82fa3b9b810656e5b4a44d471b9923ce7 (diff) | |
parent | d7cd88b1a2169e50140730db4bd451350367e5ff (diff) |
Merge #5327
5327: Mark fixes from check as preferred r=matklad a=kjeremy
This allows us to run the auto fix command from vscode to automatically fix diagnostics in the file.
They are also distinguished in the UI.
Co-authored-by: Jeremy Kolb <[email protected]>
Diffstat (limited to 'crates')
9 files changed, 20 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 7be3ef984..97f331352 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -118,6 +118,7 @@ fn map_rust_child_diagnostic( | |||
118 | changes: Some(edit_map), | 118 | changes: Some(edit_map), |
119 | document_changes: None, | 119 | document_changes: None, |
120 | }), | 120 | }), |
121 | is_preferred: Some(true), | ||
121 | }) | 122 | }) |
122 | } | 123 | } |
123 | } | 124 | } |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 326977b62..d880570d2 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -770,6 +770,7 @@ fn handle_fixes( | |||
770 | group: None, | 770 | group: None, |
771 | kind: Some(CodeActionKind::QUICKFIX), | 771 | kind: Some(CodeActionKind::QUICKFIX), |
772 | edit: Some(edit), | 772 | edit: Some(edit), |
773 | is_preferred: Some(false), | ||
773 | }; | 774 | }; |
774 | res.push(action); | 775 | res.push(action); |
775 | } | 776 | } |
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index e216966a9..13ebb18fb 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs | |||
@@ -243,6 +243,7 @@ impl Request for CodeActionRequest { | |||
243 | } | 243 | } |
244 | 244 | ||
245 | #[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)] | 245 | #[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)] |
246 | #[serde(rename_all = "camelCase")] | ||
246 | pub struct CodeAction { | 247 | pub struct CodeAction { |
247 | pub title: String, | 248 | pub title: String, |
248 | #[serde(skip_serializing_if = "Option::is_none")] | 249 | #[serde(skip_serializing_if = "Option::is_none")] |
@@ -256,6 +257,8 @@ pub struct CodeAction { | |||
256 | // pub command: Option<lsp_types::Command>, | 257 | // pub command: Option<lsp_types::Command>, |
257 | #[serde(skip_serializing_if = "Option::is_none")] | 258 | #[serde(skip_serializing_if = "Option::is_none")] |
258 | pub edit: Option<SnippetWorkspaceEdit>, | 259 | pub edit: Option<SnippetWorkspaceEdit>, |
260 | #[serde(skip_serializing_if = "Option::is_none")] | ||
261 | pub is_preferred: Option<bool>, | ||
259 | } | 262 | } |
260 | 263 | ||
261 | #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] | 264 | #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 783012c1a..687432ddb 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -689,6 +689,7 @@ pub(crate) fn unresolved_code_action( | |||
689 | group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), | 689 | group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), |
690 | kind: Some(code_action_kind(assist.id.1)), | 690 | kind: Some(code_action_kind(assist.id.1)), |
691 | edit: None, | 691 | edit: None, |
692 | is_preferred: None, | ||
692 | }; | 693 | }; |
693 | Ok(res) | 694 | Ok(res) |
694 | } | 695 | } |
diff --git a/crates/rust-analyzer/test_data/rustc_unused_variable.txt b/crates/rust-analyzer/test_data/rustc_unused_variable.txt index 084632757..74d91bc77 100644 --- a/crates/rust-analyzer/test_data/rustc_unused_variable.txt +++ b/crates/rust-analyzer/test_data/rustc_unused_variable.txt | |||
@@ -65,6 +65,9 @@ | |||
65 | document_changes: None, | 65 | document_changes: None, |
66 | }, | 66 | }, |
67 | ), | 67 | ), |
68 | is_preferred: Some( | ||
69 | true, | ||
70 | ), | ||
68 | }, | 71 | }, |
69 | ], | 72 | ], |
70 | }, | 73 | }, |
diff --git a/crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt b/crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt index d637923c5..8a420c949 100644 --- a/crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt +++ b/crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt | |||
@@ -65,6 +65,9 @@ | |||
65 | document_changes: None, | 65 | document_changes: None, |
66 | }, | 66 | }, |
67 | ), | 67 | ), |
68 | is_preferred: Some( | ||
69 | true, | ||
70 | ), | ||
68 | }, | 71 | }, |
69 | ], | 72 | ], |
70 | }, | 73 | }, |
diff --git a/crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt b/crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt index 6b48f16ed..79910660b 100644 --- a/crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt +++ b/crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt | |||
@@ -65,6 +65,9 @@ | |||
65 | document_changes: None, | 65 | document_changes: None, |
66 | }, | 66 | }, |
67 | ), | 67 | ), |
68 | is_preferred: Some( | ||
69 | true, | ||
70 | ), | ||
68 | }, | 71 | }, |
69 | ], | 72 | ], |
70 | }, | 73 | }, |
diff --git a/crates/rust-analyzer/test_data/snap_multi_line_fix.txt b/crates/rust-analyzer/test_data/snap_multi_line_fix.txt index 2c4cbea16..4f811ab64 100644 --- a/crates/rust-analyzer/test_data/snap_multi_line_fix.txt +++ b/crates/rust-analyzer/test_data/snap_multi_line_fix.txt | |||
@@ -93,6 +93,9 @@ | |||
93 | document_changes: None, | 93 | document_changes: None, |
94 | }, | 94 | }, |
95 | ), | 95 | ), |
96 | is_preferred: Some( | ||
97 | true, | ||
98 | ), | ||
96 | }, | 99 | }, |
97 | ], | 100 | ], |
98 | }, | 101 | }, |
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs index 7b908d30c..f12e5a37f 100644 --- a/crates/rust-analyzer/tests/heavy_tests/main.rs +++ b/crates/rust-analyzer/tests/heavy_tests/main.rs | |||
@@ -284,6 +284,7 @@ fn main() {} | |||
284 | } | 284 | } |
285 | ] | 285 | ] |
286 | }, | 286 | }, |
287 | "isPreferred": false, | ||
287 | "kind": "quickfix", | 288 | "kind": "quickfix", |
288 | "title": "Create module" | 289 | "title": "Create module" |
289 | }]), | 290 | }]), |
@@ -355,6 +356,7 @@ fn main() {{}} | |||
355 | } | 356 | } |
356 | ] | 357 | ] |
357 | }, | 358 | }, |
359 | "isPreferred": false, | ||
358 | "kind": "quickfix", | 360 | "kind": "quickfix", |
359 | "title": "Create module" | 361 | "title": "Create module" |
360 | }]), | 362 | }]), |