aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/hover.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/hover.rs')
-rw-r--r--crates/ra_ide_api/src/hover.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 638c24e31..f14001e84 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -557,4 +557,62 @@ mod tests {
557 assert_eq!(trim_markup_opt(hover.info.first()), Some("const C: u32")); 557 assert_eq!(trim_markup_opt(hover.info.first()), Some("const C: u32"));
558 assert_eq!(hover.info.is_exact(), true); 558 assert_eq!(hover.info.is_exact(), true);
559 } 559 }
560
561 #[test]
562 fn test_hover_self() {
563 let (analysis, position) = single_file_with_position(
564 "
565 struct Thing { x: u32 };
566 impl Thing {
567 fn new() -> Self {
568 Self<|> { x: 0 }
569 }
570 }
571 ",
572 );
573 let hover = analysis.hover(position).unwrap().unwrap();
574 assert_eq!(trim_markup_opt(hover.info.first()), Some("struct Thing"));
575 assert_eq!(hover.info.is_exact(), true);
576
577 let (analysis, position) = single_file_with_position(
578 "
579 struct Thing { x: u32 };
580 impl Thing {
581 fn new() -> Self<|> {
582 Self { x: 0 }
583 }
584 }
585 ",
586 );
587 let hover = analysis.hover(position).unwrap().unwrap();
588 assert_eq!(trim_markup_opt(hover.info.first()), Some("struct Thing"));
589 assert_eq!(hover.info.is_exact(), true);
590
591 let (analysis, position) = single_file_with_position(
592 "
593 enum Thing { A };
594 impl Thing {
595 pub fn new() -> Self<|> {
596 Thing::A
597 }
598 }
599 ",
600 );
601 let hover = analysis.hover(position).unwrap().unwrap();
602 assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing"));
603 assert_eq!(hover.info.is_exact(), true);
604
605 let (analysis, position) = single_file_with_position(
606 "
607 enum Thing { A };
608 impl Thing {
609 pub fn thing(a: Self<|>) {
610 }
611 }
612 ",
613 );
614 let hover = analysis.hover(position).unwrap().unwrap();
615 assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing"));
616 assert_eq!(hover.info.is_exact(), true);
617 }
560} 618}