Skip to content

Commit

Permalink
bugfix: highlight enum cases correctly (#18362)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik authored Aug 9, 2023
2 parents 5383ff6 + aca2503 commit 5fc691a
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 @@ -194,6 +194,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 @@ -998,3 +998,23 @@ class DocumentHighlightSuite extends BaseDocumentHighlightSuite:
| def double2(ys: List[EF]) = <<xs>> ++ ys
|end extension""".stripMargin
)

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

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

0 comments on commit 5fc691a

Please sign in to comment.