aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/call_hierarchy.rs2
-rw-r--r--crates/ide/src/diagnostics/fixes.rs2
-rw-r--r--crates/ide/src/doc_links.rs8
-rw-r--r--crates/ide/src/lib.rs8
-rw-r--r--crates/ide/src/references.rs52
-rw-r--r--crates/ide/src/references/rename.rs314
6 files changed, 176 insertions, 210 deletions
diff --git a/crates/ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs
index e8999a7f3..b10a0a78b 100644
--- a/crates/ide/src/call_hierarchy.rs
+++ b/crates/ide/src/call_hierarchy.rs
@@ -47,7 +47,7 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
47 47
48 let mut calls = CallLocations::default(); 48 let mut calls = CallLocations::default();
49 49
50 for (&file_id, references) in refs.info.references().iter() { 50 for (&file_id, references) in refs.references().iter() {
51 let file = sema.parse(file_id); 51 let file = sema.parse(file_id);
52 let file = file.syntax(); 52 let file = file.syntax();
53 for reference in references { 53 for reference in references {
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs
index 4b4afd40c..579d5a308 100644
--- a/crates/ide/src/diagnostics/fixes.rs
+++ b/crates/ide/src/diagnostics/fixes.rs
@@ -140,7 +140,7 @@ impl DiagnosticWithFix for IncorrectCase {
140 rename_with_semantics(sema, file_position, &self.suggested_text).ok()?; 140 rename_with_semantics(sema, file_position, &self.suggested_text).ok()?;
141 141
142 let label = format!("Rename to {}", self.suggested_text); 142 let label = format!("Rename to {}", self.suggested_text);
143 Some(Fix::new(&label, rename_changes.info, frange.range)) 143 Some(Fix::new(&label, rename_changes, frange.range))
144 } 144 }
145} 145}
146 146
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index de10406bc..1f08d7810 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -438,10 +438,10 @@ fn get_symbol_fragment(db: &dyn HirDatabase, field_or_assoc: &FieldOrAssocItem)
438 FieldOrAssocItem::Field(field) => format!("#structfield.{}", field.name(db)), 438 FieldOrAssocItem::Field(field) => format!("#structfield.{}", field.name(db)),
439 FieldOrAssocItem::AssocItem(assoc) => match assoc { 439 FieldOrAssocItem::AssocItem(assoc) => match assoc {
440 AssocItem::Function(function) => { 440 AssocItem::Function(function) => {
441 let is_trait_method = matches!( 441 let is_trait_method = function
442 function.as_assoc_item(db).map(|assoc| assoc.container(db)), 442 .as_assoc_item(db)
443 Some(AssocItemContainer::Trait(..)) 443 .and_then(|assoc| assoc.containing_trait(db))
444 ); 444 .is_some();
445 // This distinction may get more complicated when specialization is available. 445 // This distinction may get more complicated when specialization is available.
446 // Rustdoc makes this decision based on whether a method 'has defaultness'. 446 // Rustdoc makes this decision based on whether a method 'has defaultness'.
447 // Currently this is only the case for provided trait methods. 447 // Currently this is only the case for provided trait methods.
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 6c94c26b5..567b8117e 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -369,9 +369,7 @@ impl Analysis {
369 position: FilePosition, 369 position: FilePosition,
370 search_scope: Option<SearchScope>, 370 search_scope: Option<SearchScope>,
371 ) -> Cancelable<Option<ReferenceSearchResult>> { 371 ) -> Cancelable<Option<ReferenceSearchResult>> {
372 self.with_db(|db| { 372 self.with_db(|db| references::find_all_refs(&Semantics::new(db), position, search_scope))
373 references::find_all_refs(&Semantics::new(db), position, search_scope).map(|it| it.info)
374 })
375 } 373 }
376 374
377 /// Finds all methods and free functions for the file. Does not return tests! 375 /// Finds all methods and free functions for the file. Does not return tests!
@@ -478,6 +476,7 @@ impl Analysis {
478 position: FilePosition, 476 position: FilePosition,
479 full_import_path: &str, 477 full_import_path: &str,
480 imported_name: String, 478 imported_name: String,
479 import_for_trait_assoc_item: bool,
481 ) -> Cancelable<Vec<TextEdit>> { 480 ) -> Cancelable<Vec<TextEdit>> {
482 Ok(self 481 Ok(self
483 .with_db(|db| { 482 .with_db(|db| {
@@ -487,6 +486,7 @@ impl Analysis {
487 position, 486 position,
488 full_import_path, 487 full_import_path,
489 imported_name, 488 imported_name,
489 import_for_trait_assoc_item,
490 ) 490 )
491 })? 491 })?
492 .unwrap_or_default()) 492 .unwrap_or_default())
@@ -520,7 +520,7 @@ impl Analysis {
520 &self, 520 &self,
521 position: FilePosition, 521 position: FilePosition,
522 new_name: &str, 522 new_name: &str,
523 ) -> Cancelable<Result<RangeInfo<SourceChange>, RenameError>> { 523 ) -> Cancelable<Result<SourceChange, RenameError>> {
524 self.with_db(|db| references::rename::rename(db, position, new_name)) 524 self.with_db(|db| references::rename::rename(db, position, new_name))
525 } 525 }
526 526
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index df9c31aef..3a4f4d80b 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -25,7 +25,7 @@ use syntax::{
25 AstNode, SyntaxNode, TextRange, TokenAtOffset, T, 25 AstNode, SyntaxNode, TextRange, TokenAtOffset, T,
26}; 26};
27 27
28use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo}; 28use crate::{display::TryToNav, FilePosition, NavigationTarget};
29 29
30#[derive(Debug, Clone)] 30#[derive(Debug, Clone)]
31pub struct ReferenceSearchResult { 31pub struct ReferenceSearchResult {
@@ -41,14 +41,6 @@ pub struct Declaration {
41} 41}
42 42
43impl ReferenceSearchResult { 43impl ReferenceSearchResult {
44 pub fn declaration(&self) -> &Declaration {
45 &self.declaration
46 }
47
48 pub fn decl_target(&self) -> &NavigationTarget {
49 &self.declaration.nav
50 }
51
52 pub fn references(&self) -> &UsageSearchResult { 44 pub fn references(&self) -> &UsageSearchResult {
53 &self.references 45 &self.references
54 } 46 }
@@ -87,7 +79,7 @@ pub(crate) fn find_all_refs(
87 sema: &Semantics<RootDatabase>, 79 sema: &Semantics<RootDatabase>,
88 position: FilePosition, 80 position: FilePosition,
89 search_scope: Option<SearchScope>, 81 search_scope: Option<SearchScope>,
90) -> Option<RangeInfo<ReferenceSearchResult>> { 82) -> Option<ReferenceSearchResult> {
91 let _p = profile::span("find_all_refs"); 83 let _p = profile::span("find_all_refs");
92 let syntax = sema.parse(position.file_id).syntax().clone(); 84 let syntax = sema.parse(position.file_id).syntax().clone();
93 85
@@ -105,7 +97,7 @@ pub(crate) fn find_all_refs(
105 ) 97 )
106 }; 98 };
107 99
108 let RangeInfo { range, info: def } = find_name(&sema, &syntax, position, opt_name)?; 100 let def = find_name(&sema, &syntax, position, opt_name)?;
109 101
110 let mut usages = def.usages(sema).set_scope(search_scope).all(); 102 let mut usages = def.usages(sema).set_scope(search_scope).all();
111 usages 103 usages
@@ -139,7 +131,7 @@ pub(crate) fn find_all_refs(
139 131
140 let declaration = Declaration { nav, kind, access: decl_access(&def, &syntax, decl_range) }; 132 let declaration = Declaration { nav, kind, access: decl_access(&def, &syntax, decl_range) };
141 133
142 Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references: usages })) 134 Some(ReferenceSearchResult { declaration, references: usages })
143} 135}
144 136
145fn find_name( 137fn find_name(
@@ -147,35 +139,27 @@ fn find_name(
147 syntax: &SyntaxNode, 139 syntax: &SyntaxNode,
148 position: FilePosition, 140 position: FilePosition,
149 opt_name: Option<ast::Name>, 141 opt_name: Option<ast::Name>,
150) -> Option<RangeInfo<Definition>> { 142) -> Option<Definition> {
151 if let Some(name) = opt_name { 143 let def = if let Some(name) = opt_name {
152 let def = NameClass::classify(sema, &name)?.referenced_or_defined(sema.db); 144 NameClass::classify(sema, &name)?.referenced_or_defined(sema.db)
153 let FileRange { range, .. } = sema.original_range(name.syntax()); 145 } else if let Some(lifetime) =
154 return Some(RangeInfo::new(range, def));
155 }
156
157 let (FileRange { range, .. }, def) = if let Some(lifetime) =
158 sema.find_node_at_offset_with_descend::<ast::Lifetime>(&syntax, position.offset) 146 sema.find_node_at_offset_with_descend::<ast::Lifetime>(&syntax, position.offset)
159 { 147 {
160 if let Some(def) = NameRefClass::classify_lifetime(sema, &lifetime) 148 if let Some(def) =
161 .map(|class| NameRefClass::referenced(class, sema.db)) 149 NameRefClass::classify_lifetime(sema, &lifetime).map(|class| class.referenced(sema.db))
162 { 150 {
163 (sema.original_range(lifetime.syntax()), def) 151 def
164 } else { 152 } else {
165 ( 153 NameClass::classify_lifetime(sema, &lifetime)?.referenced_or_defined(sema.db)
166 sema.original_range(lifetime.syntax()),
167 NameClass::classify_lifetime(sema, &lifetime)?.referenced_or_defined(sema.db),
168 )
169 } 154 }
155 } else if let Some(name_ref) =
156 sema.find_node_at_offset_with_descend::<ast::NameRef>(&syntax, position.offset)
157 {
158 NameRefClass::classify(sema, &name_ref)?.referenced(sema.db)
170 } else { 159 } else {
171 let name_ref = 160 return None;
172 sema.find_node_at_offset_with_descend::<ast::NameRef>(&syntax, position.offset)?;
173 (
174 sema.original_range(name_ref.syntax()),
175 NameRefClass::classify(sema, &name_ref)?.referenced(sema.db),
176 )
177 }; 161 };
178 Some(RangeInfo::new(range, def)) 162 Some(def)
179} 163}
180 164
181fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Option<ReferenceAccess> { 165fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Option<ReferenceAccess> {
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs
index c5010df0a..c25bcce50 100644
--- a/crates/ide/src/references/rename.rs
+++ b/crates/ide/src/references/rename.rs
@@ -63,7 +63,7 @@ pub(crate) fn rename(
63 db: &RootDatabase, 63 db: &RootDatabase,
64 position: FilePosition, 64 position: FilePosition,
65 new_name: &str, 65 new_name: &str,
66) -> RenameResult<RangeInfo<SourceChange>> { 66) -> RenameResult<SourceChange> {
67 let sema = Semantics::new(db); 67 let sema = Semantics::new(db);
68 rename_with_semantics(&sema, position, new_name) 68 rename_with_semantics(&sema, position, new_name)
69} 69}
@@ -72,7 +72,7 @@ pub(crate) fn rename_with_semantics(
72 sema: &Semantics<RootDatabase>, 72 sema: &Semantics<RootDatabase>,
73 position: FilePosition, 73 position: FilePosition,
74 new_name: &str, 74 new_name: &str,
75) -> RenameResult<RangeInfo<SourceChange>> { 75) -> RenameResult<SourceChange> {
76 let source_file = sema.parse(position.file_id); 76 let source_file = sema.parse(position.file_id);
77 let syntax = source_file.syntax(); 77 let syntax = source_file.syntax();
78 78
@@ -91,7 +91,7 @@ pub(crate) fn will_rename_file(
91) -> Option<SourceChange> { 91) -> Option<SourceChange> {
92 let sema = Semantics::new(db); 92 let sema = Semantics::new(db);
93 let module = sema.to_module_def(file_id)?; 93 let module = sema.to_module_def(file_id)?;
94 let mut change = rename_mod(&sema, module, new_name_stem).ok()?.info; 94 let mut change = rename_mod(&sema, module, new_name_stem).ok()?;
95 change.file_system_edits.clear(); 95 change.file_system_edits.clear();
96 Some(change) 96 Some(change)
97} 97}
@@ -243,7 +243,7 @@ fn rename_mod(
243 sema: &Semantics<RootDatabase>, 243 sema: &Semantics<RootDatabase>,
244 module: Module, 244 module: Module,
245 new_name: &str, 245 new_name: &str,
246) -> RenameResult<RangeInfo<SourceChange>> { 246) -> RenameResult<SourceChange> {
247 if IdentifierKind::Ident != check_identifier(new_name)? { 247 if IdentifierKind::Ident != check_identifier(new_name)? {
248 bail!("Invalid name `{0}`: cannot rename module to {0}", new_name); 248 bail!("Invalid name `{0}`: cannot rename module to {0}", new_name);
249 } 249 }
@@ -281,13 +281,10 @@ fn rename_mod(
281 }); 281 });
282 source_change.extend(ref_edits); 282 source_change.extend(ref_edits);
283 283
284 Ok(RangeInfo::new(TextRange::default(), source_change)) 284 Ok(source_change)
285} 285}
286 286
287fn rename_to_self( 287fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameResult<SourceChange> {
288 sema: &Semantics<RootDatabase>,
289 local: hir::Local,
290) -> RenameResult<RangeInfo<SourceChange>> {
291 if assert_never!(local.is_self(sema.db)) { 288 if assert_never!(local.is_self(sema.db)) {
292 bail!("rename_to_self invoked on self"); 289 bail!("rename_to_self invoked on self");
293 } 290 }
@@ -356,7 +353,7 @@ fn rename_to_self(
356 TextEdit::replace(first_param_range, String::from(self_param)), 353 TextEdit::replace(first_param_range, String::from(self_param)),
357 ); 354 );
358 355
359 Ok(RangeInfo::new(TextRange::default(), source_change)) 356 Ok(source_change)
360} 357}
361 358
362fn text_edit_from_self_param(self_param: &ast::SelfParam, new_name: &str) -> Option<TextEdit> { 359fn text_edit_from_self_param(self_param: &ast::SelfParam, new_name: &str) -> Option<TextEdit> {
@@ -387,7 +384,7 @@ fn rename_self_to_param(
387 local: hir::Local, 384 local: hir::Local,
388 new_name: &str, 385 new_name: &str,
389 identifier_kind: IdentifierKind, 386 identifier_kind: IdentifierKind,
390) -> RenameResult<RangeInfo<SourceChange>> { 387) -> RenameResult<SourceChange> {
391 let (file_id, self_param) = match local.source(sema.db) { 388 let (file_id, self_param) = match local.source(sema.db) {
392 InFile { file_id, value: Either::Right(self_param) } => (file_id, self_param), 389 InFile { file_id, value: Either::Right(self_param) } => (file_id, self_param),
393 _ => { 390 _ => {
@@ -408,14 +405,14 @@ fn rename_self_to_param(
408 source_change.extend(usages.iter().map(|(&file_id, references)| { 405 source_change.extend(usages.iter().map(|(&file_id, references)| {
409 source_edit_from_references(sema, file_id, &references, new_name) 406 source_edit_from_references(sema, file_id, &references, new_name)
410 })); 407 }));
411 Ok(RangeInfo::new(TextRange::default(), source_change)) 408 Ok(source_change)
412} 409}
413 410
414fn rename_reference( 411fn rename_reference(
415 sema: &Semantics<RootDatabase>, 412 sema: &Semantics<RootDatabase>,
416 def: Definition, 413 def: Definition,
417 new_name: &str, 414 new_name: &str,
418) -> RenameResult<RangeInfo<SourceChange>> { 415) -> RenameResult<SourceChange> {
419 let ident_kind = check_identifier(new_name)?; 416 let ident_kind = check_identifier(new_name)?;
420 417
421 let def_is_lbl_or_lt = matches!(def, 418 let def_is_lbl_or_lt = matches!(def,
@@ -439,7 +436,7 @@ fn rename_reference(
439 (IdentifierKind::ToSelf, Definition::Local(local)) if local.is_self(sema.db) => { 436 (IdentifierKind::ToSelf, Definition::Local(local)) if local.is_self(sema.db) => {
440 // no-op 437 // no-op
441 mark::hit!(rename_self_to_self); 438 mark::hit!(rename_self_to_self);
442 return Ok(RangeInfo::new(TextRange::default(), SourceChange::default())); 439 return Ok(SourceChange::default());
443 } 440 }
444 (ident_kind, Definition::Local(local)) if local.is_self(sema.db) => { 441 (ident_kind, Definition::Local(local)) if local.is_self(sema.db) => {
445 mark::hit!(rename_self_to_param); 442 mark::hit!(rename_self_to_param);
@@ -465,7 +462,7 @@ fn rename_reference(
465 462
466 let (file_id, edit) = source_edit_from_def(sema, def, new_name)?; 463 let (file_id, edit) = source_edit_from_def(sema, def, new_name)?;
467 source_change.insert_source_edit(file_id, edit); 464 source_change.insert_source_edit(file_id, edit);
468 Ok(RangeInfo::new(TextRange::default(), source_change)) 465 Ok(source_change)
469} 466}
470 467
471fn source_edit_from_def( 468fn source_edit_from_def(
@@ -518,7 +515,7 @@ mod tests {
518 Ok(source_change) => { 515 Ok(source_change) => {
519 let mut text_edit_builder = TextEdit::builder(); 516 let mut text_edit_builder = TextEdit::builder();
520 let mut file_id: Option<FileId> = None; 517 let mut file_id: Option<FileId> = None;
521 for edit in source_change.info.source_file_edits { 518 for edit in source_change.source_file_edits {
522 file_id = Some(edit.0); 519 file_id = Some(edit.0);
523 for indel in edit.1.into_iter() { 520 for indel in edit.1.into_iter() {
524 text_edit_builder.replace(indel.delete, indel.insert); 521 text_edit_builder.replace(indel.delete, indel.insert);
@@ -917,36 +914,33 @@ mod foo$0;
917// empty 914// empty
918"#, 915"#,
919 expect![[r#" 916 expect![[r#"
920 RangeInfo { 917 SourceChange {
921 range: 0..0, 918 source_file_edits: {
922 info: SourceChange { 919 FileId(
923 source_file_edits: { 920 1,
924 FileId( 921 ): TextEdit {
925 1, 922 indels: [
926 ): TextEdit { 923 Indel {
927 indels: [ 924 insert: "foo2",
928 Indel { 925 delete: 4..7,
929 insert: "foo2", 926 },
930 delete: 4..7, 927 ],
931 },
932 ],
933 },
934 }, 928 },
935 file_system_edits: [ 929 },
936 MoveFile { 930 file_system_edits: [
937 src: FileId( 931 MoveFile {
932 src: FileId(
933 2,
934 ),
935 dst: AnchoredPathBuf {
936 anchor: FileId(
938 2, 937 2,
939 ), 938 ),
940 dst: AnchoredPathBuf { 939 path: "foo2.rs",
941 anchor: FileId(
942 2,
943 ),
944 path: "foo2.rs",
945 },
946 }, 940 },
947 ], 941 },
948 is_snippet: false, 942 ],
949 }, 943 is_snippet: false,
950 } 944 }
951 "#]], 945 "#]],
952 ); 946 );
@@ -969,46 +963,43 @@ pub struct FooContent;
969use crate::foo$0::FooContent; 963use crate::foo$0::FooContent;
970"#, 964"#,
971 expect![[r#" 965 expect![[r#"
972 RangeInfo { 966 SourceChange {
973 range: 0..0, 967 source_file_edits: {
974 info: SourceChange { 968 FileId(
975 source_file_edits: { 969 0,
976 FileId( 970 ): TextEdit {
977 0, 971 indels: [
978 ): TextEdit { 972 Indel {
979 indels: [ 973 insert: "quux",
980 Indel { 974 delete: 8..11,
981 insert: "quux", 975 },
982 delete: 8..11, 976 ],
983 }, 977 },
984 ], 978 FileId(
985 }, 979 2,
986 FileId( 980 ): TextEdit {
987 2, 981 indels: [
988 ): TextEdit { 982 Indel {
989 indels: [ 983 insert: "quux",
990 Indel { 984 delete: 11..14,
991 insert: "quux", 985 },
992 delete: 11..14, 986 ],
993 },
994 ],
995 },
996 }, 987 },
997 file_system_edits: [ 988 },
998 MoveFile { 989 file_system_edits: [
999 src: FileId( 990 MoveFile {
991 src: FileId(
992 1,
993 ),
994 dst: AnchoredPathBuf {
995 anchor: FileId(
1000 1, 996 1,
1001 ), 997 ),
1002 dst: AnchoredPathBuf { 998 path: "quux.rs",
1003 anchor: FileId(
1004 1,
1005 ),
1006 path: "quux.rs",
1007 },
1008 }, 999 },
1009 ], 1000 },
1010 is_snippet: false, 1001 ],
1011 }, 1002 is_snippet: false,
1012 } 1003 }
1013 "#]], 1004 "#]],
1014 ); 1005 );
@@ -1025,36 +1016,33 @@ mod fo$0o;
1025// empty 1016// empty
1026"#, 1017"#,
1027 expect![[r#" 1018 expect![[r#"
1028 RangeInfo { 1019 SourceChange {
1029 range: 0..0, 1020 source_file_edits: {
1030 info: SourceChange { 1021 FileId(
1031 source_file_edits: { 1022 0,
1032 FileId( 1023 ): TextEdit {
1033 0, 1024 indels: [
1034 ): TextEdit { 1025 Indel {
1035 indels: [ 1026 insert: "foo2",
1036 Indel { 1027 delete: 4..7,
1037 insert: "foo2", 1028 },
1038 delete: 4..7, 1029 ],
1039 },
1040 ],
1041 },
1042 }, 1030 },
1043 file_system_edits: [ 1031 },
1044 MoveFile { 1032 file_system_edits: [
1045 src: FileId( 1033 MoveFile {
1034 src: FileId(
1035 1,
1036 ),
1037 dst: AnchoredPathBuf {
1038 anchor: FileId(
1046 1, 1039 1,
1047 ), 1040 ),
1048 dst: AnchoredPathBuf { 1041 path: "../foo2/mod.rs",
1049 anchor: FileId(
1050 1,
1051 ),
1052 path: "../foo2/mod.rs",
1053 },
1054 }, 1042 },
1055 ], 1043 },
1056 is_snippet: false, 1044 ],
1057 }, 1045 is_snippet: false,
1058 } 1046 }
1059 "#]], 1047 "#]],
1060 ); 1048 );
@@ -1072,36 +1060,33 @@ mod outer { mod fo$0o; }
1072// empty 1060// empty
1073"#, 1061"#,
1074 expect![[r#" 1062 expect![[r#"
1075 RangeInfo { 1063 SourceChange {
1076 range: 0..0, 1064 source_file_edits: {
1077 info: SourceChange { 1065 FileId(
1078 source_file_edits: { 1066 0,
1079 FileId( 1067 ): TextEdit {
1080 0, 1068 indels: [
1081 ): TextEdit { 1069 Indel {
1082 indels: [ 1070 insert: "bar",
1083 Indel { 1071 delete: 16..19,
1084 insert: "bar", 1072 },
1085 delete: 16..19, 1073 ],
1086 },
1087 ],
1088 },
1089 }, 1074 },
1090 file_system_edits: [ 1075 },
1091 MoveFile { 1076 file_system_edits: [
1092 src: FileId( 1077 MoveFile {
1078 src: FileId(
1079 1,
1080 ),
1081 dst: AnchoredPathBuf {
1082 anchor: FileId(
1093 1, 1083 1,
1094 ), 1084 ),
1095 dst: AnchoredPathBuf { 1085 path: "bar.rs",
1096 anchor: FileId(
1097 1,
1098 ),
1099 path: "bar.rs",
1100 },
1101 }, 1086 },
1102 ], 1087 },
1103 is_snippet: false, 1088 ],
1104 }, 1089 is_snippet: false,
1105 } 1090 }
1106 "#]], 1091 "#]],
1107 ); 1092 );
@@ -1142,46 +1127,43 @@ pub mod foo$0;
1142// pub fn fun() {} 1127// pub fn fun() {}
1143"#, 1128"#,
1144 expect![[r#" 1129 expect![[r#"
1145 RangeInfo { 1130 SourceChange {
1146 range: 0..0, 1131 source_file_edits: {
1147 info: SourceChange { 1132 FileId(
1148 source_file_edits: { 1133 0,
1149 FileId( 1134 ): TextEdit {
1150 0, 1135 indels: [
1151 ): TextEdit { 1136 Indel {
1152 indels: [ 1137 insert: "foo2",
1153 Indel { 1138 delete: 27..30,
1154 insert: "foo2", 1139 },
1155 delete: 27..30, 1140 ],
1156 }, 1141 },
1157 ], 1142 FileId(
1158 }, 1143 1,
1159 FileId( 1144 ): TextEdit {
1160 1, 1145 indels: [
1161 ): TextEdit { 1146 Indel {
1162 indels: [ 1147 insert: "foo2",
1163 Indel { 1148 delete: 8..11,
1164 insert: "foo2", 1149 },
1165 delete: 8..11, 1150 ],
1166 },
1167 ],
1168 },
1169 }, 1151 },
1170 file_system_edits: [ 1152 },
1171 MoveFile { 1153 file_system_edits: [
1172 src: FileId( 1154 MoveFile {
1155 src: FileId(
1156 2,
1157 ),
1158 dst: AnchoredPathBuf {
1159 anchor: FileId(
1173 2, 1160 2,
1174 ), 1161 ),
1175 dst: AnchoredPathBuf { 1162 path: "foo2.rs",
1176 anchor: FileId(
1177 2,
1178 ),
1179 path: "foo2.rs",
1180 },
1181 }, 1163 },
1182 ], 1164 },
1183 is_snippet: false, 1165 ],
1184 }, 1166 is_snippet: false,
1185 } 1167 }
1186 "#]], 1168 "#]],
1187 ); 1169 );