Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix php hightlight #3317

Merged
merged 5 commits into from
Aug 5, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 61 additions & 50 deletions runtime/queries/php/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
(named_type (name) @type) @type
(named_type (qualified_name) @type) @type

(namespace_definition
name: (namespace_name(name)) @namespace
)
erasin marked this conversation as resolved.
Show resolved Hide resolved

(subscript_expression
(variable_name(name) @constant.builtin)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for code like

$array = ['One', 'Two', 'Three'];
echo $array[0]; // => "One"

This now highlights arrays in L2 as constant.builtin but I think the variable capture from before was more accurate

Copy link
Contributor Author

@erasin erasin Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(subscript_expression
  (variable_name(name) @constant.builtin
    (#match? @constant.builtin "^_?[A-Z][A-Z\\d_]+$")))

it‘s seem ok


; Functions

(array_creation_expression "array" @function.builtin)
Expand All @@ -17,7 +25,7 @@
name: (name) @function.method)

(function_call_expression
function: (qualified_name (name)) @function)
function: (_) @function)

(scoped_call_expression
name: (name) @function)
Expand All @@ -28,6 +36,7 @@
(function_definition
name: (name) @function)


; Member

(property_element
Expand Down Expand Up @@ -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