aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2021-03-27 06:47:04 +0000
committerEdwin Cheng <[email protected]>2021-03-27 06:57:11 +0000
commiteedadd70241e70f76b178763fd0e005217e36ea1 (patch)
tree6eaf9996f4e6e177df8d7802bb2046e0505aaa7d
parent4520002b63b5a27e7676822aecfb2d435bf36e5a (diff)
Add support for doc on hover for macro 2.0
-rw-r--r--crates/ide/src/hover.rs31
-rw-r--r--crates/syntax/src/parsing/text_tree_sink.rs4
2 files changed, 33 insertions, 2 deletions
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
@@ -1235,6 +1235,37 @@ fn f() { fo$0o!(); }
1235 } 1235 }
1236 1236
1237 #[test] 1237 #[test]
1238 fn test_hover_macro2_invocation() {
1239 check(
1240 r#"
1241/// foo bar
1242///
1243/// foo bar baz
1244macro foo() {}
1245
1246fn f() { fo$0o!(); }
1247"#,
1248 expect![[r#"
1249 *foo*
1250
1251 ```rust
1252 test
1253 ```
1254
1255 ```rust
1256 macro foo
1257 ```
1258
1259 ---
1260
1261 foo bar
1262
1263 foo bar baz
1264 "#]],
1265 )
1266 }
1267
1268 #[test]
1238 fn test_hover_tuple_field() { 1269 fn test_hover_tuple_field() {
1239 check( 1270 check(
1240 r#"struct TS(String, i32$0);"#, 1271 r#"struct TS(String, i32$0);"#,
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>(
147 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 147 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
148) -> usize { 148) -> usize {
149 match kind { 149 match kind {
150 MACRO_CALL | MACRO_RULES | CONST | TYPE_ALIAS | STRUCT | UNION | ENUM | VARIANT | FN 150 MACRO_CALL | MACRO_RULES | MACRO_DEF | CONST | TYPE_ALIAS | STRUCT | UNION | ENUM
151 | TRAIT | MODULE | RECORD_FIELD | STATIC | USE => { 151 | VARIANT | FN | TRAIT | MODULE | RECORD_FIELD | STATIC | USE => {
152 let mut res = 0; 152 let mut res = 0;
153 let mut trivias = trivias.enumerate().peekable(); 153 let mut trivias = trivias.enumerate().peekable();
154 154