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

Commit

Permalink
Merge pull request #411 from KapitanOczywisty/FixAttributes
Browse files Browse the repository at this point in the history
Fix attributes with leading whitespaces
  • Loading branch information
sadick254 authored Jan 12, 2021
2 parents d0da77f + 48abde6 commit 47e1a1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion grammars/php.cson
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@
]
}
{
'begin': '(^\\s+)?(?=#)'
'begin': '(^\\s+)?(?=#)(?!#\\[)'
'beginCaptures':
'1':
'name': 'punctuation.whitespace.comment.leading.php'
Expand Down
17 changes: 17 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,23 @@ 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 attribute for method', ->
lines = grammar.tokenizeLines '''
class Foo {
#[ExampleAttribute]
public function bar() {}
# I'm a happy comment!
public function baz() {}
}
'''

expect(lines[1][1]).toEqual value: '#[', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'meta.attribute.php']
expect(lines[1][2]).toEqual value: 'ExampleAttribute', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'meta.attribute.php', 'support.attribute.php']
expect(lines[1][3]).toEqual value: ']', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'meta.attribute.php']
expect(lines[3][0]).toEqual value: ' ', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'punctuation.whitespace.comment.leading.php']
expect(lines[3][1]).toEqual value: '#', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'comment.line.number-sign.php', 'punctuation.definition.comment.php']
expect(lines[3][2]).toEqual value: ' I\'m a happy comment!', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'comment.line.number-sign.php']

it 'should tokenize attribute with namespace', ->
{tokens} = grammar.tokenizeLine '#[Foo\\Bar\\Attribute]'

Expand Down

0 comments on commit 47e1a1f

Please sign in to comment.