pit-of-success API for unresolved code actions
This commit is contained in:
parent
1487f2f10e
commit
33384d289e
@ -490,8 +490,18 @@ pub fn resolve_completion_edits(
|
|||||||
.unwrap_or_default())
|
.unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Computes assists (aka code actions aka intentions) for the given
|
||||||
|
/// position. Computes enough info to show the lightbulb list in the editor,
|
||||||
|
/// but doesn't compute actual edits, to improve performance.
|
||||||
|
///
|
||||||
|
/// When the user clicks on the assist, call `resolve_assists` to get the
|
||||||
|
/// edit.
|
||||||
|
pub fn assists(&self, config: &AssistConfig, frange: FileRange) -> Cancelable<Vec<Assist>> {
|
||||||
|
self.with_db(|db| Assist::unresolved(db, config, frange))
|
||||||
|
}
|
||||||
|
|
||||||
/// Computes resolved assists with source changes for the given position.
|
/// Computes resolved assists with source changes for the given position.
|
||||||
pub fn resolved_assists(
|
pub fn resolve_assists(
|
||||||
&self,
|
&self,
|
||||||
config: &AssistConfig,
|
config: &AssistConfig,
|
||||||
frange: FileRange,
|
frange: FileRange,
|
||||||
@ -499,16 +509,6 @@ pub fn resolved_assists(
|
|||||||
self.with_db(|db| assists::Assist::resolved(db, config, frange))
|
self.with_db(|db| assists::Assist::resolved(db, config, frange))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes unresolved assists (aka code actions aka intentions) for the given
|
|
||||||
/// position.
|
|
||||||
pub fn unresolved_assists(
|
|
||||||
&self,
|
|
||||||
config: &AssistConfig,
|
|
||||||
frange: FileRange,
|
|
||||||
) -> Cancelable<Vec<Assist>> {
|
|
||||||
self.with_db(|db| Assist::unresolved(db, config, frange))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Computes the set of diagnostics for the given file.
|
/// Computes the set of diagnostics for the given file.
|
||||||
pub fn diagnostics(
|
pub fn diagnostics(
|
||||||
&self,
|
&self,
|
||||||
|
@ -946,12 +946,12 @@ pub(crate) fn handle_code_action(
|
|||||||
|
|
||||||
if snap.config.client_caps.code_action_resolve {
|
if snap.config.client_caps.code_action_resolve {
|
||||||
for (index, assist) in
|
for (index, assist) in
|
||||||
snap.analysis.unresolved_assists(&assists_config, frange)?.into_iter().enumerate()
|
snap.analysis.assists(&assists_config, frange)?.into_iter().enumerate()
|
||||||
{
|
{
|
||||||
res.push(to_proto::unresolved_code_action(&snap, params.clone(), assist, index)?);
|
res.push(to_proto::unresolved_code_action(&snap, params.clone(), assist, index)?);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for assist in snap.analysis.resolved_assists(&assists_config, frange)?.into_iter() {
|
for assist in snap.analysis.resolve_assists(&assists_config, frange)?.into_iter() {
|
||||||
res.push(to_proto::resolved_code_action(&snap, assist)?);
|
res.push(to_proto::resolved_code_action(&snap, assist)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1014,7 +1014,7 @@ pub(crate) fn handle_code_action_resolve(
|
|||||||
.only
|
.only
|
||||||
.map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect());
|
.map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect());
|
||||||
|
|
||||||
let assists = snap.analysis.resolved_assists(&snap.config.assist, frange)?;
|
let assists = snap.analysis.resolve_assists(&snap.config.assist, frange)?;
|
||||||
let (id, index) = split_once(¶ms.id, ':').unwrap();
|
let (id, index) = split_once(¶ms.id, ':').unwrap();
|
||||||
let index = index.parse::<usize>().unwrap();
|
let index = index.parse::<usize>().unwrap();
|
||||||
let assist = &assists[index];
|
let assist = &assists[index];
|
||||||
|
Loading…
Reference in New Issue
Block a user