File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
compiler/src/dotty/tools/dotc/ast
presentation-compiler/test/dotty/tools/pc/tests/hover Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,9 @@ object NavigateAST {
141
141
case _ =>
142
142
val iterator = p match
143
143
case defdef : DefTree [? ] =>
144
- p.productIterator ++ defdef.mods.productIterator
144
+ val mods = defdef.mods
145
+ val annotations = defdef.symbol.annotations.filter(_.tree.span.contains(span)).map(_.tree)
146
+ p.productIterator ++ annotations ++ mods.productIterator
145
147
case _ =>
146
148
p.productIterator
147
149
childPath(iterator, p :: path)
Original file line number Diff line number Diff line change @@ -279,3 +279,51 @@ class HoverDefnSuite extends BaseHoverSuite:
279
279
|```
280
280
|""" .stripMargin
281
281
)
282
+
283
+ @ Test def `annotation` =
284
+ check(
285
+ """ |
286
+ |@ma@@in
287
+ |def example() =
288
+ | println("test")
289
+ |""" .stripMargin,
290
+ """ |```scala
291
+ |def this(): main
292
+ |```""" .stripMargin.hover
293
+ )
294
+
295
+ @ Test def `annotation-2` =
296
+ check(
297
+ """ |
298
+ |@ma@@in
299
+ |def example() =
300
+ | List("test")
301
+ |""" .stripMargin,
302
+ """ |```scala
303
+ |def this(): main
304
+ |```""" .stripMargin.hover
305
+ )
306
+
307
+ @ Test def `annotation-3` =
308
+ check(
309
+ """ |
310
+ |@ma@@in
311
+ |def example() =
312
+ | Array("test")
313
+ |""" .stripMargin,
314
+ """ |```scala
315
+ |def this(): main
316
+ |```""" .stripMargin.hover
317
+ )
318
+
319
+ @ Test def `annotation-4` =
320
+ check(
321
+ """ |
322
+ |@ma@@in
323
+ |def example() =
324
+ | Array(1, 2)
325
+ |""" .stripMargin,
326
+ """ |```scala
327
+ |def this(): main
328
+ |```""" .stripMargin.hover
329
+ )
You can’t perform that action at this time.
0 commit comments