From 34007887059238f63a49ab4d382d839d9405c66c Mon Sep 17 00:00:00 2001 From: Caleb White Date: Mon, 18 Mar 2024 21:19:50 -0500 Subject: [PATCH] feat(php): add highlight tests --- queries/php_only/highlights.scm | 1 + tests/query/highlights/php/keywords.php | 173 +++++++++++++++++++++++ tests/query/highlights/php/literals.php | 26 ++++ tests/query/highlights/php/types.php | 23 +++ tests/query/highlights/php/variables.php | 28 ++++ 5 files changed, 251 insertions(+) create mode 100644 tests/query/highlights/php/keywords.php create mode 100644 tests/query/highlights/php/literals.php create mode 100644 tests/query/highlights/php/types.php create mode 100644 tests/query/highlights/php/variables.php diff --git a/queries/php_only/highlights.scm b/queries/php_only/highlights.scm index 557421d9f..0bba534d0 100644 --- a/queries/php_only/highlights.scm +++ b/queries/php_only/highlights.scm @@ -216,6 +216,7 @@ (named_label_statement) @label + ; Keywords [ "and" diff --git a/tests/query/highlights/php/keywords.php b/tests/query/highlights/php/keywords.php new file mode 100644 index 000000000..e11a9f351 --- /dev/null +++ b/tests/query/highlights/php/keywords.php @@ -0,0 +1,173 @@ + $a + $b; +// ^^ @keyword.function + static $a; +// ^^^^^^ @keyword.modifier + global $a; +// ^^^^^^ @keyword + clone $call; +// ^^^^^ @keyword + match ($a) { +// ^^^^^ @keyword.conditional + default => "other", +// ^^^^^^^ @keyword +// ^^ @operator + }; + + switch ($a) { +// ^^^^^^ @keyword.conditional + case 'value': +// ^^^^ @keyword.conditional + break; +// ^^^^^ @keyword + default: +// ^^^^^^^ @keyword + } + yield $a; +// ^^^^^ @keyword.return + yield from $a; +// ^^^^ @keyword.return + return $a; +// ^^^^^^ @keyword.return + goto a; +// ^^^^ @keyword + echo "a"; +// ^^^^ @keyword + print "a"; +// ^^^^^ @keyword + print("a"); +// ^^^^^ @keyword + exit; +// ^^^^ @keyword + exit(); +// ^^^^ @function.builtin + exit(1); +// ^^^^ @function.builtin + } +} + +throw new Exception("oh"); +//^^^ @keyword.exception +// ^^^ @keyword +// ^^^^^^^^^ @constructor + +interface T {} +//^^^^^^^ @keyword +// ^ @type + +trait T { public function small(): void {} } +//^^^ @keyword +// ^ @type +// ^^^^ @type.builtin +enum Foo { case Bar; } +//^^ @keyword +// ^^^^ @keyword.conditional diff --git a/tests/query/highlights/php/literals.php b/tests/query/highlights/php/literals.php new file mode 100644 index 000000000..17b539362 --- /dev/null +++ b/tests/query/highlights/php/literals.php @@ -0,0 +1,26 @@ +foo(); +// ^^^^ @variable.builtin +// ^^ @operator +// ^^^ @function.method.call + self::foo(); +// ^^^^ @variable.builtin +// ^^^ @function.call + static::foo(); +// ^^^^^^ @variable.builtin + parent::foo(); +// ^^^^^^ @variable.builtin + $this->foo; +// ^^^ @variable.member + $this->foo(a: 5); +// ^ @variable.parameter + } +}