From dd63f17027d5c873a5782dcbb08e9b068fc8ee00 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 11 Jun 2019 17:48:27 +0300 Subject: use Source for module, part 2 --- crates/ra_hir/src/code_model.rs | 4 ++-- crates/ra_hir/src/docs.rs | 2 +- crates/ra_ide_api/src/display/navigation_target.rs | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index e920256e5..1a33127fa 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -210,11 +210,11 @@ impl Module { pub fn declaration_source( self, db: &(impl DefDatabase + AstDatabase), - ) -> Option<(HirFileId, TreeArc)> { + ) -> Option>> { let def_map = db.crate_def_map(self.krate); let decl = def_map[self.module_id].declaration?; let ast = decl.to_node(db); - Some((decl.file_id(), ast)) + Some((decl.file_id(), ast).into()) } /// Returns the syntax of the last path segment corresponding to this import diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/docs.rs index ae82d55a5..4db066c43 100644 --- a/crates/ra_hir/src/docs.rs +++ b/crates/ra_hir/src/docs.rs @@ -71,7 +71,7 @@ pub(crate) fn documentation_query( def: DocDef, ) -> Option { match def { - DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.1), + DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.ast), DocDef::StructField(it) => match it.source(db).ast { FieldSource::Named(named) => docs_from_ast(&*named), FieldSource::Pos(..) => return None, diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 4a92be710..d7687e1a4 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs @@ -149,15 +149,15 @@ 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(); + if let Some(src) = module.declaration_source(db) { + let file_id = src.file_id.as_original_file(); return NavigationTarget::from_syntax( file_id, name, None, - source.syntax(), - source.doc_comment_text(), - source.short_label(), + src.ast.syntax(), + src.ast.doc_comment_text(), + src.ast.short_label(), ); } NavigationTarget::from_module(db, module) -- cgit v1.2.3