vscode-scala-syntax
vscode-scala-syntax copied to clipboard
Consistent highlight on derives' qualIds
fix: https://github.com/scala/vscode-scala-syntax/issues/239
vscode-scala-syntax couldn't provide consistent highlights for
C and D in derives C, D.
Problem
Consider we have the following code
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).
fix
This commit makes it provides 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.
alternative solution
It would be ideal to put entity.other.inherited-class.scala to both C and D,
but it looks like impossible with TextMate grammar.
Because according to the 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
enum A extends B derives C, D
where there's no : or {.
So, just give up providing entity.other.inherited-class.scala and put entity.name.class based on their name (upper camel).
@Meowcolm024 What do you think about this? you can check it by
- check out this branch
tanishiking:derives yarn install,yarn buildcode --install-extension scala-0.5.6.vsix- restart vscode
Decided to assign entity.name.class to A, B in extends A, B, maybe we should do the same thing for with A (even though it doesn't accept with A, B) for consistency 🤔
Closing for https://github.com/scala/vscode-scala-syntax/pull/242