diff --git a/packages/language-php/grammars/tree-sitter/queries/highlights.scm b/packages/language-php/grammars/tree-sitter/queries/highlights.scm index 96ab45f14a..c3f42e6bc1 100644 --- a/packages/language-php/grammars/tree-sitter/queries/highlights.scm +++ b/packages/language-php/grammars/tree-sitter/queries/highlights.scm @@ -245,22 +245,54 @@ (class_declaration (base_clause (name) @entity.other.inherited-class.php)) (class_declaration (class_interface_clause (name) @entity.other.implemented-interface.php)) +; usage or consumption of traits +(use_declaration (name) @entity.name.type.trait.php) +; in use lists, "bar" in `Foo::bar` is a method, not a constant +(use_list + (_ + (class_constant_access_expression (name) @support.other.function.method.php .) + (name) @support.other.function.method.php + ) + (#set! capture.final true) +) + +; the "Foo" and "bar" in `Foo::bar` +(class_constant_access_expression . (name) @support.class.php) +(class_constant_access_expression (name) @variable.other.property.php .) + +; the "Foo" and "$bar" in Foo::$bar +(scoped_property_access_expression + scope: (name) @support.class.php + name: (variable_name) @variable.other.property.static.php + (#set! capture.final true)) + ; Static method calls. (scoped_call_expression + scope: (name) @support.class.php name: (name) @support.other.function.method.static.php) (member_call_expression name: (name) @support.other.function.method.php) -(scoped_call_expression - scope: (name) @support.class.php) - ; TRAITS ; ====== (trait_declaration (name) @entity.name.type.trait.php) +; INTERFACES +; ====== + +(interface_declaration (name) @entity.name.type.interface.php) + +; ENUMS +; ===== + +(enum_declaration + name: (name) @entity.name.type.enum.php + (enum_declaration_list + (enum_case + name: (name) @constant.other.enum.php))) ; TYPES ; ===== @@ -272,7 +304,7 @@ "global" @storage.modifier.global.php -["trait" "class"] @storage.type._TYPE_.php +["enum" "interface" "trait" "class"] @storage.type._TYPE_.php "function" @storage.type.function.php "fn" @storage.type.function.arrow.php @@ -300,9 +332,9 @@ "$" @punctuation.definition.variable.php ) @variable.parameter.php)) -; The "$bar" in `$foo->$bar`. +; The "bar" and "$bar" in `$foo->bar` and `$foo->$bar`. (member_access_expression - name: (variable_name) @variable.other.property.php + name: [(name) (variable_name)] @variable.other.property.php (#set! capture.final true)) ((variable_name @@ -349,7 +381,6 @@ [ - "abstract" "as" "break" "case" @@ -375,7 +406,6 @@ "include_once" "include" "insteadof" - "interface" "namespace" "new" "require_once" @@ -389,6 +419,7 @@ ] @keyword.control._TYPE_.php [ + "abstract" "final" "private" "protected" @@ -484,7 +515,15 @@ "-=" "*=" "/=" + "%=" + "**=" + "&=" + "|=" + "^=" + "<<=" + ">>=" ".=" + "??=" ] @keyword.operator.assignment.compound.php "->" @keyword.operator.class.php