diff options
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index feb2a4d32..e356515cb 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -57,7 +57,6 @@ mod tests; | |||
57 | 57 | ||
58 | use std::sync::Arc; | 58 | use std::sync::Arc; |
59 | 59 | ||
60 | use either::Either; | ||
61 | use hir_expand::{ | 60 | use hir_expand::{ |
62 | ast_id_map::FileAstId, diagnostics::DiagnosticSink, name::Name, InFile, MacroDefId, | 61 | ast_id_map::FileAstId, diagnostics::DiagnosticSink, name::Name, InFile, MacroDefId, |
63 | }; | 62 | }; |
@@ -154,20 +153,16 @@ impl ModuleOrigin { | |||
154 | 153 | ||
155 | /// Returns a node which defines this module. | 154 | /// Returns a node which defines this module. |
156 | /// That is, a file or a `mod foo {}` with items. | 155 | /// That is, a file or a `mod foo {}` with items. |
157 | pub fn definition_source( | 156 | pub fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> { |
158 | &self, | ||
159 | db: &impl DefDatabase, | ||
160 | ) -> InFile<Either<ast::SourceFile, ast::Module>> { | ||
161 | match self { | 157 | match self { |
162 | ModuleOrigin::File(_, file_id) | ModuleOrigin::Root(Some(file_id)) => { | 158 | ModuleOrigin::File(_, file_id) | ModuleOrigin::Root(Some(file_id)) => { |
163 | let file_id = *file_id; | 159 | let file_id = *file_id; |
164 | let sf = db.parse(file_id).tree(); | 160 | let sf = db.parse(file_id).tree(); |
165 | return InFile::new(file_id.into(), Either::Left(sf)); | 161 | return InFile::new(file_id.into(), ModuleSource::SourceFile(sf)); |
166 | } | 162 | } |
167 | ModuleOrigin::Root(None) => unreachable!(), | 163 | ModuleOrigin::Root(None) => unreachable!(), |
168 | ModuleOrigin::Inline(m) => InFile::new(m.file_id, Either::Right(m.to_node(db))), | 164 | ModuleOrigin::Inline(m) => InFile::new(m.file_id, ModuleSource::Module(m.to_node(db))), |
169 | // FIXME: right now it's never constructed, so it's fine to omit | 165 | ModuleOrigin::Block(b) => InFile::new(b.file_id, ModuleSource::Block(b.to_node(db))), |
170 | ModuleOrigin::Block(_b) => unimplemented!(), | ||
171 | } | 166 | } |
172 | } | 167 | } |
173 | } | 168 | } |
@@ -348,10 +343,7 @@ impl CrateDefMap { | |||
348 | 343 | ||
349 | impl ModuleData { | 344 | impl ModuleData { |
350 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. | 345 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. |
351 | pub fn definition_source( | 346 | pub fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> { |
352 | &self, | ||
353 | db: &impl DefDatabase, | ||
354 | ) -> InFile<Either<ast::SourceFile, ast::Module>> { | ||
355 | self.origin.definition_source(db) | 347 | self.origin.definition_source(db) |
356 | } | 348 | } |
357 | 349 | ||