-
Notifications
You must be signed in to change notification settings - Fork 37
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
Improve detection of definitions #174
Conversation
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`, ...
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.
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 = "(?!//|/\\*)" |
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 a good refactoring 👍
// ^^^ keyword.declaration.scala | ||
// ^^^^^^^^^^ comment.line.double-slash.scala | ||
|
||
def /* comment */ |
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.
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.
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.
Indeed, low priority. There might be some useful code for the end
pattern that might be useful for this.
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.
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 */ |
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.
What about val/*test*/ x = 2
?
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
, ...