From 7d938c1c72ac21cd059ed9a71d50f1329b33d988 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Mon, 18 Mar 2024 22:42:44 -0500 Subject: [PATCH] fix(php): fix use_{as,instead_of}_clause highlights --- queries/php_only/highlights.scm | 20 +++++++++++++++++--- tests/query/highlights/php/keywords.php | 17 ++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/queries/php_only/highlights.scm b/queries/php_only/highlights.scm index ab95ea603..e8b4a7825 100644 --- a/queries/php_only/highlights.scm +++ b/queries/php_only/highlights.scm @@ -26,7 +26,8 @@ (name) @type) ]) -(named_type (name) @type.builtin +(named_type + (name) @type.builtin (#any-of? @type.builtin "static" "self")) (class_declaration @@ -99,7 +100,9 @@ (list_literal "list" @function.builtin) -(exit_statement "exit" @function.builtin "(") +(exit_statement + "exit" @function.builtin + "(") (method_declaration name: (name) @function.method) @@ -123,6 +126,18 @@ (nullsafe_member_call_expression name: (name) @function.method) +(use_instead_of_clause + (class_constant_access_expression + (_) + (name) @function.method) + (name) @type) + +(use_as_clause + (class_constant_access_expression + (_) + (name) @function.method)* + (name) @function.method) + (method_declaration name: (name) @constructor (#eq? @constructor "__construct")) @@ -280,7 +295,6 @@ (yield_expression "from" @keyword.return) - [ "case" "else" diff --git a/tests/query/highlights/php/keywords.php b/tests/query/highlights/php/keywords.php index e11a9f351..4bacf1c9d 100644 --- a/tests/query/highlights/php/keywords.php +++ b/tests/query/highlights/php/keywords.php @@ -96,9 +96,20 @@ class B extends A implements T U::small insteadof T; // ^ @type // ^^ @operator -// ^^^^^ @constant +// ^^^^^ @function.method // ^^^^^^^^^ @keyword // ^ @type + T::big as protected tBig; +// ^ @type +// ^^^ @function.method +// ^^ @keyword.operator +// ^^^^^^^^^ @keyword.modifier +// ^^^^ @function.method + big as private tBig; +// ^^^ @function.method +// ^^ @keyword.operator +// ^^^^^^^^^ @keyword.modifier +// ^^^^ @function.method } public function foo(callable $call): self // ^^^^^^^^ @type.builtin @@ -106,7 +117,7 @@ class B extends A implements T { $call instanceof Closure; // ^^^^^ @variable -// ^^^^^^^^^^ @keyword +// ^^^^^^^^^^ @keyword.operator // ^^^^^^^ @type fn ($a, $b) => $a + $b; // ^^ @keyword.function @@ -147,7 +158,7 @@ class B extends A implements T print("a"); // ^^^^^ @keyword exit; -// ^^^^ @keyword +// ^^^^ @keyword.return exit(); // ^^^^ @function.builtin exit(1);