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

Commit 0687966

Browse files
class modifiers
1 parent f6815ff commit 0687966

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

grammars/tree-sitter-php.cson

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ scopes:
136136
'meta.function.parameter.no-default.php'
137137
]
138138

139-
'object_creation_expression > qualified_name > name': 'entity.name.type.class'
139+
'object_creation_expression > qualified_name > name': 'support.class.php'
140140
'object_creation_expression > new_variable > simple_variable': 'meta.class.instance.constructor'
141141

142142
'const_element > name': 'constant'
@@ -184,10 +184,10 @@ scopes:
184184
'"protected"': 'storage.modifier.php'
185185
'"global"': 'storage.modifier'
186186
'"const"': 'storage.modifier'
187-
'"abstract"': 'storage.modifier.abstract'
187+
'"abstract"': 'storage.modifier.abstract.php'
188188
'"extends"': 'storage.modifier.extends.php'
189189
'"implements"': 'storage.modifier.implements'
190-
'"final"': 'storage.modifier.final'
190+
'"final"': 'storage.modifier.final.php'
191191
'"use"': 'keyword.other.use.php'
192192
'"namespace"': 'keyword.other.namespace.php'
193193

spec/tree-sitter-spec.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,5 +1754,43 @@ ${caret}
17541754
["source.php", "punctuation.terminator.expression.php"]
17551755
);
17561756
});
1757+
1758+
it("tokenizes class modifiers", () => {
1759+
editor.setContent("abstract class Test {}");
1760+
1761+
expect(editor).toHaveScopesAtPosition(
1762+
[1, 0],
1763+
["source.php", "meta.class.php", "storage.modifier.abstract.php"]
1764+
);
1765+
expect(editor).toHaveScopesAtPosition(
1766+
[1, 8],
1767+
["source.php", "meta.class.php"]
1768+
);
1769+
expect(editor).toHaveScopesAtPosition(
1770+
[1, 9],
1771+
["source.php", "meta.class.php", "storage.type.class.php"]
1772+
);
1773+
1774+
editor.setContent("final class Test {}");
1775+
1776+
expect(editor).toHaveScopesAtPosition(
1777+
[1, 0],
1778+
["source.php", "meta.class.php", "storage.modifier.final.php"]
1779+
);
1780+
expect(editor).toHaveScopesAtPosition(
1781+
[1, 6],
1782+
["source.php", "meta.class.php", "storage.type.class.php"]
1783+
);
1784+
});
1785+
1786+
// SKIP TS-php handles this
1787+
// it('tokenizes classes declared immediately after another class ends', () => {})
1788+
1789+
describe('properties', () => {
1790+
it('tokenizes types', () => {
1791+
// up next...
1792+
});
1793+
});
1794+
17571795
});
17581796
});

0 commit comments

Comments
 (0)