From 5044a79cf16749d90bffbca1db1516b2237d7266 Mon Sep 17 00:00:00 2001 From: Erasin Date: Wed, 3 Aug 2022 19:33:42 +0800 Subject: [PATCH 1/5] Fix php hightlight namespace fucntion --- runtime/queries/php/highlights.scm | 111 ++++++++++++++++------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index 5379fa1e341b..4eab6384e34b 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -8,6 +8,14 @@ (named_type (name) @type) @type (named_type (qualified_name) @type) @type +(namespace_definition + name: (namespace_name(name)) @constructor +) + +(subscript_expression + (variable_name(name) @constant) +) + ; Functions (array_creation_expression "array" @function.builtin) @@ -17,7 +25,7 @@ name: (name) @function.method) (function_call_expression - function: (qualified_name (name)) @function) + function: (_) @function) (scoped_call_expression name: (name) @function) @@ -28,6 +36,7 @@ (function_definition name: (name) @function) + ; Member (property_element @@ -67,52 +76,54 @@ ; Keywords -"abstract" @keyword -"as" @keyword -"break" @keyword -"case" @keyword -"catch" @keyword -"class" @keyword -"const" @keyword -"continue" @keyword -"declare" @keyword -"default" @keyword -"do" @keyword -"echo" @keyword -"else" @keyword -"elseif" @keyword -"enddeclare" @keyword -"endforeach" @keyword -"endif" @keyword -"endswitch" @keyword -"endwhile" @keyword -"enum" @keyword -"extends" @keyword -"final" @keyword -"finally" @keyword -"foreach" @keyword -"fn" @keyword -"function" @keyword -"global" @keyword -"if" @keyword -"implements" @keyword -"include_once" @keyword -"include" @keyword -"insteadof" @keyword -"interface" @keyword -"match" @keyword -"namespace" @keyword -"new" @keyword -"private" @keyword -"protected" @keyword -"public" @keyword -"require_once" @keyword -"require" @keyword -"return" @keyword -"static" @keyword -"switch" @keyword -"throw" @keyword -"trait" @keyword -"try" @keyword -"use" @keyword -"while" @keyword +[ + "abstract" + "as" + "break" + "case" + "catch" + "class" + "const" + "continue" + "declare" + "default" + "do" + "echo" + "else" + "elseif" + "enddeclare" + "endforeach" + "endif" + "endswitch" + "endwhile" + "enum" + "extends" + "final" + "finally" + "foreach" + "fn" + "function" + "global" + "if" + "implements" + "include_once" + "include" + "insteadof" + "interface" + "match" + "namespace" + "new" + "private" + "protected" + "public" + "require_once" + "require" + "return" + "static" + "switch" + "throw" + "trait" + "try" + "use" + "while" +] @keyword \ No newline at end of file From ca226f712815c3212c855871f7303d19dc3680f2 Mon Sep 17 00:00:00 2001 From: Erasin Date: Thu, 4 Aug 2022 11:06:17 +0800 Subject: [PATCH 2/5] update php highlight --- runtime/queries/php/highlights.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index 4eab6384e34b..00431670ec5d 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -9,7 +9,7 @@ (named_type (qualified_name) @type) @type (namespace_definition - name: (namespace_name(name)) @constructor + name: (namespace_name(name)) @namespace ) (subscript_expression @@ -126,4 +126,4 @@ "try" "use" "while" -] @keyword \ No newline at end of file +] @keyword From c53e3413038d4077b539f84c71d6ff0abf899df6 Mon Sep 17 00:00:00 2001 From: Erasin Date: Thu, 4 Aug 2022 19:39:22 +0800 Subject: [PATCH 3/5] Fix PHP, mark superglobals with constant.builtin --- runtime/queries/php/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index 00431670ec5d..3c53a5a6a44f 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -13,7 +13,7 @@ ) (subscript_expression - (variable_name(name) @constant) + (variable_name(name) @constant.builtin) ) ; Functions From 200d4e190569331fabd517814208f44950bb609a Mon Sep 17 00:00:00 2001 From: Erasin Date: Fri, 5 Aug 2022 12:08:20 +0800 Subject: [PATCH 4/5] Update runtime/queries/php/highlights.scm Co-authored-by: Michael Davis --- runtime/queries/php/highlights.scm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index 3c53a5a6a44f..d32fc34d56fa 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -9,8 +9,7 @@ (named_type (qualified_name) @type) @type (namespace_definition - name: (namespace_name(name)) @namespace -) + name: (namespace_name (name) @namespace)) (subscript_expression (variable_name(name) @constant.builtin) From d18459da265fc7883627e09113f27af2125d8a28 Mon Sep 17 00:00:00 2001 From: Erasin Date: Fri, 5 Aug 2022 12:32:22 +0800 Subject: [PATCH 5/5] FIX php hightlight for superglobals --- runtime/queries/php/highlights.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index d32fc34d56fa..77c9424fef64 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -11,9 +11,10 @@ (namespace_definition name: (namespace_name (name) @namespace)) +; Superglobals (subscript_expression - (variable_name(name) @constant.builtin) -) + (variable_name(name) @constant.builtin + (#match? @constant.builtin "^_?[A-Z][A-Z\\d_]+$"))) ; Functions