Permalink
Browse files

Merge pull request #79 from rkma/tokenize-unused-and-wildcard

Add unused and wildcard variables
  • Loading branch information...
2 parents 99afafc + b3033b6 commit 03f015926284ab7c14d7f0f31655ae57a5efdd27 @keathley keathley committed on GitHub Oct 17, 2016
Showing with 17 additions and 4 deletions.
  1. +6 −2 grammars/elixir.cson
  2. +11 −2 spec/elixir-spec.coffee
@@ -1464,8 +1464,12 @@
'name': 'comment.line.number-sign.elixir'
}
{
- 'match': '\\b_(\\w*)'
- 'name': 'comment.elixir'
+ 'match': '\\b_([\\w]+[?!]?)'
+ 'name': 'unused.comment.elixir'
+ }
+ {
+ 'match': '\\b_\\b'
+ 'name': 'wildcard.comment.elixir'
}
{
'comment': """
@@ -13,8 +13,17 @@ describe "Elixir grammar", ->
expect(grammar.scopeName).toBe "source.elixir"
it "tokenizes underscore variables as comments", ->
- {tokens} = grammar.tokenizeLine('_some_variable')
- expect(tokens[0]).toEqual value: '_some_variable', scopes: ['source.elixir', 'comment.elixir']
+ {tokens} = grammar.tokenizeLine('_some_variable?')
+ expect(tokens[0]).toEqual value: '_some_variable?', scopes: ['source.elixir', 'unused.comment.elixir']
+
+ {tokens} = grammar.tokenizeLine('some_variable')
+ expect(tokens[0]).toEqual value: 'some_variable', scopes: ['source.elixir']
+
+ it "tokenizes underscore as wildcard variable", ->
+ {tokens} = grammar.tokenizeLine('this _ other_thing')
+ expect(tokens[0]).not.toEqual value: 'this ', scopes: ['source.elixir', 'wildcard.comment.elixir']
+ expect(tokens[1]).toEqual value: '_', scopes: ['source.elixir', 'wildcard.comment.elixir']
+ expect(tokens[2]).not.toEqual value: ' other_thing', scopes: ['source.elixir', 'wildcard.comment.elixir']
{tokens} = grammar.tokenizeLine('some_variable')
expect(tokens[0]).toEqual value: 'some_variable', scopes: ['source.elixir']

0 comments on commit 03f0159

Please sign in to comment.