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

Added impl capture. #96

Merged
merged 6 commits into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -403,31 +437,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