aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/rename.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-24 22:56:13 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-24 22:56:13 +0000
commitc42db0bbd750fae19a91f0a0354240ea6c3bafce (patch)
treebeb7030248280fd8c67eb2b2c9cc4b19c6074c17 /crates/ra_ide_api/src/rename.rs
parentb308375b82a33687f93468d75c7cc628b83a1351 (diff)
parent31d3a56b1865c33ef54e5d76e606965c87676695 (diff)
Merge #623
623: WIP: module id is not def id r=matklad a=matklad This achieves two things: * makes module_tree & item_map per crate, not per source_root * begins the refactoring to remove universal `DefId` in favor of having separate ids for each kind of `Def`. Currently, only modules get a differnt ID though. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/rename.rs')
-rw-r--r--crates/ra_ide_api/src/rename.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs
index 53dc273c6..5b767addd 100644
--- a/crates/ra_ide_api/src/rename.rs
+++ b/crates/ra_ide_api/src/rename.rs
@@ -57,7 +57,6 @@ fn rename_mod(
57) -> Option<SourceChange> { 57) -> Option<SourceChange> {
58 let mut source_file_edits = Vec::new(); 58 let mut source_file_edits = Vec::new();
59 let mut file_system_edits = Vec::new(); 59 let mut file_system_edits = Vec::new();
60
61 if let Some(module) = module_from_declaration(db, position.file_id, &ast_module) { 60 if let Some(module) = module_from_declaration(db, position.file_id, &ast_module) {
62 let (file_id, module_source) = module.definition_source(db); 61 let (file_id, module_source) = module.definition_source(db);
63 match module_source { 62 match module_source {
@@ -223,11 +222,15 @@ mod tests {
223 fn test_rename_mod() { 222 fn test_rename_mod() {
224 let (analysis, position) = analysis_and_position( 223 let (analysis, position) = analysis_and_position(
225 " 224 "
226 //- /bar.rs 225 //- /lib.rs
227 mod fo<|>o; 226 mod bar;
228 //- /bar/foo.rs 227
229 // emtpy 228 //- /bar.rs
230 ", 229 mod foo<|>;
230
231 //- /bar/foo.rs
232 // emtpy
233 ",
231 ); 234 );
232 let new_name = "foo2"; 235 let new_name = "foo2";
233 let source_change = analysis.rename(position, new_name).unwrap(); 236 let source_change = analysis.rename(position, new_name).unwrap();
@@ -238,11 +241,11 @@ mod tests {
238 fn test_rename_mod_in_dir() { 241 fn test_rename_mod_in_dir() {
239 let (analysis, position) = analysis_and_position( 242 let (analysis, position) = analysis_and_position(
240 " 243 "
241 //- /lib.rs 244 //- /lib.rs
242 mod fo<|>o; 245 mod fo<|>o;
243 //- /foo/mod.rs 246 //- /foo/mod.rs
244 // emtpy 247 // emtpy
245 ", 248 ",
246 ); 249 );
247 let new_name = "foo2"; 250 let new_name = "foo2";
248 let source_change = analysis.rename(position, new_name).unwrap(); 251 let source_change = analysis.rename(position, new_name).unwrap();