-
Notifications
You must be signed in to change notification settings - Fork 59
Fix meta.catch.java and meta.throwables.java scopes #144
Fix meta.catch.java and meta.throwables.java scopes #144
Conversation
@50Wliu could you have a look at this PR? Thanks! |
grammars/java.cson
Outdated
{ | ||
'include': '#parameters' | ||
'match': '\\|' | ||
'name': 'punctuation.catch.separator' |
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.
.java
grammars/java.cson
Outdated
'name': 'punctuation.catch.separator' | ||
} | ||
{ | ||
'match': '([a-zA-Z$_][\\.a-zA-Z0-9$_]*)\\s*(\\w+)*' |
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.
Should it be (\\w+)?
instead?
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.
Yes, you are right. I will update the code.
grammars/java.cson
Outdated
{ | ||
'include': '#object-types' | ||
'match': ',' | ||
'name': 'punctuation.throwables.separator' |
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.
.java
I also think this can use the standard comma separator scope.
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.
Yes, you are right. Will update.
@50Wliu thanks for review! I updated the code, would you mind taking a look again? Thanks. |
Requirements
Description of the Change
This PR updates the code for scopes
meta.catch.java
andmeta.throwables.java
and fixes scoping of exception class names and/or parameters.For
meta.catch.java
we are currently includeparameters
scope, which is not exactly correct, because parameters are assumed to bestorage + variable
, but in the case of catch block, you could see something like thisException1 | Exception2 err
, so we would only highlight the second case. I replaced it with the pattern that scopes|
as separator and requirestorage
and optionalvariable
name.For
meta.throwables.java
we are currently includingobject-types
scope, which is also not 100% correct, because they assumestorage
followed byvariable
, but inthrows
you could see something like thisthrows Exception1, Exception2
. I changed it to just parse storage type.Before:

After:

Alternate Designs
I was considering updating
parameters
andobject-types
scopes, but I found that it would be rather massive change, which might cause the regression in other parts. So I went with this fairly straightforward approach.Benefits
Fixes issue of scoping exceptions in
catch
andthrows
.Possible Drawbacks
None that I found, it does not affect existing scopes.
Applicable Issues
Closes #138