aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/apex
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/apex
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/apex')
-rw-r--r--runtime/queries/apex/folds.scm6
-rw-r--r--runtime/queries/apex/highlights.scm257
-rw-r--r--runtime/queries/apex/injections.scm5
-rw-r--r--runtime/queries/apex/locals.scm67
4 files changed, 335 insertions, 0 deletions
diff --git a/runtime/queries/apex/folds.scm b/runtime/queries/apex/folds.scm
new file mode 100644
index 000000000..fdfc2a1ed
--- /dev/null
+++ b/runtime/queries/apex/folds.scm
@@ -0,0 +1,6 @@
+[
+ (class_body)
+ (constructor_declaration)
+ (argument_list)
+ (annotation_argument_list)
+] @fold
diff --git a/runtime/queries/apex/highlights.scm b/runtime/queries/apex/highlights.scm
new file mode 100644
index 000000000..82ce23414
--- /dev/null
+++ b/runtime/queries/apex/highlights.scm
@@ -0,0 +1,257 @@
+; inherits: soql
+
+; Apex + SOQL
+[
+ "["
+ "]"
+ "{"
+ "}"
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ ","
+ "."
+ ":"
+ "?"
+ ";"
+] @punctuation.delimiter
+
+; Default general color definition
+(identifier) @variable
+
+(type_identifier) @type
+
+; Methods
+(method_declaration
+ name: (identifier) @function.method)
+
+(method_invocation
+ name: (identifier) @function.method.call)
+
+(super) @function.builtin
+
+; Annotations
+(annotation
+ name: (identifier) @attribute)
+
+; Types
+(interface_declaration
+ name: (identifier) @type)
+
+(class_declaration
+ name: (identifier) @type)
+
+(class_declaration
+ (superclass) @type)
+
+(enum_declaration
+ name: (identifier) @type)
+
+(enum_constant
+ name: (identifier) @constant)
+
+(type_arguments
+ "<" @punctuation.delimiter)
+
+(type_arguments
+ ">" @punctuation.delimiter)
+
+(field_access
+ object: (identifier) @type)
+
+(field_access
+ field: (identifier) @property)
+
+((scoped_identifier
+ scope: (identifier) @type)
+ (#match? @type "^[A-Z]"))
+
+((method_invocation
+ object: (identifier) @type)
+ (#match? @type "^[A-Z]"))
+
+(method_declaration
+ (formal_parameters
+ (formal_parameter
+ name: (identifier) @variable.parameter)))
+
+(constructor_declaration
+ name: (identifier) @constructor)
+
+(dml_type) @function.builtin
+
+(assignment_operator) @operator
+
+(update_operator) @operator
+
+(trigger_declaration
+ name: (identifier) @type
+ object: (identifier) @type
+ (trigger_event) @keyword
+ (","
+ (trigger_event) @keyword)*)
+
+[
+ "@"
+ "="
+ "!="
+ "<="
+ ">="
+] @operator
+
+(binary_expression
+ operator: [
+ ">"
+ "<"
+ "=="
+ "==="
+ "!=="
+ "&&"
+ "||"
+ "+"
+ "-"
+ "*"
+ "/"
+ "&"
+ "|"
+ "^"
+ "%"
+ "<<"
+ ">>"
+ ">>>"
+ ] @operator)
+
+(unary_expression
+ operator: [
+ "+"
+ "-"
+ "!"
+ "~"
+ ]) @operator
+
+"=>" @operator
+
+[
+ (boolean_type)
+ (void_type)
+] @type.builtin
+
+; Fields
+(field_declaration
+ declarator: (variable_declarator
+ name: (identifier) @variable.member))
+
+(field_access
+ field: (identifier) @variable.member)
+
+; Variables
+(variable_declarator
+ (identifier) @property)
+
+(field_declaration
+ (modifiers
+ (modifier
+ [
+ (final)
+ (static)
+ ])
+ (modifier
+ [
+ (final)
+ (static)
+ ]))
+ (variable_declarator
+ name: (identifier) @constant))
+
+((identifier) @constant
+ (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) ; SCREAM SNAKE CASE
+
+(this) @variable.builtin
+
+; Literals
+[
+ (int)
+ (decimal)
+ (currency_literal)
+] @number
+
+(string_literal) @string
+
+[
+ (line_comment)
+ (block_comment)
+] @comment
+
+(null_literal) @constant.builtin
+
+; ;; Keywords
+[
+ "abstract"
+ "final"
+ "private"
+ "protected"
+ "public"
+ "static"
+] @keyword.modifier
+
+[
+ "if"
+ "else"
+ "switch"
+] @keyword.conditional
+
+[
+ "for"
+ "while"
+ "do"
+ "break"
+] @keyword.repeat
+
+"return" @keyword.return
+
+[
+ "throw"
+ "finally"
+ "try"
+ "catch"
+] @keyword.exception
+
+"new" @keyword.operator
+
+[
+ (abstract)
+ (all_rows_clause)
+ "continue"
+ "extends"
+ (final)
+ "get"
+ (global)
+ "implements"
+ "instanceof"
+ "on"
+ (override)
+ (private)
+ (protected)
+ (public)
+ "set"
+ (static)
+ (testMethod)
+ (webservice)
+ (transient)
+ "trigger"
+ (virtual)
+ "when"
+ (with_sharing)
+ (without_sharing)
+ (inherited_sharing)
+] @keyword
+
+[
+ "interface"
+ "class"
+ "enum"
+] @keyword.type
+
+"System.runAs" @function.builtin
diff --git a/runtime/queries/apex/injections.scm b/runtime/queries/apex/injections.scm
new file mode 100644
index 000000000..3cd6aac8e
--- /dev/null
+++ b/runtime/queries/apex/injections.scm
@@ -0,0 +1,5 @@
+([
+ (line_comment)
+ (block_comment)
+] @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/apex/locals.scm b/runtime/queries/apex/locals.scm
new file mode 100644
index 000000000..d758f14cf
--- /dev/null
+++ b/runtime/queries/apex/locals.scm
@@ -0,0 +1,67 @@
+; declarations
+(class_declaration) @local.scope
+
+(method_declaration) @local.scope
+
+(constructor_declaration) @local.scope
+
+(enum_declaration) @local.scope
+
+(enhanced_for_statement) @local.scope
+
+; if/else
+(if_statement) @local.scope
+
+(if_statement
+ consequence: (_) @local.scope) ; if body in case there are no braces
+
+(if_statement
+ alternative: (_) @local.scope) ; else body in case there are no braces
+
+; try/catch
+(try_statement) @local.scope ; covers try+catch, individual try and catch are covered by (block)
+
+(catch_clause) @local.scope ; needed because `Exception` variable
+
+; loops
+(for_statement) @local.scope
+
+(for_statement ; "for" body in case there are no braces
+ body: (_) @local.scope)
+
+(do_statement
+ body: (_) @local.scope)
+
+(while_statement
+ body: (_) @local.scope)
+
+; Functions
+(constructor_declaration) @local.scope
+
+(method_declaration) @local.scope
+
+; definitions
+(enum_declaration
+ name: (identifier) @local.definition.enum)
+
+(method_declaration
+ name: (identifier) @local.definition.method)
+
+(local_variable_declaration
+ declarator: (variable_declarator
+ name: (identifier) @local.definition.var))
+
+(enhanced_for_statement
+ name: (identifier) @local.definition.var)
+
+(formal_parameter
+ name: (identifier) @local.definition.parameter)
+
+(field_declaration
+ declarator: (variable_declarator
+ name: (identifier) @local.definition.field))
+
+; REFERENCES
+(identifier) @local.reference
+
+(type_identifier) @local.reference