mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Ensure that listing&resolving code actions use the same set of actions
This commit is contained in:
parent
fe29a9e837
commit
04b5fcfdb2
2 changed files with 43 additions and 23 deletions
|
@ -531,6 +531,34 @@ impl Analysis {
|
|||
self.with_db(|db| diagnostics::diagnostics(db, config, file_id))
|
||||
}
|
||||
|
||||
/// Convenience function to return assists + quick fixes for diagnostics
|
||||
pub fn assists_with_fixes(
|
||||
&self,
|
||||
assist_config: &AssistConfig,
|
||||
diagnostics_config: &DiagnosticsConfig,
|
||||
resolve: bool,
|
||||
frange: FileRange,
|
||||
) -> Cancelable<Vec<Assist>> {
|
||||
let include_fixes = match &assist_config.allowed {
|
||||
Some(it) => it.iter().any(|&it| it == AssistKind::None || it == AssistKind::QuickFix),
|
||||
None => true,
|
||||
};
|
||||
|
||||
self.with_db(|db| {
|
||||
let mut res = Assist::get(db, assist_config, resolve, frange);
|
||||
ssr::add_ssr_assist(db, &mut res, resolve, frange);
|
||||
|
||||
if include_fixes {
|
||||
res.extend(
|
||||
diagnostics::diagnostics(db, diagnostics_config, frange.file_id)
|
||||
.into_iter()
|
||||
.filter_map(|it| it.fix),
|
||||
);
|
||||
}
|
||||
res
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the edit required to rename reference at the position to the new
|
||||
/// name.
|
||||
pub fn rename(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue