Skip to content

Commit

Permalink
Distinguish comparison operators
Browse files Browse the repository at this point in the history
as proposed in atom#188
  • Loading branch information
pchaigno committed Sep 7, 2015
1 parent b731239 commit 6ac4c44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions grammars/javascript.cson
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
{
'captures':
'1':
'name': 'keyword.operator.new.js'
'name': 'keyword.operator.language.js'
'2':
'name': 'entity.name.type.instance.js'
'match': '(new)\\s+(\\$?\\w+(?:\\.\\w*)?)'
Expand Down Expand Up @@ -455,10 +455,6 @@
'match': '(?<!\\.)\\b(default)\\b'
'name': 'keyword.control.js'
}
{
'match': '(?<!\\.)\\b(delete|in|of|instanceof|new|typeof|void)(?!\\s*:)\\b'
'name': 'keyword.operator.js'
}
{
'match': '(?<!\\.)\\btrue(?!\\s*:)\\b'
'name': 'constant.language.boolean.true.js'
Expand Down Expand Up @@ -519,6 +515,15 @@
'match': '(?<!\\.)\\b(module|exports|__filename|__dirname|global|process)(?!\\s*:)\\b'
'name': 'support.variable.js'
}
{
'match': '!=|!==|<=|>=|<<=|>>=|>>>=|\\*=|(?<!\\()/=|%=|\\+=|\\-=|&=|\\^=|!|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\^'
'comment': 'match 2-character operator first'
'name': 'keyword.operator.js'
}
{
'match': '(?<!\\.)\\b(delete|in|of|instanceof|new|typeof|void)(?!\\s*:)\\b'
'name': 'keyword.operator.language.js'
}
{
'match': '\\b(Infinity|NaN|undefined)\\b'
'name': 'constant.language.js'
Expand All @@ -539,11 +544,6 @@
}
]
}
{
'match': '!=|!==|<=|>=|<<=|>>=|>>>=|\\*=|(?<!\\()/=|%=|\\+=|\\-=|&=|\\^=|!|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\^'
'comment': 'match 2-character operator first'
'name': 'keyword.operator.js'
}
{
'match': '\\;'
'name': 'punctuation.terminator.statement.js'
Expand Down
8 changes: 4 additions & 4 deletions spec/javascript-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ describe "Javascript grammar", ->
describe "instantiation", ->
it "tokenizes the new keyword and instance entities", ->
{tokens} = grammar.tokenizeLine('new something')
expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js']
expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.language.js']
expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor']
expect(tokens[2]).toEqual value: 'something', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']

{tokens} = grammar.tokenizeLine('new Something')
expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js']
expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.language.js']
expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor']
expect(tokens[2]).toEqual value: 'Something', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']

{tokens} = grammar.tokenizeLine('new $something')
expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js']
expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.language.js']
expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor']
expect(tokens[2]).toEqual value: '$something', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']

Expand Down Expand Up @@ -150,7 +150,7 @@ describe "Javascript grammar", ->
describe "operators", ->
it "tokenizes void correctly", ->
{tokens} = grammar.tokenizeLine('void')
expect(tokens[0]).toEqual value: 'void', scopes: ['source.js', 'keyword.operator.js']
expect(tokens[0]).toEqual value: 'void', scopes: ['source.js', 'keyword.operator.language.js']

it "tokenizes the / arithmetic operator when separated by newlines", ->
lines = grammar.tokenizeLines """
Expand Down

0 comments on commit 6ac4c44

Please sign in to comment.