-
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 inline
soft keyword
#3329
enh(scala) add inline
soft keyword
#3329
Conversation
d183241
to
12cd297
Compare
src/languages/scala.js
Outdated
@@ -117,6 +117,11 @@ export default function(hljs) { | |||
contains: [ NAME ] | |||
}; | |||
|
|||
const INLINE = { | |||
className: 'keyword', | |||
begin: /(?<!\.)\binline(?=\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.
Again, can't use look-behind. To solve "false positive" cases like this you can often introduce a second dummy rule like:
// consume inline as a property access
{ match: /\.inline/ }
The dummy rule matches the property access case, preventing your highlighting rule from seeing that content.
Also, beginKeywords
has this magic built-in but you'd need to be inside of a separate scope to take advantage of that, so I think my first suggestion may be what you want.
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.
beginKeywords
did not work with the `inline` + ...
case.
12cd297
to
8cf5382
Compare
src/languages/scala.js
Outdated
const INLINE_NAME_SELECT = { | ||
match: /\.inline\b/ | ||
}; | ||
const INLINE = { | ||
begin: /\binline(?=\s)/, | ||
keywords: 'inline' | ||
}; | ||
|
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.
const INLINE_NAME_SELECT = { | |
match: /\.inline\b/ | |
}; | |
const INLINE = { | |
begin: /\binline(?=\s)/, | |
keywords: 'inline' | |
}; | |
// TODO: use negative look-behind in future | |
const INLINE_MODES = [{ | |
match: /\.inline\b/ | |
}, | |
{ | |
begin: /\binline(?=\s)/, | |
keywords: 'inline' | |
}]; |
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.
Lets keep them grouped I think.
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.
Done
src/languages/scala.js
Outdated
INLINE_NAME_SELECT, | ||
INLINE, |
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.
INLINE_NAME_SELECT, | |
INLINE, | |
...INLINE_MODES, |
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.
Done
Make `inline` a keyword when it is not part of a member selection of application. Basic idea form https://github.com/scala/vscode-scala-syntax/blob/main/src/typescript/Scala.tmLanguage.ts#L665, but without the need to distinguish the two kinds of keyword. Also see https://docs.scala-lang.org/scala3/reference/soft-modifier.html
8cf5382
to
03a39c8
Compare
Changes
Make
inline
a keyword when it is not part of a member selection of application.Basic idea form https://github.com/scala/vscode-scala-syntax/blob/main/src/typescript/Scala.tmLanguage.ts#L665, but without the need to distinguish the two kinds of keyword.
Also see https://docs.scala-lang.org/scala3/reference/soft-modifier.html
Checklist
CHANGES.md