Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix capitalized variables being highlighted as storage type #128

Merged
merged 2 commits into from Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion grammars/java.cson
Expand Up @@ -1004,7 +1004,8 @@
}
{
# If the above fails *then* just look for Wow
'match': '\\b(?:[A-Z]\\w*\\s*(\\.)\\s*)*[A-Z]\\w*\\b'
# (must be followed by a variable name, we use '\n' to cover multi-line definitions)
'match': '\\b(?:[A-Z]\\w*\\s*(\\.)\\s*)*[A-Z]\\w*\\b(?=\\s*[A-Za-z$_\\n])'
'name': 'storage.type.java'
'captures':
'1':
Expand Down
24 changes: 24 additions & 0 deletions spec/java-spec.coffee
Expand Up @@ -770,6 +770,30 @@ describe 'Java grammar', ->
expect(lines[6][3]).toEqual value: 'primitive', scopes: ['source.java', 'meta.class.java', 'meta.class.body.java', 'meta.method.java', 'meta.method.body.java', 'meta.definition.variable.java', 'variable.other.definition.java']
expect(lines[6][7]).toEqual value: '5', scopes: ['source.java', 'meta.class.java', 'meta.class.body.java', 'meta.method.java', 'meta.method.body.java', 'meta.definition.variable.java', 'constant.numeric.decimal.java']

it 'tokenizes capitalized variables', ->
lines = grammar.tokenizeLines '''
void func()
{
int g = 1;
g += 2;
int G = 1;
G += 2;

if (G > g) {
// do something
}
}
'''

expect(lines[2][3]).toEqual value: 'g', scopes: ['source.java', 'meta.definition.variable.java', 'variable.other.definition.java']
expect(lines[3][0]).toEqual value: ' g ', scopes: ['source.java']
expect(lines[4][3]).toEqual value: 'G', scopes: ['source.java', 'meta.definition.variable.java', 'variable.other.definition.java']
expect(lines[5][0]).toEqual value: ' G ', scopes: ['source.java'] # should not be highlighted as storage type!

expect(lines[7][4]).toEqual value: 'G ', scopes: ['source.java'] # should not be highlighted as storage type!
expect(lines[7][5]).toEqual value: '>', scopes: ['source.java', 'keyword.operator.comparison.java']
expect(lines[7][6]).toEqual value: ' g', scopes: ['source.java']

it 'tokenizes function and method calls', ->
lines = grammar.tokenizeLines '''
class A
Expand Down