From eedadd70241e70f76b178763fd0e005217e36ea1 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 27 Mar 2021 14:47:04 +0800 Subject: Add support for doc on hover for macro 2.0 --- crates/ide/src/hover.rs | 31 +++++++++++++++++++++++++++++ crates/syntax/src/parsing/text_tree_sink.rs | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index c43089476..3c951c507 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -1234,6 +1234,37 @@ fn f() { fo$0o!(); } ) } + #[test] + fn test_hover_macro2_invocation() { + check( + r#" +/// foo bar +/// +/// foo bar baz +macro foo() {} + +fn f() { fo$0o!(); } +"#, + expect![[r#" + *foo* + + ```rust + test + ``` + + ```rust + macro foo + ``` + + --- + + foo bar + + foo bar baz + "#]], + ) + } + #[test] fn test_hover_tuple_field() { check( diff --git a/crates/syntax/src/parsing/text_tree_sink.rs b/crates/syntax/src/parsing/text_tree_sink.rs index bb10f20c9..1934204ea 100644 --- a/crates/syntax/src/parsing/text_tree_sink.rs +++ b/crates/syntax/src/parsing/text_tree_sink.rs @@ -147,8 +147,8 @@ fn n_attached_trivias<'a>( trivias: impl Iterator, ) -> usize { match kind { - MACRO_CALL | MACRO_RULES | CONST | TYPE_ALIAS | STRUCT | UNION | ENUM | VARIANT | FN - | TRAIT | MODULE | RECORD_FIELD | STATIC | USE => { + MACRO_CALL | MACRO_RULES | MACRO_DEF | CONST | TYPE_ALIAS | STRUCT | UNION | ENUM + | VARIANT | FN | TRAIT | MODULE | RECORD_FIELD | STATIC | USE => { let mut res = 0; let mut trivias = trivias.enumerate().peekable(); -- cgit v1.2.3