You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: #239
vscode-scala-syntax couldn't provide consistent highlights for
`C` and `D` in `derives C, D`.
Consider we have the following code
```scala
enum A extends B derives C, D
```
Previously,
`B` and `C` have the following TextMate Scopes
```
entity.other.inherited-class.scala
source.scala
```
while `D` has
```
entity.name.class
source.scala
```
because it had accepted only one qualId after `derived`
https://github.com/scala/vscode-scala-syntax/blob/0b2b1e8829254f0d190e723d3a49874cb7d135c0/src/typescript/Scala.tmLanguage.ts#L1156
even though Scala3 syntax allows us to put multiple qualIds.
Therefore, the first one will have `entity.other.inherited-class.scala`,
but the following qualIds won't be named as
`entity.other.inherited-class.scala`. Instead, falllback to
`entity.name.class` based on it's name (upper camel).
This commit makes it provide consistent highlight for each qualId after
`derives` keyword.
Now, both `C` and `D` will have `entity.name.class` instead of
`entity.other.inherited-class.scala`.
It would be ideal to put `entity.other.inherited-class.scala` to both `C` and `D`,
but it looks like impossible with TextMate grammer.
Because, according to the [syntax](https://dotty.epfl.ch/docs/reference/contextual/derivation.html#syntax)
(see the syntax spec for Scala3 here https://docs.scala-lang.org/scala3/reference/syntax.html)
we can't tell where's the end of `derives` clause.
In the complete program, we can tell `{` or `:` is the end of `derives`
clause, but it messes up if the program is incomplete like
```scala
enum A extends B derives C, D
```
where there's no `:` or `{`.
Just give up providing `entity.other.inherited-class.scala` and
put `entity.name.class` based on their name (upper camel).
0 commit comments