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 #288 from atom/wl-scope-resolution-namespaces
Browse files Browse the repository at this point in the history
Tokenize namespaces when using the scope resolution operator
  • Loading branch information
50Wliu committed Oct 16, 2017
2 parents aa09512 + 1d449de commit 3e21c92
Show file tree
Hide file tree
Showing 2 changed files with 14 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 @@ -2419,7 +2419,7 @@
'scope-resolution':
'patterns': [
{
'match': '(?i)\\b([a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*)(?=\\s*::)'
'match': '(?i)([a-z_\\x{7f}-\\x{ff}\\\\][a-z0-9_\\x{7f}-\\x{ff}\\\\]*)(?=\\s*::)'
'captures':
'1':
'patterns': [
Expand Down
13 changes: 13 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,19 @@ describe 'PHP grammar', ->
expect(tokens[1][3]).toEqual value: ' ', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php']
expect(tokens[1][4]).toEqual value: 'constant', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'constant.other.class.php']

it 'tokenizes namespaced classes', ->
tokens = grammar.tokenizeLines "<?php\n\\One\\Two\\Three::$var"

expect(tokens[1][0]).toEqual value: '\\', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'support.other.namespace.php', 'punctuation.separator.inheritance.php']
expect(tokens[1][1]).toEqual value: 'One', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'support.other.namespace.php']
expect(tokens[1][2]).toEqual value: '\\', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'support.other.namespace.php', 'punctuation.separator.inheritance.php']
expect(tokens[1][3]).toEqual value: 'Two', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'support.other.namespace.php']
expect(tokens[1][4]).toEqual value: '\\', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'support.other.namespace.php', 'punctuation.separator.inheritance.php']
expect(tokens[1][5]).toEqual value: 'Three', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'support.class.php']
expect(tokens[1][6]).toEqual value: '::', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'keyword.operator.class.php']
expect(tokens[1][7]).toEqual value: '$', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'variable.other.class.php', 'punctuation.definition.variable.php']
expect(tokens[1][8]).toEqual value: 'var', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'variable.other.class.php']

it 'tokenizes the special "class" keyword', ->
tokens = grammar.tokenizeLines "<?php\nobj::class"

Expand Down

0 comments on commit 3e21c92

Please sign in to comment.