aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-24 12:50:30 +0000
committerGitHub <[email protected]>2020-12-24 12:50:30 +0000
commitaebf7ee2b65fdb51e125fc1461554cd9f673c60e (patch)
tree7b7ee3cecfe87f4a7a939687b72e7aaef0db06df
parent06320015af0c966df3deef9994b535fb110d303e (diff)
parent33384d289e246ea29c8e8103fef3099a6781e23b (diff)
Merge #7028
7028: pit-of-success API for unresolved code actions r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ide/src/lib.rs22
-rw-r--r--crates/rust-analyzer/src/handlers.rs6
2 files changed, 14 insertions, 14 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 52c7f9775..a75cc85b6 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -490,8 +490,18 @@ impl Analysis {
490 .unwrap_or_default()) 490 .unwrap_or_default())
491 } 491 }
492 492
493 /// Computes assists (aka code actions aka intentions) for the given
494 /// position. Computes enough info to show the lightbulb list in the editor,
495 /// but doesn't compute actual edits, to improve performance.
496 ///
497 /// When the user clicks on the assist, call `resolve_assists` to get the
498 /// edit.
499 pub fn assists(&self, config: &AssistConfig, frange: FileRange) -> Cancelable<Vec<Assist>> {
500 self.with_db(|db| Assist::unresolved(db, config, frange))
501 }
502
493 /// Computes resolved assists with source changes for the given position. 503 /// Computes resolved assists with source changes for the given position.
494 pub fn resolved_assists( 504 pub fn resolve_assists(
495 &self, 505 &self,
496 config: &AssistConfig, 506 config: &AssistConfig,
497 frange: FileRange, 507 frange: FileRange,
@@ -499,16 +509,6 @@ impl Analysis {
499 self.with_db(|db| assists::Assist::resolved(db, config, frange)) 509 self.with_db(|db| assists::Assist::resolved(db, config, frange))
500 } 510 }
501 511
502 /// Computes unresolved assists (aka code actions aka intentions) for the given
503 /// position.
504 pub fn unresolved_assists(
505 &self,
506 config: &AssistConfig,
507 frange: FileRange,
508 ) -> Cancelable<Vec<Assist>> {
509 self.with_db(|db| Assist::unresolved(db, config, frange))
510 }
511
512 /// Computes the set of diagnostics for the given file. 512 /// Computes the set of diagnostics for the given file.
513 pub fn diagnostics( 513 pub fn diagnostics(
514 &self, 514 &self,
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 25692793b..1207b31c4 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -946,12 +946,12 @@ pub(crate) fn handle_code_action(
946 946
947 if snap.config.client_caps.code_action_resolve { 947 if snap.config.client_caps.code_action_resolve {
948 for (index, assist) in 948 for (index, assist) in
949 snap.analysis.unresolved_assists(&assists_config, frange)?.into_iter().enumerate() 949 snap.analysis.assists(&assists_config, frange)?.into_iter().enumerate()
950 { 950 {
951 res.push(to_proto::unresolved_code_action(&snap, params.clone(), assist, index)?); 951 res.push(to_proto::unresolved_code_action(&snap, params.clone(), assist, index)?);
952 } 952 }
953 } else { 953 } else {
954 for assist in snap.analysis.resolved_assists(&assists_config, frange)?.into_iter() { 954 for assist in snap.analysis.resolve_assists(&assists_config, frange)?.into_iter() {
955 res.push(to_proto::resolved_code_action(&snap, assist)?); 955 res.push(to_proto::resolved_code_action(&snap, assist)?);
956 } 956 }
957 } 957 }
@@ -1014,7 +1014,7 @@ pub(crate) fn handle_code_action_resolve(
1014 .only 1014 .only
1015 .map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect()); 1015 .map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect());
1016 1016
1017 let assists = snap.analysis.resolved_assists(&snap.config.assist, frange)?; 1017 let assists = snap.analysis.resolve_assists(&snap.config.assist, frange)?;
1018 let (id, index) = split_once(&params.id, ':').unwrap(); 1018 let (id, index) = split_once(&params.id, ':').unwrap();
1019 let index = index.parse::<usize>().unwrap(); 1019 let index = index.parse::<usize>().unwrap();
1020 let assist = &assists[index]; 1020 let assist = &assists[index];