From 5e8f000cb5a20f44f7a7a89d07ad0774031c53f3 Mon Sep 17 00:00:00 2001 From: KapitanOczywisty <44417092+KapitanOczywisty@users.noreply.github.com> Date: Mon, 17 Apr 2023 08:20:49 +0200 Subject: [PATCH] Add new attributes (#4) - add SensitiveParameter and AllowDynamicProperties (PHP 8.2) - add ReturnTypeWillChange (PHP 8.1) --- grammars/php.cson | 2 +- spec/php-spec.coffee | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/grammars/php.cson b/grammars/php.cson index 9360bee..63e7c1b 100644 --- a/grammars/php.cson +++ b/grammars/php.cson @@ -1055,7 +1055,7 @@ { # There will be other attributes in the future 'match': '''(?xi) - (\\\\)?\\b(Attribute)\\b + (\\\\)?\\b(Attribute|SensitiveParameter|AllowDynamicProperties|ReturnTypeWillChange)\\b ''' 'name': 'support.attribute.builtin.php' 'captures': diff --git a/spec/php-spec.coffee b/spec/php-spec.coffee index 9905cb6..ae7a0a5 100644 --- a/spec/php-spec.coffee +++ b/spec/php-spec.coffee @@ -2679,6 +2679,21 @@ describe 'PHP grammar', -> expect(lines[1][0]).toEqual value: 'class', scopes: ['source.php', 'meta.class.php', 'storage.type.class.php'] expect(lines[1][2]).toEqual value: 'FooAttribute', scopes: ['source.php', 'meta.class.php', 'entity.name.type.class.php'] + lines = grammar.tokenizeLines ''' + #[Attribute] + #[Attributes] + #[SensitiveParameter] + #[\\AllowDynamicProperties] + #[ReturnTypeWillChange] + ''' + + expect(lines[0][1]).toEqual value: 'Attribute', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php'] + expect(lines[1][1]).toEqual value: 'Attributes', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.php'] + expect(lines[2][1]).toEqual value: 'SensitiveParameter', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php'] + expect(lines[3][1]).toEqual value: '\\', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php', 'punctuation.separator.inheritance.php'] + expect(lines[3][2]).toEqual value: 'AllowDynamicProperties', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php'] + expect(lines[4][1]).toEqual value: 'ReturnTypeWillChange', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php'] + describe 'types', -> it 'should tokenize null correctly', -> {tokens} = grammar.tokenizeLine 'function():null{}'