Repository navigation
Fix capitalized variables being highlighted as storage type - #128
Conversation
|
@50Wliu could you review this PR, please? Thanks! |
| # If the above fails *then* just look for Wow | ||
| 'match': '\\b(?:[A-Z]\\w*\\s*(\\.)\\s*)*[A-Z]\\w*\\b' | ||
| # If the above fails *then* just look for Wow (must be followed by a variable name) | ||
| 'match': '\\b(?:[A-Z]\\w*\\s*(\\.)\\s*)*[A-Z]\\w*\\b(?=\\s*(\\w|\\$))' |
There was a problem hiding this comment.
Nitpick: [\\w$] might be clearer and is typically what we do with languages that accept $ as an identifier. Also I think variables can start with underscores?
There was a problem hiding this comment.
Yes, you are right. I actually replaced with the following: [A-Za-z$_\\n], which is what we use for start of the variable, and I added new line to cover cases:
String
test = "abc";With this change, current highlighting is the same as in master branch (which is not exactly the same as inline definition String test = "abc").
|
My only concern: I think Java allows multiline variable declarations like String
test = 3;Please tell me if I'm wrong. Even if that's allowed, I'm thinking that this change should be merged because uppercase variables are more likely than multiline declarations. |


Requirements
Description of the Change
This PR fixes highlighting of variables that are capitalized or start with capital letter. I fixed by enforcing that the last branch of 'object-types' pattern requires the next word (variable name); and since variable names can start with
A-Za-zor_, or$, I added\w|$.Tested on the code:
Alternate Designs
None were considered, though I was experimenting with different changes to see what actually affects the highlighting.
Benefits
Fix problem with highlighting variables starting with capital letters in situations like, but not limited to:
Possible Drawbacks
Might break something else, but it passes all tests so far.
Applicable Issues
Closes #76