Skip to content
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

Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Sep 6, 2021

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

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

@nicolasstucki nicolasstucki marked this pull request as ready for review September 6, 2021 15:02
@@ -117,6 +117,11 @@ export default function(hljs) {
contains: [ NAME ]
};

const INLINE = {
className: 'keyword',
begin: /(?<!\.)\binline(?=\s)/
Copy link
Member

@joshgoebel joshgoebel Sep 6, 2021

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.

Copy link
Contributor Author

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.

@nicolasstucki nicolasstucki marked this pull request as draft September 6, 2021 15:25
@nicolasstucki nicolasstucki marked this pull request as ready for review September 7, 2021 09:23
Comment on lines 115 to 124
const INLINE_NAME_SELECT = {
match: /\.inline\b/
};
const INLINE = {
begin: /\binline(?=\s)/,
keywords: 'inline'
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
}];

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 137 to 138
INLINE_NAME_SELECT,
INLINE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
INLINE_NAME_SELECT,
INLINE,
...INLINE_MODES,

Copy link
Contributor Author

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
@joshgoebel joshgoebel merged commit c3c04d6 into highlightjs:main Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants