summaryrefslogtreecommitdiff
path: root/runtime/queries/php
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-09 08:42:49 +0000
committerBlaž Hrastnik2021-04-09 09:57:46 +0000
commit4e31d1521bf9bb59f6485954d4ada16bf853c85a (patch)
treed8d05c9303701590dee6351eea693887dbab3981 /runtime/queries/php
parentc1e5733b02e4ba39b82d7b330fab0b2ded2220f2 (diff)
Add tree-sitter queries.
Diffstat (limited to 'runtime/queries/php')
-rw-r--r--runtime/queries/php/highlights.scm114
-rw-r--r--runtime/queries/php/injections.scm3
-rw-r--r--runtime/queries/php/tags.scm26
3 files changed, 143 insertions, 0 deletions
diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm
new file mode 100644
index 00000000..83850403
--- /dev/null
+++ b/runtime/queries/php/highlights.scm
@@ -0,0 +1,114 @@
+(php_tag) @tag
+"?>" @tag
+
+; Types
+
+(primitive_type) @type.builtin
+(cast_type) @type.builtin
+(type_name (name) @type)
+
+; Functions
+
+(array_creation_expression "array" @function.builtin)
+(list_literal "list" @function.builtin)
+
+(method_declaration
+ name: (name) @function.method)
+
+(function_call_expression
+ function: (qualified_name (name)) @function)
+
+(scoped_call_expression
+ name: (name) @function)
+
+(member_call_expression
+ name: (name) @function.method)
+
+(function_definition
+ name: (name) @function)
+
+; Member
+
+(property_element
+ (variable_name) @property)
+
+(member_access_expression
+ name: (variable_name (name)) @property)
+(member_access_expression
+ name: (name) @property)
+
+; Variables
+
+(relative_scope) @variable.builtin
+
+((name) @constant
+ (#match? @constant "^_?[A-Z][A-Z\d_]+$"))
+
+((name) @constructor
+ (#match? @constructor "^[A-Z]"))
+
+((name) @variable.builtin
+ (#eq? @variable.builtin "this"))
+
+(variable_name) @variable
+
+; Basic tokens
+
+(string) @string
+(heredoc) @string
+(boolean) @constant.builtin
+(null) @constant.builtin
+(integer) @number
+(float) @number
+(comment) @comment
+
+"$" @operator
+
+; 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
+"extends" @keyword
+"final" @keyword
+"finally" @keyword
+"foreach" @keyword
+"function" @keyword
+"global" @keyword
+"if" @keyword
+"implements" @keyword
+"include_once" @keyword
+"include" @keyword
+"insteadof" @keyword
+"interface" @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
diff --git a/runtime/queries/php/injections.scm b/runtime/queries/php/injections.scm
new file mode 100644
index 00000000..16d5736b
--- /dev/null
+++ b/runtime/queries/php/injections.scm
@@ -0,0 +1,3 @@
+((text) @injection.content
+ (#set! injection.language "html")
+ (#set! injection.combined))
diff --git a/runtime/queries/php/tags.scm b/runtime/queries/php/tags.scm
new file mode 100644
index 00000000..ef889cee
--- /dev/null
+++ b/runtime/queries/php/tags.scm
@@ -0,0 +1,26 @@
+(class_declaration
+ name: (name) @name) @definition.class
+
+(function_definition
+ name: (name) @name) @definition.function
+
+(method_declaration
+ name: (name) @name) @definition.function
+
+(object_creation_expression
+ [
+ (qualified_name (name) @name)
+ (variable_name (name) @name)
+ ]) @reference.class
+
+(function_call_expression
+ function: [
+ (qualified_name (name) @name)
+ (variable_name (name)) @name
+ ]) @reference.call
+
+(scoped_call_expression
+ name: (name) @name) @reference.call
+
+(member_call_expression
+ name: (name) @name) @reference.call