diff options
| author | Xi Xiao <xi.xiao007@gmail.com> | 2023-09-17 20:00:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-17 20:00:21 +0300 |
| commit | 280cf6fddd09fbcdce659b24d0df9c3055977cd3 (patch) | |
| tree | 966aaab4295fe6c6f1db6ee179b6bc789de142f0 /queries/apex | |
| parent | fix(dockerfile): bash injection on run instructions (diff) | |
| download | nvim-treesitter-280cf6fddd09fbcdce659b24d0df9c3055977cd3.tar nvim-treesitter-280cf6fddd09fbcdce659b24d0df9c3055977cd3.tar.gz nvim-treesitter-280cf6fddd09fbcdce659b24d0df9c3055977cd3.tar.bz2 nvim-treesitter-280cf6fddd09fbcdce659b24d0df9c3055977cd3.tar.lz nvim-treesitter-280cf6fddd09fbcdce659b24d0df9c3055977cd3.tar.xz nvim-treesitter-280cf6fddd09fbcdce659b24d0df9c3055977cd3.tar.zst nvim-treesitter-280cf6fddd09fbcdce659b24d0df9c3055977cd3.zip | |
feat: add parsers and queries for apex, sosl, soql (#5396)
Diffstat (limited to 'queries/apex')
| -rw-r--r-- | queries/apex/folds.scm | 6 | ||||
| -rw-r--r-- | queries/apex/highlights.scm | 248 | ||||
| -rw-r--r-- | queries/apex/locals.scm | 66 |
3 files changed, 320 insertions, 0 deletions
diff --git a/queries/apex/folds.scm b/queries/apex/folds.scm new file mode 100644 index 000000000..0ffc550e9 --- /dev/null +++ b/queries/apex/folds.scm @@ -0,0 +1,6 @@ +[ + (class_body) + (constructor_declaration) + (argument_list) + (annotation_argument_list) +] @fold diff --git a/queries/apex/highlights.scm b/queries/apex/highlights.scm new file mode 100644 index 000000000..f5ce0b9fb --- /dev/null +++ b/queries/apex/highlights.scm @@ -0,0 +1,248 @@ +; inherits: soql + +;;; Apex + SOQL + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +[ + "," + "." + ":" + "?" + ";" + ] @punctuation.delimiter + +;; Default general color defination + +(identifier) @variable + +(type_identifier) @type + +;; Methods + +(method_declaration + name: (identifier) @method) + +(method_invocation + name: (identifier) @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) @parameter))) + +(constructor_declaration + name: (identifier) @constructor) + +(dml_type) @function.builtin + +(assignment_operator) @operator + +(update_expression ["++" "--"] @operator) + +(trigger_declaration + name: (identifier) @type + object: (identifier) @type + (trigger_event) @keyword + ("," (trigger_event) @keyword)*) + +[ + "@" + "=" + "!=" + "<=" + ">=" +] @operator + +(binary_expression + operator: [ + ">" + "<" + "==" + "===" + "!==" + "&&" + "||" + "+" + "-" + "*" + "/" + "&" + "|" + "^" + "%" + "<<" + ">>" + ">>>"] @operator) + +(unary_expression + operator: [ + "+" + "-" + "!" + "~" + ]) @operator + +(map_initializer "=>" @operator) + +[ + (boolean_type) + (void_type) +] @type.builtin;; + +; Fields + +(field_declaration + declarator: (variable_declarator + name: (identifier) @field)) + +(field_access + field: (identifier) @field) + +; Variables + +(field_declaration + (modifiers (modifier ["final" "static"])(modifier ["final" "static"])) + (variable_declarator + name: (identifier) @constant)) + +(variable_declarator + (identifier) @property) + +((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" + ] @type.qualifier + +[ + "if" + "else" + "switch" +] @conditional + +[ + "for" + "while" + "do" + "break" +] @repeat + +[ + "return" +] @keyword.return + +[ + "throw" + "finally" + "try" + "catch" + ] @exception + +"new" @keyword.operator + +[ + "abstract" + "class" + "continue" + "default" + "enum" + "extends" + "final" + "get" + "global" + "implements" + "instanceof" + "interface" + "on" + "private" + "protected" + "public" + "set" + "static" + "testMethod" + "transient" + "trigger" + "virtual" + "when" + "with_sharing" + "without_sharing" + "inherited_sharing" +] @keyword + +"System.runAs" @type.builtin diff --git a/queries/apex/locals.scm b/queries/apex/locals.scm new file mode 100644 index 000000000..c7213601b --- /dev/null +++ b/queries/apex/locals.scm @@ -0,0 +1,66 @@ +; declarations + +(class_declaration) @scope +(method_declaration) @scope +(constructor_declaration) @scope +(enum_declaration) @scope +(enhanced_for_statement) @scope + +; if/else + +(if_statement) @scope +(if_statement + consequence: (_) @scope) ; if body in case there are no braces +(if_statement + alternative: (_) @scope) ; else body in case there are no braces + +; try/catch + +(try_statement) @scope ; covers try+catch, individual try and catch are covered by (block) +(catch_clause) @scope ; needed because `Exception` variable + +; loops + +(for_statement) @scope +(for_statement ; "for" body in case there are no braces + body: (_) @scope) +(do_statement + body: (_) @scope) +(while_statement + body: (_) @scope) + +; Functions + +(constructor_declaration) @scope +(method_declaration) @scope + +;; definitions + +(enum_declaration + name: (identifier) @definition.enum) + +(method_declaration + name: (identifier) @definition.method) + +(local_variable_declaration + declarator: (variable_declarator + name: (identifier) @definition.var)) + +(enhanced_for_statement + name: (identifier) @definition.var) + +(formal_parameter + name: (identifier) @definition.parameter) + +(catch_formal_parameter + name: (identifier) @definition.parameter) + +(field_declaration + declarator: (variable_declarator + name: (identifier) @definition.field)) + +;; REFERENCES + +(identifier) @reference + +(type_identifier) @reference |
