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

Commit 3df1958

Browse files
authored
Merge pull request #276 from alxtz/master
[tree-sitter] add variable identifier support in assignments expressions
2 parents 2323b3e + 55ab414 commit 3df1958

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

grammars/tree-sitter-ruby.cson

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ scopes:
161161
'")"': 'punctuation.definition.parameters'
162162

163163
'method > identifier': 'entity.name.function'
164+
'assignment > identifier': 'variable'
165+
164166
'singleton_method > identifier:nth-child(3)': 'entity.name.function'
165167
'setter > identifier': 'entity.name.function'
166168
'call > identifier:nth-child(2)': 'entity.name.function'

spec/tree-sitter-spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,26 @@ describe('Tree-sitter Ruby grammar', () => {
108108
'.source.ruby .keyword.control'
109109
)
110110
})
111+
112+
it('tokenizes variable in assignment expressions', async () => {
113+
const editor = await atom.workspace.open('foo.rb')
114+
editor.setText(dedent`
115+
a = 10
116+
`)
117+
118+
expect(editor.scopeDescriptorForBufferPosition([0, 0]).toString()).toBe(
119+
'.source.ruby .variable'
120+
)
121+
})
122+
123+
it('does not tokenizes method call in assignment expressions', async () => {
124+
const editor = await atom.workspace.open('foo.rb')
125+
editor.setText(dedent`
126+
foo() = 10
127+
`)
128+
129+
expect(editor.scopeDescriptorForBufferPosition([0, 0]).toString()).not.toBe(
130+
'.source.ruby .variable'
131+
)
132+
})
111133
})

0 commit comments

Comments
 (0)