From 371961be0e0b0741599ebf3d9435c03fd45cf777 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 1 Jun 2019 19:34:19 +0800 Subject: Improve goto definition for MBE --- crates/ra_ide_api/src/goto_definition.rs | 23 +++++++++++++++++++++++ crates/ra_ide_api/src/name_ref_kind.rs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 97b367115..e72b7a6e7 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -216,6 +216,29 @@ mod tests { ); } + #[test] + fn goto_definition_works_for_macros_from_other_crates() { + covers!(goto_definition_works_for_macros); + check_goto( + " + //- /lib.rs + use foo::foo; + fn bar() { + <|>foo!(); + } + + //- /foo/lib.rs + #[macro_export] + macro_rules! foo { + () => { + {} + }; + } + ", + "foo MACRO_CALL FileId(2) [0; 79) [29; 32)", + ); + } + #[test] fn goto_definition_works_for_methods() { covers!(goto_definition_works_for_methods); diff --git a/crates/ra_ide_api/src/name_ref_kind.rs b/crates/ra_ide_api/src/name_ref_kind.rs index b498fe495..90972bc58 100644 --- a/crates/ra_ide_api/src/name_ref_kind.rs +++ b/crates/ra_ide_api/src/name_ref_kind.rs @@ -39,7 +39,7 @@ pub(crate) fn classify_name_ref( .and_then(ast::MacroCall::cast) { tested_by!(goto_definition_works_for_macros); - if let Some(mac) = analyzer.resolve_macro_call(macro_call) { + if let Some(mac) = analyzer.resolve_macro_call(db, macro_call) { return Some(Macro(mac)); } } -- cgit v1.2.3