mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Mark machine applicable fixes as preferred
This allows us to run the auto fix command from vscode to automatically fix all diagnostics in the file. They are also distinguished in the UI.
This commit is contained in:
parent
9210fcc076
commit
d7cd88b1a2
9 changed files with 20 additions and 0 deletions
|
@ -118,6 +118,7 @@ fn map_rust_child_diagnostic(
|
|||
changes: Some(edit_map),
|
||||
document_changes: None,
|
||||
}),
|
||||
is_preferred: Some(true),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -775,6 +775,7 @@ fn handle_fixes(
|
|||
group: None,
|
||||
kind: Some(CodeActionKind::QUICKFIX),
|
||||
edit: Some(edit),
|
||||
is_preferred: Some(false),
|
||||
};
|
||||
res.push(action);
|
||||
}
|
||||
|
|
|
@ -243,6 +243,7 @@ impl Request for CodeActionRequest {
|
|||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CodeAction {
|
||||
pub title: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -256,6 +257,8 @@ pub struct CodeAction {
|
|||
// pub command: Option<lsp_types::Command>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub edit: Option<SnippetWorkspaceEdit>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub is_preferred: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
|
||||
|
|
|
@ -652,6 +652,7 @@ pub(crate) fn unresolved_code_action(
|
|||
group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0),
|
||||
kind: Some(code_action_kind(assist.id.1)),
|
||||
edit: None,
|
||||
is_preferred: None,
|
||||
};
|
||||
Ok(res)
|
||||
}
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
document_changes: None,
|
||||
},
|
||||
),
|
||||
is_preferred: Some(
|
||||
true,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
document_changes: None,
|
||||
},
|
||||
),
|
||||
is_preferred: Some(
|
||||
true,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
document_changes: None,
|
||||
},
|
||||
),
|
||||
is_preferred: Some(
|
||||
true,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -93,6 +93,9 @@
|
|||
document_changes: None,
|
||||
},
|
||||
),
|
||||
is_preferred: Some(
|
||||
true,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -284,6 +284,7 @@ fn main() {}
|
|||
}
|
||||
]
|
||||
},
|
||||
"isPreferred": false,
|
||||
"kind": "quickfix",
|
||||
"title": "Create module"
|
||||
}]),
|
||||
|
@ -355,6 +356,7 @@ fn main() {{}}
|
|||
}
|
||||
]
|
||||
},
|
||||
"isPreferred": false,
|
||||
"kind": "quickfix",
|
||||
"title": "Create module"
|
||||
}]),
|
||||
|
|
Loading…
Reference in a new issue