diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/impls.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/navigation_target.rs | 15 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 1 |
3 files changed, 15 insertions, 9 deletions
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( | |||
50 | 50 | ||
51 | Some( | 51 | Some( |
52 | impls | 52 | impls |
53 | .lookup_impl_blocks(db, &ty) | 53 | .lookup_impl_blocks(&ty) |
54 | .map(|(module, imp)| NavigationTarget::from_impl_block(db, module, &imp)) | 54 | .map(|imp| NavigationTarget::from_impl_block(db, imp)) |
55 | .collect(), | 55 | .collect(), |
56 | ) | 56 | ) |
57 | } | 57 | } |
@@ -68,8 +68,8 @@ fn impls_for_trait( | |||
68 | 68 | ||
69 | Some( | 69 | Some( |
70 | impls | 70 | impls |
71 | .lookup_impl_blocks_for_trait(db, &tr) | 71 | .lookup_impl_blocks_for_trait(&tr) |
72 | .map(|(module, imp)| NavigationTarget::from_impl_block(db, module, &imp)) | 72 | .map(|imp| NavigationTarget::from_impl_block(db, imp)) |
73 | .collect(), | 73 | .collect(), |
74 | ) | 74 | ) |
75 | } | 75 | } |
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 { | |||
79 | 79 | ||
80 | pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { | 80 | pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { |
81 | let (file_id, source) = module.definition_source(db); | 81 | let (file_id, source) = module.definition_source(db); |
82 | let file_id = file_id.as_original_file(); | ||
82 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 83 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
83 | match source { | 84 | match source { |
84 | ModuleSource::SourceFile(node) => { | 85 | ModuleSource::SourceFile(node) => { |
@@ -93,6 +94,7 @@ impl NavigationTarget { | |||
93 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { | 94 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { |
94 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 95 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
95 | if let Some((file_id, source)) = module.declaration_source(db) { | 96 | if let Some((file_id, source)) = module.declaration_source(db) { |
97 | let file_id = file_id.as_original_file(); | ||
96 | return NavigationTarget::from_syntax(file_id, name, None, source.syntax()); | 98 | return NavigationTarget::from_syntax(file_id, name, None, source.syntax()); |
97 | } | 99 | } |
98 | NavigationTarget::from_module(db, module) | 100 | NavigationTarget::from_module(db, module) |
@@ -151,12 +153,15 @@ impl NavigationTarget { | |||
151 | 153 | ||
152 | pub(crate) fn from_impl_block( | 154 | pub(crate) fn from_impl_block( |
153 | db: &RootDatabase, | 155 | db: &RootDatabase, |
154 | module: hir::Module, | 156 | impl_block: hir::ImplBlock, |
155 | impl_block: &hir::ImplBlock, | ||
156 | ) -> NavigationTarget { | 157 | ) -> NavigationTarget { |
157 | let (file_id, _) = module.definition_source(db); | 158 | let (file_id, node) = impl_block.source(db); |
158 | let node = module.impl_source(db, impl_block.id()); | 159 | NavigationTarget::from_syntax( |
159 | NavigationTarget::from_syntax(file_id, "impl".into(), None, node.syntax()) | 160 | file_id.as_original_file(), |
161 | "impl".into(), | ||
162 | None, | ||
163 | node.syntax(), | ||
164 | ) | ||
160 | } | 165 | } |
161 | 166 | ||
162 | #[cfg(test)] | 167 | #[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( | |||
100 | if let Some(module) = source_binder::module_from_declaration(db, position.file_id, &ast_module) | 100 | if let Some(module) = source_binder::module_from_declaration(db, position.file_id, &ast_module) |
101 | { | 101 | { |
102 | let (file_id, module_source) = module.definition_source(db); | 102 | let (file_id, module_source) = module.definition_source(db); |
103 | let file_id = file_id.as_original_file(); | ||
103 | match module_source { | 104 | match module_source { |
104 | ModuleSource::SourceFile(..) => { | 105 | ModuleSource::SourceFile(..) => { |
105 | let mod_path: RelativePathBuf = db.file_relative_path(file_id); | 106 | let mod_path: RelativePathBuf = db.file_relative_path(file_id); |