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 {
141141 case _ =>
142142 val iterator = p match
143143 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
145147 case _ =>
146148 p.productIterator
147149 childPath(iterator, p :: path)
Original file line number Diff line number Diff line change @@ -255,3 +255,51 @@ class HoverDefnSuite extends BaseHoverSuite:
255255 |```
256256 |""" .stripMargin
257257 )
258+
259+ @ Test def `annotation` =
260+ check(
261+ """ |
262+ |@ma@@in
263+ |def example() =
264+ | println("test")
265+ |""" .stripMargin,
266+ """ |```scala
267+ |def this(): main
268+ |```""" .stripMargin.hover
269+ )
270+
271+ @ Test def `annotation-2` =
272+ check(
273+ """ |
274+ |@ma@@in
275+ |def example() =
276+ | List("test")
277+ |""" .stripMargin,
278+ """ |```scala
279+ |def this(): main
280+ |```""" .stripMargin.hover
281+ )
282+
283+ @ Test def `annotation-3` =
284+ check(
285+ """ |
286+ |@ma@@in
287+ |def example() =
288+ | Array("test")
289+ |""" .stripMargin,
290+ """ |```scala
291+ |def this(): main
292+ |```""" .stripMargin.hover
293+ )
294+
295+ @ Test def `annotation-4` =
296+ check(
297+ """ |
298+ |@ma@@in
299+ |def example() =
300+ | Array(1, 2)
301+ |""" .stripMargin,
302+ """ |```scala
303+ |def this(): main
304+ |```""" .stripMargin.hover
305+ )
You can’t perform that action at this time.
0 commit comments