Skip to content

Improve detection of definitions #174

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

Merged

Conversation

nicolasstucki
Copy link
Contributor

This makes definitions highlight before the name is typed, as it happens with all other keywords.

Also fix corner case where a comment is inserted just after a val, def, ...

This makes definitions highlight before the name is typed, as it happens with all other keywords.

Also fix corner case where a comment is inserted just after a `val`, `def`, ...
Copy link
Contributor

@MaximeKjaer MaximeKjaer left a comment

Choose a reason for hiding this comment

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

The changes look good. I have a few comments that could become low-priority issues, but I think we can already merge this.

@@ -20,6 +20,7 @@ const plainid = `(?:${idrest}|${opchar}+)`
const backQuotedId = "`[^`]+`"
const anyId = `(?:${plainid}|${backQuotedId})`
const endOfLineMaybeWithComment = "(?=\\s*(//.*|/\\*(?!.*\\*/\\s*\\S.*).*)?$)"
const notStartOfComment = "(?!//|/\\*)"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good refactoring 👍

// ^^^ keyword.declaration.scala
// ^^^^^^^^^^ comment.line.double-slash.scala

def /* comment */
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about supporting things like def /* test */ myDef() at some point? I obviously don't want it for this PR, this is very low priority, but I'm just wondering. I think it would require going to some specific state after keywords that are followed by an identifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, low priority. There might be some useful code for the end pattern that might be useful for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not really sure if it is worth adding more complexity into the rule to support this syntax that nobody should be using anyway.

// ^^^ keyword.declaration.stable.scala
// ^^^^^^^^^^ comment.line.double-slash.scala

val /* comment */
Copy link
Contributor

Choose a reason for hiding this comment

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

What about val/*test*/ x = 2?

@nicolasstucki nicolasstucki merged commit 69fe540 into scala:master Dec 16, 2020
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.

2 participants