diff options
Diffstat (limited to 'crates/ra_ide_api/src/goto_definition.rs')
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 1f3fa6c57..c1ce54bea 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -316,6 +316,25 @@ mod tests { | |||
316 | } | 316 | } |
317 | 317 | ||
318 | #[test] | 318 | #[test] |
319 | fn goto_definition_works_for_macros_in_use_tree() { | ||
320 | check_goto( | ||
321 | " | ||
322 | //- /lib.rs | ||
323 | use foo::foo<|>; | ||
324 | |||
325 | //- /foo/lib.rs | ||
326 | #[macro_export] | ||
327 | macro_rules! foo { | ||
328 | () => { | ||
329 | {} | ||
330 | }; | ||
331 | } | ||
332 | ", | ||
333 | "foo MACRO_CALL FileId(2) [0; 66) [29; 32)", | ||
334 | ); | ||
335 | } | ||
336 | |||
337 | #[test] | ||
319 | fn goto_definition_works_for_methods() { | 338 | fn goto_definition_works_for_methods() { |
320 | covers!(goto_definition_works_for_methods); | 339 | covers!(goto_definition_works_for_methods); |
321 | check_goto( | 340 | check_goto( |
@@ -371,6 +390,61 @@ mod tests { | |||
371 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", | 390 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", |
372 | ); | 391 | ); |
373 | } | 392 | } |
393 | |||
394 | #[test] | ||
395 | fn goto_definition_works_for_ufcs_inherent_methods() { | ||
396 | check_goto( | ||
397 | " | ||
398 | //- /lib.rs | ||
399 | struct Foo; | ||
400 | impl Foo { | ||
401 | fn frobnicate() { } | ||
402 | } | ||
403 | |||
404 | fn bar(foo: &Foo) { | ||
405 | Foo::frobnicate<|>(); | ||
406 | } | ||
407 | ", | ||
408 | "frobnicate FN_DEF FileId(1) [27; 47) [30; 40)", | ||
409 | ); | ||
410 | } | ||
411 | |||
412 | #[test] | ||
413 | fn goto_definition_works_for_ufcs_trait_methods_through_traits() { | ||
414 | check_goto( | ||
415 | " | ||
416 | //- /lib.rs | ||
417 | trait Foo { | ||
418 | fn frobnicate(); | ||
419 | } | ||
420 | |||
421 | fn bar() { | ||
422 | Foo::frobnicate<|>(); | ||
423 | } | ||
424 | ", | ||
425 | "frobnicate FN_DEF FileId(1) [16; 32) [19; 29)", | ||
426 | ); | ||
427 | } | ||
428 | |||
429 | #[test] | ||
430 | fn goto_definition_works_for_ufcs_trait_methods_through_self() { | ||
431 | check_goto( | ||
432 | " | ||
433 | //- /lib.rs | ||
434 | struct Foo; | ||
435 | trait Trait { | ||
436 | fn frobnicate(); | ||
437 | } | ||
438 | impl Trait for Foo {} | ||
439 | |||
440 | fn bar() { | ||
441 | Foo::frobnicate<|>(); | ||
442 | } | ||
443 | ", | ||
444 | "frobnicate FN_DEF FileId(1) [30; 46) [33; 43)", | ||
445 | ); | ||
446 | } | ||
447 | |||
374 | #[test] | 448 | #[test] |
375 | fn goto_definition_on_self() { | 449 | fn goto_definition_on_self() { |
376 | check_goto( | 450 | check_goto( |