diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-01 18:48:06 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-01 18:48:06 +0100 |
commit | ccec71165bf1f8f79bd2d2a5c05bed55ff3a07a2 (patch) | |
tree | 695718725ac4c9fb60a6c5c29a4f83aa489cc6c2 /crates/ra_ide_api | |
parent | 1e6b45b05ae378b9e376fcf02ecef15aa7dd1b6b (diff) | |
parent | 371961be0e0b0741599ebf3d9435c03fd45cf777 (diff) |
Merge #1360
1360: Improve goto definition for MBE r=matklad a=edwin0cheng
This PR improve the macro resolution for goto definition and expression macro invocation by using proper path resolution for external macros.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 23 | ||||
-rw-r--r-- | crates/ra_ide_api/src/name_ref_kind.rs | 2 |
2 files changed, 24 insertions, 1 deletions
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 | |||
@@ -217,6 +217,29 @@ mod tests { | |||
217 | } | 217 | } |
218 | 218 | ||
219 | #[test] | 219 | #[test] |
220 | fn goto_definition_works_for_macros_from_other_crates() { | ||
221 | covers!(goto_definition_works_for_macros); | ||
222 | check_goto( | ||
223 | " | ||
224 | //- /lib.rs | ||
225 | use foo::foo; | ||
226 | fn bar() { | ||
227 | <|>foo!(); | ||
228 | } | ||
229 | |||
230 | //- /foo/lib.rs | ||
231 | #[macro_export] | ||
232 | macro_rules! foo { | ||
233 | () => { | ||
234 | {} | ||
235 | }; | ||
236 | } | ||
237 | ", | ||
238 | "foo MACRO_CALL FileId(2) [0; 79) [29; 32)", | ||
239 | ); | ||
240 | } | ||
241 | |||
242 | #[test] | ||
220 | fn goto_definition_works_for_methods() { | 243 | fn goto_definition_works_for_methods() { |
221 | covers!(goto_definition_works_for_methods); | 244 | covers!(goto_definition_works_for_methods); |
222 | check_goto( | 245 | check_goto( |
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( | |||
39 | .and_then(ast::MacroCall::cast) | 39 | .and_then(ast::MacroCall::cast) |
40 | { | 40 | { |
41 | tested_by!(goto_definition_works_for_macros); | 41 | tested_by!(goto_definition_works_for_macros); |
42 | if let Some(mac) = analyzer.resolve_macro_call(macro_call) { | 42 | if let Some(mac) = analyzer.resolve_macro_call(db, macro_call) { |
43 | return Some(Macro(mac)); | 43 | return Some(Macro(mac)); |
44 | } | 44 | } |
45 | } | 45 | } |