aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/code_model.rs15
-rw-r--r--crates/ra_hir/src/docs.rs2
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs10
-rw-r--r--crates/ra_ide_api/src/hover.rs4
4 files changed, 18 insertions, 13 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 5b56f890e..adb61a804 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -1003,12 +1003,17 @@ pub struct MacroDef {
1003 pub(crate) id: MacroDefId, 1003 pub(crate) id: MacroDefId,
1004} 1004}
1005 1005
1006impl HasSource for MacroDef {
1007 type Ast = TreeArc<ast::MacroCall>;
1008
1009 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::MacroCall>> {
1010 (self.id.0.file_id(), self.id.0.to_node(db)).into()
1011 }
1012}
1013
1006impl MacroDef { 1014impl MacroDef {
1007 pub fn source( 1015 pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::MacroCall>> {
1008 &self, 1016 (self.id.0.file_id(), self.id.0.to_node(db)).into()
1009 db: &(impl DefDatabase + AstDatabase),
1010 ) -> (HirFileId, TreeArc<ast::MacroCall>) {
1011 (self.id.0.file_id(), self.id.0.to_node(db))
1012 } 1017 }
1013} 1018}
1014 1019
diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/docs.rs
index f736f3875..cbf7ae10b 100644
--- a/crates/ra_hir/src/docs.rs
+++ b/crates/ra_hir/src/docs.rs
@@ -85,7 +85,7 @@ pub(crate) fn documentation_query(
85 DocDef::Union(it) => docs_from_ast(&*it.source(db).ast), 85 DocDef::Union(it) => docs_from_ast(&*it.source(db).ast),
86 DocDef::Trait(it) => docs_from_ast(&*it.source(db).ast), 86 DocDef::Trait(it) => docs_from_ast(&*it.source(db).ast),
87 DocDef::TypeAlias(it) => docs_from_ast(&*it.source(db).ast), 87 DocDef::TypeAlias(it) => docs_from_ast(&*it.source(db).ast),
88 DocDef::MacroDef(it) => docs_from_ast(&*it.source(db).1), 88 DocDef::MacroDef(it) => docs_from_ast(&*it.source(db).ast),
89 } 89 }
90} 90}
91 91
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs
index 640d68544..e5e1aa011 100644
--- a/crates/ra_ide_api/src/display/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -248,12 +248,12 @@ impl NavigationTarget {
248 } 248 }
249 249
250 pub(crate) fn from_macro_def(db: &RootDatabase, macro_call: hir::MacroDef) -> NavigationTarget { 250 pub(crate) fn from_macro_def(db: &RootDatabase, macro_call: hir::MacroDef) -> NavigationTarget {
251 let (file_id, node) = macro_call.source(db); 251 let src = macro_call.source(db);
252 log::debug!("nav target {}", node.syntax().debug_dump()); 252 log::debug!("nav target {}", src.ast.syntax().debug_dump());
253 NavigationTarget::from_named( 253 NavigationTarget::from_named(
254 file_id.original_file(db), 254 src.file_id.original_file(db),
255 &*node, 255 &*src.ast,
256 node.doc_comment_text(), 256 src.ast.doc_comment_text(),
257 None, 257 None,
258 ) 258 )
259 } 259 }
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index c4004435c..72328a72b 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -98,8 +98,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
98 match classify_name_ref(db, &analyzer, name_ref) { 98 match classify_name_ref(db, &analyzer, name_ref) {
99 Some(Method(it)) => res.extend(from_def_source(db, it)), 99 Some(Method(it)) => res.extend(from_def_source(db, it)),
100 Some(Macro(it)) => { 100 Some(Macro(it)) => {
101 let it = it.source(db).1; 101 let src = it.source(db);
102 res.extend(hover_text(it.doc_comment_text(), None)); 102 res.extend(hover_text(src.ast.doc_comment_text(), None));
103 } 103 }
104 Some(FieldAccess(it)) => { 104 Some(FieldAccess(it)) => {
105 let it = it.source(db).1; 105 let it = it.source(db).1;