diff options
author | Kirill Bulatov <[email protected]> | 2021-05-03 15:08:09 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-05-03 15:14:49 +0100 |
commit | e5cdcb8b124f5b7d59950429787e760e46388f72 (patch) | |
tree | 8740336ea373603a48542d911da6765645a02627 /crates/rust-analyzer/src/handlers.rs | |
parent | eb741e895f1a73420a401f2495c711afe37d9d19 (diff) |
Add a way to resolve certain assists
Diffstat (limited to 'crates/rust-analyzer/src/handlers.rs')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 1f59402e5..dc350c01f 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -8,8 +8,9 @@ use std::{ | |||
8 | }; | 8 | }; |
9 | 9 | ||
10 | use ide::{ | 10 | use ide::{ |
11 | AnnotationConfig, FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, Query, | 11 | AnnotationConfig, AssistResolveStrategy, FileId, FilePosition, FileRange, HoverAction, |
12 | RangeInfo, Runnable, RunnableKind, SearchScope, SourceChange, TextEdit, | 12 | HoverGotoTypeData, Query, RangeInfo, Runnable, RunnableKind, SearchScope, SourceChange, |
13 | TextEdit, | ||
13 | }; | 14 | }; |
14 | use ide_db::SymbolKind; | 15 | use ide_db::SymbolKind; |
15 | use itertools::Itertools; | 16 | use itertools::Itertools; |
@@ -1004,10 +1005,15 @@ pub(crate) fn handle_code_action( | |||
1004 | let mut res: Vec<lsp_ext::CodeAction> = Vec::new(); | 1005 | let mut res: Vec<lsp_ext::CodeAction> = Vec::new(); |
1005 | 1006 | ||
1006 | let code_action_resolve_cap = snap.config.code_action_resolve(); | 1007 | let code_action_resolve_cap = snap.config.code_action_resolve(); |
1008 | let resolve = if code_action_resolve_cap { | ||
1009 | AssistResolveStrategy::None | ||
1010 | } else { | ||
1011 | AssistResolveStrategy::All | ||
1012 | }; | ||
1007 | let assists = snap.analysis.assists_with_fixes( | 1013 | let assists = snap.analysis.assists_with_fixes( |
1008 | &assists_config, | 1014 | &assists_config, |
1009 | &snap.config.diagnostics(), | 1015 | &snap.config.diagnostics(), |
1010 | !code_action_resolve_cap, | 1016 | resolve, |
1011 | frange, | 1017 | frange, |
1012 | )?; | 1018 | )?; |
1013 | for (index, assist) in assists.into_iter().enumerate() { | 1019 | for (index, assist) in assists.into_iter().enumerate() { |
@@ -1055,7 +1061,8 @@ pub(crate) fn handle_code_action_resolve( | |||
1055 | let assists = snap.analysis.assists_with_fixes( | 1061 | let assists = snap.analysis.assists_with_fixes( |
1056 | &assists_config, | 1062 | &assists_config, |
1057 | &snap.config.diagnostics(), | 1063 | &snap.config.diagnostics(), |
1058 | true, | 1064 | // TODO kb pass a certain id |
1065 | AssistResolveStrategy::All, | ||
1059 | frange, | 1066 | frange, |
1060 | )?; | 1067 | )?; |
1061 | 1068 | ||
@@ -1182,7 +1189,7 @@ pub(crate) fn publish_diagnostics( | |||
1182 | 1189 | ||
1183 | let diagnostics: Vec<Diagnostic> = snap | 1190 | let diagnostics: Vec<Diagnostic> = snap |
1184 | .analysis | 1191 | .analysis |
1185 | .diagnostics(&snap.config.diagnostics(), false, file_id)? | 1192 | .diagnostics(&snap.config.diagnostics(), AssistResolveStrategy::None, file_id)? |
1186 | .into_iter() | 1193 | .into_iter() |
1187 | .map(|d| Diagnostic { | 1194 | .map(|d| Diagnostic { |
1188 | range: to_proto::range(&line_index, d.range), | 1195 | range: to_proto::range(&line_index, d.range), |