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

Commit

Permalink
Added impl capture. (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
maccoda authored and KalitaAlexey committed May 2, 2017
1 parent 2f736b3 commit c24ef01
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
61 changes: 34 additions & 27 deletions grammars/rust.cson
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
'name': 'support.type.std.rust'
'match': '\\b(ToOwned|ToString)\\b'
}
'type': {
'comment': 'A type'
'name': 'entity.name.type.rust'
'match': '\\b([A-Za-z][_A-Za-z0-9]*|_[_A-Za-z0-9]+)\\b'
}
'type_params': {
'comment': 'Type parameters'
'name': 'meta.type_params.rust'
Expand All @@ -159,11 +164,40 @@
{ 'include': '#std_types' }
{ 'include': '#std_traits' }
{ 'include': '#type_params' }
# { 'include': '#type' }
]
}
}

'patterns': [
# Implementation
{
'comment': 'Implementation'
'begin': '\\b(impl)\\b'
'end': '\\{'
'beginCaptures': {
'1': { 'name': 'storage.type.rust' }
}
'patterns': [
{ 'include': '#block_comment' }
{ 'include': '#line_comment' }
{ 'include': '#sigils' }
{ 'include': '#mut' }
{ 'include': '#ref_lifetime' }
{ 'include': '#core_types' }
{ 'include': '#core_marker' }
{ 'include': '#core_traits' }
{ 'include': '#std_types' }
{ 'include': '#std_traits' }
{ 'include': '#type_params' }
{ 'include': '#where' }
{
'name': 'storage.type.rust'
'match': '\\bfor\\b'
}
{ 'include': '#type' }
]
}
# Comments
{ 'include': '#block_doc_comment' }
{ 'include': '#block_comment' }
Expand Down Expand Up @@ -415,31 +449,4 @@
{ 'include': '#type_params' }
]
}
# Implementation
{
'comment': 'Implementation'
'begin': '\\b(impl)\\b'
'end': '\\{'
'beginCaptures': {
'1': { 'name': 'storage.type.rust' }
}
'patterns': [
{ 'include': '#block_comment' }
{ 'include': '#line_comment' }
{ 'include': '#sigils' }
{ 'include': '#mut' }
{ 'include': '#ref_lifetime' }
{ 'include': '#core_types' }
{ 'include': '#core_marker' }
{ 'include': '#core_traits' }
{ 'include': '#std_types' }
{ 'include': '#std_traits' }
{ 'include': '#type_params' }
{ 'include': '#where' }
{
'name': 'storage.type.rust'
'match': '\\bfor\\b'
}
]
}
]
4 changes: 2 additions & 2 deletions spec/rust-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ describe 'Rust grammar', ->
struct Foo<A, B> where text { }
trait Foo<A, B> : C where { }
''')
expect(tokens[0][6]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
expect(tokens[1][8]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
expect(tokens[0][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
expect(tokens[1][11]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
expect(tokens[3][8]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
expect(tokens[5][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
expect(tokens[6][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']
Expand Down

0 comments on commit c24ef01

Please sign in to comment.