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

Commit c24ef01

Browse files
maccodaKalitaAlexey
authored andcommitted
Added impl capture. (#96)
1 parent 2f736b3 commit c24ef01

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

grammars/rust.cson

+34-27
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@
142142
'name': 'support.type.std.rust'
143143
'match': '\\b(ToOwned|ToString)\\b'
144144
}
145+
'type': {
146+
'comment': 'A type'
147+
'name': 'entity.name.type.rust'
148+
'match': '\\b([A-Za-z][_A-Za-z0-9]*|_[_A-Za-z0-9]+)\\b'
149+
}
145150
'type_params': {
146151
'comment': 'Type parameters'
147152
'name': 'meta.type_params.rust'
@@ -159,11 +164,40 @@
159164
{ 'include': '#std_types' }
160165
{ 'include': '#std_traits' }
161166
{ 'include': '#type_params' }
167+
# { 'include': '#type' }
162168
]
163169
}
164170
}
165171

166172
'patterns': [
173+
# Implementation
174+
{
175+
'comment': 'Implementation'
176+
'begin': '\\b(impl)\\b'
177+
'end': '\\{'
178+
'beginCaptures': {
179+
'1': { 'name': 'storage.type.rust' }
180+
}
181+
'patterns': [
182+
{ 'include': '#block_comment' }
183+
{ 'include': '#line_comment' }
184+
{ 'include': '#sigils' }
185+
{ 'include': '#mut' }
186+
{ 'include': '#ref_lifetime' }
187+
{ 'include': '#core_types' }
188+
{ 'include': '#core_marker' }
189+
{ 'include': '#core_traits' }
190+
{ 'include': '#std_types' }
191+
{ 'include': '#std_traits' }
192+
{ 'include': '#type_params' }
193+
{ 'include': '#where' }
194+
{
195+
'name': 'storage.type.rust'
196+
'match': '\\bfor\\b'
197+
}
198+
{ 'include': '#type' }
199+
]
200+
}
167201
# Comments
168202
{ 'include': '#block_doc_comment' }
169203
{ 'include': '#block_comment' }
@@ -415,31 +449,4 @@
415449
{ 'include': '#type_params' }
416450
]
417451
}
418-
# Implementation
419-
{
420-
'comment': 'Implementation'
421-
'begin': '\\b(impl)\\b'
422-
'end': '\\{'
423-
'beginCaptures': {
424-
'1': { 'name': 'storage.type.rust' }
425-
}
426-
'patterns': [
427-
{ 'include': '#block_comment' }
428-
{ 'include': '#line_comment' }
429-
{ 'include': '#sigils' }
430-
{ 'include': '#mut' }
431-
{ 'include': '#ref_lifetime' }
432-
{ 'include': '#core_types' }
433-
{ 'include': '#core_marker' }
434-
{ 'include': '#core_traits' }
435-
{ 'include': '#std_types' }
436-
{ 'include': '#std_traits' }
437-
{ 'include': '#type_params' }
438-
{ 'include': '#where' }
439-
{
440-
'name': 'storage.type.rust'
441-
'match': '\\bfor\\b'
442-
}
443-
]
444-
}
445452
]

spec/rust-spec.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ describe 'Rust grammar', ->
539539
struct Foo<A, B> where text { }
540540
trait Foo<A, B> : C where { }
541541
''')
542-
expect(tokens[0][6]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
543-
expect(tokens[1][8]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
542+
expect(tokens[0][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
543+
expect(tokens[1][11]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
544544
expect(tokens[3][8]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
545545
expect(tokens[5][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
546546
expect(tokens[6][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']

0 commit comments

Comments
 (0)