enh(scala) add inline soft keyword#3329
Merged
joshgoebel merged 1 commit intohighlightjs:mainfrom Sep 9, 2021
Merged
Conversation
d183241 to
12cd297
Compare
joshgoebel
reviewed
Sep 6, 2021
src/languages/scala.js
Outdated
|
|
||
| const INLINE = { | ||
| className: 'keyword', | ||
| begin: /(?<!\.)\binline(?=\s)/ |
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
beginKeywords did not work with the `inline` + ... case.
12cd297 to
8cf5382
Compare
joshgoebel
reviewed
Sep 7, 2021
src/languages/scala.js
Outdated
Comment on lines
+115
to
+124
| const INLINE_NAME_SELECT = { | ||
| match: /\.inline\b/ | ||
| }; | ||
| const INLINE = { | ||
| begin: /\binline(?=\s)/, | ||
| keywords: 'inline' | ||
| }; | ||
|
|
Member
There was a problem hiding this comment.
Suggested change
| 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' | |
| }]; |
Member
There was a problem hiding this comment.
Lets keep them grouped I think.
joshgoebel
reviewed
Sep 7, 2021
src/languages/scala.js
Outdated
Comment on lines
+137
to
+138
| INLINE_NAME_SELECT, | ||
| INLINE, |
Member
There was a problem hiding this comment.
Suggested change
| INLINE_NAME_SELECT, | |
| INLINE, | |
| ...INLINE_MODES, |
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
joshgoebel
approved these changes
Sep 9, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Make
inlinea 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