Skip to content

Commit

Permalink
bugfix: highlight enum cases correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek authored and tgodzik committed Aug 10, 2023
1 parent 1f4c43f commit 4c33849
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ abstract class PcCollector[T](
case (df: NamedDefTree) :: _
if df.nameSpan.contains(pos.span) && !isGeneratedGiven(df) =>
Some(symbolAlternatives(df.symbol), pos.withSpan(df.nameSpan))
/* enum cases with params
* enum Foo:
* case B@@ar[A](i: A)
*/
case (df: NamedDefTree) :: Template(_, _, self, _) :: _
if (df.name == nme.apply || df.name == nme.unapply) && df.nameSpan.isZeroExtent =>
Some(symbolAlternatives(self.tpt.symbol), self.sourcePos)
/**
* For traversing annotations:
* @JsonNo@@tification("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,24 @@ class Scala3DocumentHighlightSuite extends BaseDocumentHighlightSuite {
|end extension""".stripMargin,
)

check(
"enum-cases".tag(IgnoreScala2),
"""|enum MyOption:
| case <<My@@Some>>(value: Int)
| case MyNone
|
|val alpha = MyOption.<<MySome>>(1)
|""".stripMargin,
)

check(
"enum-cases2".tag(IgnoreScala2),
"""|enum MyOption:
| case <<My@@Some>>[U](value: U)
| case MyNone
|
|val alpha = MyOption.<<MySome>>(1)
|""".stripMargin,
)

}

0 comments on commit 4c33849

Please sign in to comment.