Add support for doc on hover for macro 2.0

This commit is contained in:
Edwin Cheng 2021-03-27 14:47:04 +08:00
parent 4520002b63
commit eedadd7024
2 changed files with 33 additions and 2 deletions

View file

@ -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] #[test]
fn test_hover_tuple_field() { fn test_hover_tuple_field() {
check( check(

View file

@ -147,8 +147,8 @@ fn n_attached_trivias<'a>(
trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
) -> usize { ) -> usize {
match kind { match kind {
MACRO_CALL | MACRO_RULES | CONST | TYPE_ALIAS | STRUCT | UNION | ENUM | VARIANT | FN MACRO_CALL | MACRO_RULES | MACRO_DEF | CONST | TYPE_ALIAS | STRUCT | UNION | ENUM
| TRAIT | MODULE | RECORD_FIELD | STATIC | USE => { | VARIANT | FN | TRAIT | MODULE | RECORD_FIELD | STATIC | USE => {
let mut res = 0; let mut res = 0;
let mut trivias = trivias.enumerate().peekable(); let mut trivias = trivias.enumerate().peekable();