diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-04 19:38:10 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-04 19:38:10 +0100 |
commit | aa7bdfd37f999607806cf47c0108d33a5b44b3e5 (patch) | |
tree | 83e606dd367454ce65262b77e0a64d723c858d35 /crates/ra_ide_api/src/display | |
parent | 9c49f6c36e1e097f938946811d1e2f5eb70edca9 (diff) | |
parent | 8198e13c26fe985af5893af7bdac04041880b461 (diff) |
Merge #1208
1208: [WIP] Goto for Macro's r=matklad a=Lapz
Adds goto definition for macros. Currently only works for macros in the current crate ~~otherwise it panics~~. Proper macro resolution needs to be added for it to resolve macros in other crates.
Todo
- [X] Allow goto from macro calls
- [X] Fix panics
- [x] Add tests

Co-authored-by: Lenard Pratt <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/display')
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 84645287d..765cf883b 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -213,6 +213,15 @@ impl NavigationTarget { | |||
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | pub(crate) fn from_macro_def( | ||
217 | db: &RootDatabase, | ||
218 | macro_call: hir::MacroByExampleDef, | ||
219 | ) -> NavigationTarget { | ||
220 | let (file_id, node) = macro_call.source(db); | ||
221 | log::debug!("nav target {}", node.syntax().debug_dump()); | ||
222 | NavigationTarget::from_named(file_id.original_file(db), &*node) | ||
223 | } | ||
224 | |||
216 | #[cfg(test)] | 225 | #[cfg(test)] |
217 | pub(crate) fn assert_match(&self, expected: &str) { | 226 | pub(crate) fn assert_match(&self, expected: &str) { |
218 | let actual = self.debug_render(); | 227 | let actual = self.debug_render(); |
@@ -289,6 +298,7 @@ impl NavigationTarget { | |||
289 | .visit(doc_comments::<ast::StaticDef>) | 298 | .visit(doc_comments::<ast::StaticDef>) |
290 | .visit(doc_comments::<ast::NamedFieldDef>) | 299 | .visit(doc_comments::<ast::NamedFieldDef>) |
291 | .visit(doc_comments::<ast::EnumVariant>) | 300 | .visit(doc_comments::<ast::EnumVariant>) |
301 | .visit(doc_comments::<ast::MacroCall>) | ||
292 | .accept(&node)? | 302 | .accept(&node)? |
293 | } | 303 | } |
294 | 304 | ||