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

Commit

Permalink
Merge pull request #139 from atom/wl-var-channels
Browse files Browse the repository at this point in the history
Support channels in variable declarations
  • Loading branch information
50Wliu authored Sep 27, 2017
2 parents 8ffd5e8 + dba0fbf commit f7c6ca6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion grammars/go.cson
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@
# var a [][]*string
# var a c.d
# var a []c.d
'match': '(\\w+(?:,\\s*\\w+)*)(\\s+(\\[(\\d*|\\.\\.\\.)\\])*\\*?\\w+(?:\\.\\w+)?\\s*[^=].*)'
# var a <-chan string
'match': '(\\w+(?:,\\s*\\w+)*)(\\s+(\\[(\\d*|\\.\\.\\.)\\])*\\*?(<-)?\\w+(?:\\.\\w+)?\\s*[^=].*)'
'captures':
'1':
'patterns': [
Expand Down
8 changes: 8 additions & 0 deletions spec/go-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,14 @@ describe 'Go grammar', ->
testOpAddress tokens[8], '*'
testStringType tokens[9], 'string'

it 'tokenizes a single name and a channel', ->
{tokens} = grammar.tokenizeLine 'var x <-chan bool'
testVar tokens[0]
testVarDeclaration tokens[2], 'x'
expect(tokens[4]).toEqual value: '<-', scopes: ['source.go', 'keyword.operator.channel.go']
expect(tokens[5]).toEqual value: 'chan', scopes: ['source.go', 'keyword.channel.go']
expect(tokens[7]).toEqual value: 'bool', scopes: ['source.go', 'storage.type.boolean.go']

it 'tokenizes a single name and its initialization', ->
{tokens} = grammar.tokenizeLine ' var k = 0'
testVar tokens[1]
Expand Down

0 comments on commit f7c6ca6

Please sign in to comment.