Skip to content

Commit aebf7ee

Browse files
bors[bot]matklad
andauthored
Merge #7028
7028: pit-of-success API for unresolved code actions r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 0632001 + 33384d2 commit aebf7ee

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

crates/ide/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,25 +490,25 @@ impl Analysis {
490490
.unwrap_or_default())
491491
}
492492

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+
493503
/// Computes resolved assists with source changes for the given position.
494-
pub fn resolved_assists(
504+
pub fn resolve_assists(
495505
&self,
496506
config: &AssistConfig,
497507
frange: FileRange,
498508
) -> Cancelable<Vec<ResolvedAssist>> {
499509
self.with_db(|db| assists::Assist::resolved(db, config, frange))
500510
}
501511

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-
512512
/// Computes the set of diagnostics for the given file.
513513
pub fn diagnostics(
514514
&self,

crates/rust-analyzer/src/handlers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,12 +946,12 @@ pub(crate) fn handle_code_action(
946946

947947
if snap.config.client_caps.code_action_resolve {
948948
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()
950950
{
951951
res.push(to_proto::unresolved_code_action(&snap, params.clone(), assist, index)?);
952952
}
953953
} 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() {
955955
res.push(to_proto::resolved_code_action(&snap, assist)?);
956956
}
957957
}
@@ -1014,7 +1014,7 @@ pub(crate) fn handle_code_action_resolve(
10141014
.only
10151015
.map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect());
10161016

1017-
let assists = snap.analysis.resolved_assists(&snap.config.assist, frange)?;
1017+
let assists = snap.analysis.resolve_assists(&snap.config.assist, frange)?;
10181018
let (id, index) = split_once(&params.id, ':').unwrap();
10191019
let index = index.parse::<usize>().unwrap();
10201020
let assist = &assists[index];

0 commit comments

Comments
 (0)