diff options
author | uHOOCCOOHu <[email protected]> | 2019-09-10 06:33:02 +0100 |
---|---|---|
committer | uHOOCCOOHu <[email protected]> | 2019-09-10 06:33:02 +0100 |
commit | c66a789a045c3c521620af73c1f06314fbe315bb (patch) | |
tree | e9d58a7d19140a6f6b610ca4f64250b989eeac0c | |
parent | 7de9537cccc7a6338bcd9c892a1fdb4a6008dc1a (diff) |
Show macro definition in hover text
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 1981e62d3..4b7847de8 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -12,8 +12,8 @@ use ra_syntax::{ | |||
12 | use crate::{ | 12 | use crate::{ |
13 | db::RootDatabase, | 13 | db::RootDatabase, |
14 | display::{ | 14 | display::{ |
15 | description_from_symbol, docs_from_symbol, rust_code_markup, rust_code_markup_with_doc, | 15 | description_from_symbol, docs_from_symbol, macro_label, rust_code_markup, |
16 | ShortLabel, | 16 | rust_code_markup_with_doc, ShortLabel, |
17 | }, | 17 | }, |
18 | name_ref_kind::{classify_name_ref, NameRefKind::*}, | 18 | name_ref_kind::{classify_name_ref, NameRefKind::*}, |
19 | FilePosition, FileRange, RangeInfo, | 19 | FilePosition, FileRange, RangeInfo, |
@@ -108,7 +108,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
108 | Some(Method(it)) => res.extend(from_def_source(db, it)), | 108 | Some(Method(it)) => res.extend(from_def_source(db, it)), |
109 | Some(Macro(it)) => { | 109 | Some(Macro(it)) => { |
110 | let src = it.source(db); | 110 | let src = it.source(db); |
111 | res.extend(hover_text(src.ast.doc_comment_text(), None)); | 111 | res.extend(hover_text(src.ast.doc_comment_text(), Some(macro_label(&src.ast)))); |
112 | } | 112 | } |
113 | Some(FieldAccess(it)) => { | 113 | Some(FieldAccess(it)) => { |
114 | let src = it.source(db); | 114 | let src = it.source(db); |
@@ -700,4 +700,22 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
700 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); | 700 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); |
701 | assert_eq!(hover.info.is_exact(), true); | 701 | assert_eq!(hover.info.is_exact(), true); |
702 | } | 702 | } |
703 | |||
704 | #[test] | ||
705 | fn test_hover_macro_invocation() { | ||
706 | let (analysis, position) = single_file_with_position( | ||
707 | " | ||
708 | macro_rules! foo { | ||
709 | () => {} | ||
710 | } | ||
711 | |||
712 | fn f() { | ||
713 | fo<|>o!(); | ||
714 | } | ||
715 | ", | ||
716 | ); | ||
717 | let hover = analysis.hover(position).unwrap().unwrap(); | ||
718 | assert_eq!(trim_markup_opt(hover.info.first()), Some("macro_rules! foo")); | ||
719 | assert_eq!(hover.info.is_exact(), true); | ||
720 | } | ||
703 | } | 721 | } |