Skip to content

Commit

Permalink
bugfix: highlight enum cases correctly
Browse files Browse the repository at this point in the history
[Cherry-picked aca2503]
  • Loading branch information
kasiaMarek authored and Kordyjan committed Dec 7, 2023
1 parent 6468e1b commit 9200b7e
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 9200b7e

Please sign in to comment.