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

Commit

Permalink
Support attributes in the function parameter list (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
KapitanOczywisty authored Mar 30, 2021
1 parent 7382930 commit 5fae657
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions grammars/php.cson
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,9 @@
]
'function-parameters':
'patterns': [
{
'include': '#attribute'
}
{
'include': '#comments'
}
Expand Down
13 changes: 13 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,19 @@ describe 'PHP grammar', ->
expect(tokens[4]).toEqual value: 'class', scopes: ['source.php', 'meta.class.php', 'storage.type.class.php']
expect(tokens[6]).toEqual value: 'Foo', scopes: ['source.php', 'meta.class.php', 'entity.name.type.class.php']

it 'should tokenize parameter attribute', ->
{tokens} = grammar.tokenizeLine 'function Foo(#[ParameterAttribute] $parameter) {}'

expect(tokens[0]).toEqual value: 'function', scopes: ['source.php', 'meta.function.php', 'storage.type.function.php']
expect(tokens[2]).toEqual value: 'Foo', scopes: ['source.php', 'meta.function.php', 'entity.name.function.php']
expect(tokens[3]).toEqual value: '(', scopes: ['source.php', 'meta.function.php', 'punctuation.definition.parameters.begin.bracket.round.php']
expect(tokens[4]).toEqual value: '#[', scopes: ['source.php', 'meta.function.php', 'meta.function.parameters.php', 'meta.attribute.php']
expect(tokens[5]).toEqual value: 'ParameterAttribute', scopes: ['source.php', 'meta.function.php', 'meta.function.parameters.php', 'meta.attribute.php', 'support.attribute.php']
expect(tokens[6]).toEqual value: ']', scopes: ['source.php', 'meta.function.php', 'meta.function.parameters.php', 'meta.attribute.php']
expect(tokens[8]).toEqual value: '$', scopes: ['source.php', 'meta.function.php', 'meta.function.parameters.php', 'meta.function.parameter.no-default.php', 'variable.other.php', 'punctuation.definition.variable.php']
expect(tokens[9]).toEqual value: 'parameter', scopes: ['source.php', 'meta.function.php', 'meta.function.parameters.php', 'meta.function.parameter.no-default.php', 'variable.other.php']
expect(tokens[10]).toEqual value: ')', scopes: ['source.php', 'meta.function.php', 'punctuation.definition.parameters.end.bracket.round.php']

it 'should tokenize attribute for method', ->
lines = grammar.tokenizeLines '''
class Foo {
Expand Down

0 comments on commit 5fae657

Please sign in to comment.