mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Rename source_edit to source_file_edit to match file_system_edit
This commit is contained in:
parent
b92fcbc956
commit
4d26bae46d
5 changed files with 11 additions and 11 deletions
|
@ -17,7 +17,7 @@ pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
|
||||||
let file_id = frange.file_id;
|
let file_id = frange.file_id;
|
||||||
let file_edit = SourceFileEdit { file_id, edit: action.edit };
|
let file_edit = SourceFileEdit { file_id, edit: action.edit };
|
||||||
let id = label.id;
|
let id = label.id;
|
||||||
let change = SourceChange::source_edit(label.label, file_edit).with_cursor_opt(
|
let change = SourceChange::source_file_edit(label.label, file_edit).with_cursor_opt(
|
||||||
action.cursor_position.map(|offset| FilePosition { offset, file_id }),
|
action.cursor_position.map(|offset| FilePosition { offset, file_id }),
|
||||||
);
|
);
|
||||||
Assist { id, change }
|
Assist { id, change }
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn check_unnecessary_braces_in_use_statement(
|
||||||
range,
|
range,
|
||||||
message: format!("Unnecessary braces in use statement"),
|
message: format!("Unnecessary braces in use statement"),
|
||||||
severity: Severity::WeakWarning,
|
severity: Severity::WeakWarning,
|
||||||
fix: Some(SourceChange::source_edit(
|
fix: Some(SourceChange::source_file_edit(
|
||||||
"Remove unnecessary braces",
|
"Remove unnecessary braces",
|
||||||
SourceFileEdit { file_id, edit },
|
SourceFileEdit { file_id, edit },
|
||||||
)),
|
)),
|
||||||
|
@ -117,7 +117,7 @@ fn check_struct_shorthand_initialization(
|
||||||
range: named_field.syntax().range(),
|
range: named_field.syntax().range(),
|
||||||
message: format!("Shorthand struct initialization"),
|
message: format!("Shorthand struct initialization"),
|
||||||
severity: Severity::WeakWarning,
|
severity: Severity::WeakWarning,
|
||||||
fix: Some(SourceChange::source_edit(
|
fix: Some(SourceChange::source_file_edit(
|
||||||
"use struct shorthand initialization",
|
"use struct shorthand initialization",
|
||||||
SourceFileEdit { file_id, edit },
|
SourceFileEdit { file_id, edit },
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -115,7 +115,7 @@ impl SourceChange {
|
||||||
|
|
||||||
/// Creates a new SourceChange with the given label,
|
/// Creates a new SourceChange with the given label,
|
||||||
/// containing only the given `SourceFileEdits`.
|
/// containing only the given `SourceFileEdits`.
|
||||||
pub(crate) fn source_edits<L: Into<String>>(label: L, edits: Vec<SourceFileEdit>) -> Self {
|
pub(crate) fn source_file_edits<L: Into<String>>(label: L, edits: Vec<SourceFileEdit>) -> Self {
|
||||||
SourceChange {
|
SourceChange {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
source_file_edits: edits,
|
source_file_edits: edits,
|
||||||
|
@ -137,8 +137,8 @@ impl SourceChange {
|
||||||
|
|
||||||
/// Creates a new SourceChange with the given label,
|
/// Creates a new SourceChange with the given label,
|
||||||
/// containing only a single `SourceFileEdit`.
|
/// containing only a single `SourceFileEdit`.
|
||||||
pub(crate) fn source_edit<L: Into<String>>(label: L, edit: SourceFileEdit) -> Self {
|
pub(crate) fn source_file_edit<L: Into<String>>(label: L, edit: SourceFileEdit) -> Self {
|
||||||
SourceChange::source_edits(label, vec![edit])
|
SourceChange::source_file_edits(label, vec![edit])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new SourceChange with the given label
|
/// Creates a new SourceChange with the given label
|
||||||
|
@ -148,7 +148,7 @@ impl SourceChange {
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
edit: TextEdit,
|
edit: TextEdit,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
SourceChange::source_edit(label, SourceFileEdit { file_id, edit })
|
SourceChange::source_file_edit(label, SourceFileEdit { file_id, edit })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new SourceChange with the given label
|
/// Creates a new SourceChange with the given label
|
||||||
|
@ -358,7 +358,7 @@ impl Analysis {
|
||||||
file_id: frange.file_id,
|
file_id: frange.file_id,
|
||||||
edit: join_lines::join_lines(&file, frange.range),
|
edit: join_lines::join_lines(&file, frange.range),
|
||||||
};
|
};
|
||||||
SourceChange::source_edit("join lines", file_edit)
|
SourceChange::source_file_edit("join lines", file_edit)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an edit which should be applied when opening a new line, fixing
|
/// Returns an edit which should be applied when opening a new line, fixing
|
||||||
|
@ -373,7 +373,7 @@ impl Analysis {
|
||||||
pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
|
pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
|
||||||
let file = self.db.parse(position.file_id);
|
let file = self.db.parse(position.file_id);
|
||||||
let edit = typing::on_eq_typed(&file, position.offset)?;
|
let edit = typing::on_eq_typed(&file, position.offset)?;
|
||||||
Some(SourceChange::source_edit(
|
Some(SourceChange::source_file_edit(
|
||||||
"add semicolon",
|
"add semicolon",
|
||||||
SourceFileEdit { edit, file_id: position.file_id },
|
SourceFileEdit { edit, file_id: position.file_id },
|
||||||
))
|
))
|
||||||
|
|
|
@ -206,7 +206,7 @@ fn rename_reference(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(SourceChange::source_edits("rename", edit))
|
Some(SourceChange::source_file_edits("rename", edit))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour
|
||||||
edit.insert(position.offset, inserted);
|
edit.insert(position.offset, inserted);
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
SourceChange::source_edit(
|
SourceChange::source_file_edit(
|
||||||
"on enter",
|
"on enter",
|
||||||
SourceFileEdit { edit: edit.finish(), file_id: position.file_id },
|
SourceFileEdit { edit: edit.finish(), file_id: position.file_id },
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue