Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/NavigateAST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ object NavigateAST {
case _ =>
val iterator = p match
case defdef: DefTree[?] =>
p.productIterator ++ defdef.mods.productIterator
val mods = defdef.mods
val annotations = defdef.symbol.annotations.filter(_.tree.span.contains(span)).map(_.tree)
p.productIterator ++ annotations ++ mods.productIterator
case _ =>
p.productIterator
childPath(iterator, p :: path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,51 @@ class HoverDefnSuite extends BaseHoverSuite:
|```
|""".stripMargin
)

@Test def `annotation` =
check(
"""|
|@ma@@in
|def example() =
| println("test")
|""".stripMargin,
"""|```scala
|def this(): main
|```""".stripMargin.hover
)

@Test def `annotation-2` =
check(
"""|
|@ma@@in
|def example() =
| List("test")
|""".stripMargin,
"""|```scala
|def this(): main
|```""".stripMargin.hover
)

@Test def `annotation-3` =
check(
"""|
|@ma@@in
|def example() =
| Array("test")
|""".stripMargin,
"""|```scala
|def this(): main
|```""".stripMargin.hover
)

@Test def `annotation-4` =
check(
"""|
|@ma@@in
|def example() =
| Array(1, 2)
|""".stripMargin,
"""|```scala
|def this(): main
|```""".stripMargin.hover
)
Loading