From 0242acae5388188c06d826f4aed41eee3e91d018 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 16 Feb 2019 21:09:58 +0100 Subject: Turn ImplBlock into a copy type just containing IDs This makes it more like the other code model types. Also make Module::definition_source/declaration_source return HirFileIds, to make them more like the other source functions. --- crates/ra_ide_api/src/impls.rs | 8 ++++---- crates/ra_ide_api/src/navigation_target.rs | 15 ++++++++++----- crates/ra_ide_api/src/references.rs | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs index 681bd808d..896b47f10 100644 --- a/crates/ra_ide_api/src/impls.rs +++ b/crates/ra_ide_api/src/impls.rs @@ -50,8 +50,8 @@ fn impls_for_def( Some( impls - .lookup_impl_blocks(db, &ty) - .map(|(module, imp)| NavigationTarget::from_impl_block(db, module, &imp)) + .lookup_impl_blocks(&ty) + .map(|imp| NavigationTarget::from_impl_block(db, imp)) .collect(), ) } @@ -68,8 +68,8 @@ fn impls_for_trait( Some( impls - .lookup_impl_blocks_for_trait(db, &tr) - .map(|(module, imp)| NavigationTarget::from_impl_block(db, module, &imp)) + .lookup_impl_blocks_for_trait(&tr) + .map(|imp| NavigationTarget::from_impl_block(db, imp)) .collect(), ) } diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index c559dca11..004921863 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -79,6 +79,7 @@ impl NavigationTarget { pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { let (file_id, source) = module.definition_source(db); + let file_id = file_id.as_original_file(); let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); match source { ModuleSource::SourceFile(node) => { @@ -93,6 +94,7 @@ impl NavigationTarget { pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); if let Some((file_id, source)) = module.declaration_source(db) { + let file_id = file_id.as_original_file(); return NavigationTarget::from_syntax(file_id, name, None, source.syntax()); } NavigationTarget::from_module(db, module) @@ -151,12 +153,15 @@ impl NavigationTarget { pub(crate) fn from_impl_block( db: &RootDatabase, - module: hir::Module, - impl_block: &hir::ImplBlock, + impl_block: hir::ImplBlock, ) -> NavigationTarget { - let (file_id, _) = module.definition_source(db); - let node = module.impl_source(db, impl_block.id()); - NavigationTarget::from_syntax(file_id, "impl".into(), None, node.syntax()) + let (file_id, node) = impl_block.source(db); + NavigationTarget::from_syntax( + file_id.as_original_file(), + "impl".into(), + None, + node.syntax(), + ) } #[cfg(test)] diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index ca145f3e4..e7ebf9f6e 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs @@ -100,6 +100,7 @@ fn rename_mod( if let Some(module) = source_binder::module_from_declaration(db, position.file_id, &ast_module) { let (file_id, module_source) = module.definition_source(db); + let file_id = file_id.as_original_file(); match module_source { ModuleSource::SourceFile(..) => { let mod_path: RelativePathBuf = db.file_relative_path(file_id); -- cgit v1.2.3