.unwrap_or_else(|| RelativePath::new(""))
.join(&d.candidate);
let create_file = FileSystemEdit::CreateFile { source_root, path };
- let fix = SourceChange::file_system_edit("create module", create_file);
+ let fix = SourceChange::file_system_edit("Create module", create_file);
res.borrow_mut().push(Diagnostic {
range: sema.diagnostics_range(d).range,
message: d.message(),
algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder);
Some(SourceChange::source_file_edit_from(
- "fill struct fields",
+ "Fill struct fields",
file_id,
builder.finish(),
))
let node = d.ast(db);
let replacement = format!("Ok({})", node.syntax());
let edit = TextEdit::replace(node.syntax().text_range(), replacement);
- let fix = SourceChange::source_file_edit_from("wrap with ok", file_id, edit);
+ let fix = SourceChange::source_file_edit_from("Wrap with ok", file_id, edit);
res.borrow_mut().push(Diagnostic {
range: sema.diagnostics_range(d).range,
message: d.message(),
message: "Shorthand struct initialization".to_string(),
severity: Severity::WeakWarning,
fix: Some(SourceChange::source_file_edit(
- "use struct shorthand initialization",
+ "Use struct shorthand initialization",
SourceFileEdit { file_id, edit },
)),
});
range: 0..8,
fix: Some(
SourceChange {
- label: "create module",
+ label: "Create module",
source_file_edits: [],
file_system_edits: [
CreateFile {
range: 224..233,
fix: Some(
SourceChange {
- label: "fill struct fields",
+ label: "Fill struct fields",
source_file_edits: [
SourceFileEdit {
file_id: FileId(
source_file_edits.extend(ref_edits);
}
- Some(SourceChange::from_edits("rename", source_file_edits, file_system_edits))
+ Some(SourceChange::from_edits("Rename", source_file_edits, file_system_edits))
}
fn rename_reference(
return None;
}
- Some(RangeInfo::new(range, SourceChange::source_file_edits("rename", edit)))
+ Some(RangeInfo::new(range, SourceChange::source_file_edits("Rename", edit)))
}
#[cfg(test)]
RangeInfo {
range: 4..7,
info: SourceChange {
- label: "rename",
+ label: "Rename",
source_file_edits: [
SourceFileEdit {
file_id: FileId(
RangeInfo {
range: 4..7,
info: SourceChange {
- label: "rename",
+ label: "Rename",
source_file_edits: [
SourceFileEdit {
file_id: FileId(
RangeInfo {
range: 8..11,
info: SourceChange {
- label: "rename",
+ label: "Rename",
source_file_edits: [
SourceFileEdit {
file_id: FileId(
/// Creates a new SourceChange with the given label,
/// containing only the given `SourceFileEdits`.
pub(crate) fn source_file_edits<L: Into<String>>(label: L, edits: Vec<SourceFileEdit>) -> Self {
+ let label = label.into();
+ assert!(label.starts_with(char::is_uppercase));
SourceChange {
- label: label.into(),
+ label: label,
source_file_edits: edits,
file_system_edits: vec![],
cursor_position: None,
Some(
SourceChange::source_file_edit(
- "on enter",
+ "On enter",
SourceFileEdit { edit, file_id: position.file_id },
)
.with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }),
"arguments": [
{
"cursorPosition": null,
- "label": "create module",
+ "label": "Create module",
"workspaceEdit": {
"documentChanges": [
{
}
],
"command": "rust-analyzer.applySourceChange",
- "title": "create module"
+ "title": "Create module"
},
- "title": "create module"
+ "title": "Create module"
}
]),
);
"arguments": [
{
"cursorPosition": null,
- "label": "create module",
+ "label": "Create module",
"workspaceEdit": {
"documentChanges": [
{
}
],
"command": "rust-analyzer.applySourceChange",
- "title": "create module"
+ "title": "Create module"
},
- "title": "create module"
+ "title": "Create module"
}
]),
);
"position": { "character": 4, "line": 1 },
"textDocument": { "uri": "file:///[..]src/m0.rs" }
},
- "label": "on enter",
+ "label": "On enter",
"workspaceEdit": {
"documentChanges": [
{
"position": { "line": 1, "character": 4 },
"textDocument": { "uri": "file:///[..]src/main.rs" }
},
- "label": "on enter",
+ "label": "On enter",
"workspaceEdit": {
"documentChanges": [
{