-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enh(scala) add Scala 3 end
and extension
soft keywords
#3327
enh(scala) add Scala 3 end
and extension
soft keywords
#3327
Conversation
7ead484
to
8f2895d
Compare
src/languages/scala.js
Outdated
|
||
const END = { | ||
className: 'keyword', | ||
begin: /(?<=^\s*)end(\s+extension|\b)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some reason both these are special and can't simply be added to the keywords list? Is there a reason they absolutely need mode rules instead?
Are these not reserved words everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these not reserved words everywhere?
Unfortunately, they are not reserved keywords. It is not part of the Scala 2 syntax and Scala 3 only allows them in this particular context. Otherwise, they are considered normal identifiers. We can have names end
/extension
that can be defined with def extension: FileExtension = ...
or members called end
such as in line.end
.
Is there some reason both these are special and can't simply be added to the keywords list? Is there a reason they absolutely need mode rules instead?
This is to avoid breaking code in Scala 2 and code in Scala 3 (in particular contexts).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I figured once I saw you using the normal keyword feature in your other PR. We'll still need to remove the look-behind here though and find another way.
8f2895d
to
6b77d08
Compare
end
and extension
soft keywords
@nicolasstucki Thanks for the work on this! |
Looks good to me, reason it's still draft? |
Add Scala 3 end of definition or expression. Simplified verion of https://github.com/scala/vscode-scala-syntax/blob/main/src/typescript/Scala.tmLanguage.ts#L599-L634. Here we only need one kind of keyword.
6b77d08
to
fa0c541
Compare
Managed to join the |
begin: [ | ||
/^\s*/, // Is first token on the line | ||
'extension', | ||
/\s+(?=[[(])/, // followed by at least one space and `[` or `(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I use escapes for (
and [
as in the other PR?
The rule would be /\s+(?=\[|\()/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, it's a character group. But we don't generally use a single character group to avoid escapes, hence my flagging the other.
Changes
Add Scala 3
end
of definition or expression marker (see https://docs.scala-lang.org/scala3/reference/soft-modifier.html)Simplified version of https://github.com/scala/vscode-scala-syntax/blob/main/src/typescript/Scala.tmLanguage.ts#L599-L634. Here we only need one kind of keyword.
Based on #3326
Checklist
CHANGES.md