mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Rename
This commit is contained in:
parent
fdd4df97ba
commit
0970c3454b
4 changed files with 13 additions and 13 deletions
|
@ -22,16 +22,16 @@ pub(crate) struct Assist(pub(crate) Vec<AssistInfo>);
|
|||
pub(crate) struct AssistInfo {
|
||||
pub(crate) label: AssistLabel,
|
||||
pub(crate) group_label: Option<GroupLabel>,
|
||||
pub(crate) action: Option<SourceChange>,
|
||||
pub(crate) source_change: Option<SourceChange>,
|
||||
}
|
||||
|
||||
impl AssistInfo {
|
||||
fn new(label: AssistLabel) -> AssistInfo {
|
||||
AssistInfo { label, group_label: None, action: None }
|
||||
AssistInfo { label, group_label: None, source_change: None }
|
||||
}
|
||||
|
||||
fn resolved(self, action: SourceChange) -> AssistInfo {
|
||||
AssistInfo { action: Some(action), ..self }
|
||||
fn resolved(self, source_change: SourceChange) -> AssistInfo {
|
||||
AssistInfo { source_change: Some(source_change), ..self }
|
||||
}
|
||||
|
||||
fn with_group(self, group_label: GroupLabel) -> AssistInfo {
|
||||
|
@ -40,7 +40,7 @@ impl AssistInfo {
|
|||
|
||||
pub(crate) fn into_resolved(self) -> Option<ResolvedAssist> {
|
||||
let label = self.label;
|
||||
self.action.map(|action| ResolvedAssist { label, action })
|
||||
self.source_change.map(|source_change| ResolvedAssist { label, source_change })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,12 +104,12 @@ impl<'a> AssistCtx<'a> {
|
|||
let change_label = label.label.clone();
|
||||
let mut info = AssistInfo::new(label);
|
||||
if self.should_compute_edit {
|
||||
let action = {
|
||||
let source_change = {
|
||||
let mut edit = ActionBuilder::new(&self);
|
||||
f(&mut edit);
|
||||
edit.build(change_label, self.frange.file_id)
|
||||
};
|
||||
info = info.resolved(action)
|
||||
info = info.resolved(source_change)
|
||||
};
|
||||
|
||||
Some(Assist(vec![info]))
|
||||
|
@ -163,12 +163,12 @@ impl<'a> AssistGroup<'a> {
|
|||
let change_label = label.label.clone();
|
||||
let mut info = AssistInfo::new(label).with_group(self.group.clone());
|
||||
if self.ctx.should_compute_edit {
|
||||
let action = {
|
||||
let source_change = {
|
||||
let mut edit = ActionBuilder::new(&self.ctx);
|
||||
f(&mut edit);
|
||||
edit.build(change_label, self.ctx.frange.file_id)
|
||||
};
|
||||
info = info.resolved(action)
|
||||
info = info.resolved(source_change)
|
||||
};
|
||||
|
||||
self.assists.push(info)
|
||||
|
|
|
@ -59,7 +59,7 @@ impl AssistLabel {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct ResolvedAssist {
|
||||
pub label: AssistLabel,
|
||||
pub action: SourceChange,
|
||||
pub source_change: SourceChange,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
@ -57,7 +57,7 @@ fn check_doc_test(assist_id: &str, before: &str, after: &str) {
|
|||
});
|
||||
|
||||
let actual = {
|
||||
let change = assist.action.source_file_edits.pop().unwrap();
|
||||
let change = assist.source_change.source_file_edits.pop().unwrap();
|
||||
let mut actual = before.clone();
|
||||
change.edit.apply(&mut actual);
|
||||
actual
|
||||
|
@ -94,7 +94,7 @@ fn check(assist: Handler, before: &str, expected: ExpectedResult) {
|
|||
|
||||
match (assist(assist_ctx), expected) {
|
||||
(Some(assist), ExpectedResult::After(after)) => {
|
||||
let mut action = assist.0[0].action.clone().unwrap();
|
||||
let mut action = assist.0[0].source_change.clone().unwrap();
|
||||
let change = action.source_file_edits.pop().unwrap();
|
||||
|
||||
let mut actual = db.file_text(change.file_id).as_ref().to_owned();
|
||||
|
|
|
@ -478,7 +478,7 @@ impl Analysis {
|
|||
id: assist.label.id,
|
||||
label: assist.label.label,
|
||||
group_label: assist.label.group.map(|it| it.0),
|
||||
source_change: assist.action,
|
||||
source_change: assist.source_change,
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue