aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/references.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/references.rs')
-rw-r--r--crates/ra_ide_api/src/references.rs69
1 files changed, 67 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 89984e642..2118e7ad3 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -341,7 +341,39 @@ mod tests {
341 ); 341 );
342 let new_name = "foo2"; 342 let new_name = "foo2";
343 let source_change = analysis.rename(position, new_name).unwrap(); 343 let source_change = analysis.rename(position, new_name).unwrap();
344 assert_debug_snapshot_matches!("rename_mod", &source_change); 344 assert_debug_snapshot_matches!(&source_change,
345@r#"Some(
346 SourceChange {
347 label: "rename",
348 source_file_edits: [
349 SourceFileEdit {
350 file_id: FileId(
351 2,
352 ),
353 edit: TextEdit {
354 atoms: [
355 AtomTextEdit {
356 delete: [4; 7),
357 insert: "foo2",
358 },
359 ],
360 },
361 },
362 ],
363 file_system_edits: [
364 MoveFile {
365 src: FileId(
366 3,
367 ),
368 dst_source_root: SourceRootId(
369 0,
370 ),
371 dst_path: "bar/foo2.rs",
372 },
373 ],
374 cursor_position: None,
375 },
376)"#);
345 } 377 }
346 378
347 #[test] 379 #[test]
@@ -356,7 +388,40 @@ mod tests {
356 ); 388 );
357 let new_name = "foo2"; 389 let new_name = "foo2";
358 let source_change = analysis.rename(position, new_name).unwrap(); 390 let source_change = analysis.rename(position, new_name).unwrap();
359 assert_debug_snapshot_matches!("rename_mod_in_dir", &source_change); 391 assert_debug_snapshot_matches!(&source_change,
392 @r###"Some(
393 SourceChange {
394 label: "rename",
395 source_file_edits: [
396 SourceFileEdit {
397 file_id: FileId(
398 1,
399 ),
400 edit: TextEdit {
401 atoms: [
402 AtomTextEdit {
403 delete: [4; 7),
404 insert: "foo2",
405 },
406 ],
407 },
408 },
409 ],
410 file_system_edits: [
411 MoveFile {
412 src: FileId(
413 2,
414 ),
415 dst_source_root: SourceRootId(
416 0,
417 ),
418 dst_path: "foo2/mod.rs",
419 },
420 ],
421 cursor_position: None,
422 },
423)"###
424 );
360 } 425 }
361 426
362 fn test_rename(text: &str, new_name: &str, expected: &str) { 427 fn test_rename(text: &str, new_name: &str, expected: &str) {