mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-10 07:20:06 -04:00
feat: add parsers and queries for apex, sosl, soql (#5396)
This commit is contained in:
parent
dac6efbaff
commit
280cf6fddd
7 changed files with 534 additions and 0 deletions
|
|
@ -5,6 +5,9 @@
|
||||||
"agda": {
|
"agda": {
|
||||||
"revision": "80ea622cf952a0059e168e5c92a798b2f1925652"
|
"revision": "80ea622cf952a0059e168e5c92a798b2f1925652"
|
||||||
},
|
},
|
||||||
|
"apex": {
|
||||||
|
"revision": "e63bcdcc26ae808b3fe79dfb8fa61bebdb95bda4"
|
||||||
|
},
|
||||||
"arduino": {
|
"arduino": {
|
||||||
"revision": "db929fc6822b9b9e1211678d508f187894ce0345"
|
"revision": "db929fc6822b9b9e1211678d508f187894ce0345"
|
||||||
},
|
},
|
||||||
|
|
@ -524,6 +527,12 @@
|
||||||
"solidity": {
|
"solidity": {
|
||||||
"revision": "168020304759ad5d8b4a88a541a699134e3730c5"
|
"revision": "168020304759ad5d8b4a88a541a699134e3730c5"
|
||||||
},
|
},
|
||||||
|
"soql": {
|
||||||
|
"revision": "e63bcdcc26ae808b3fe79dfb8fa61bebdb95bda4"
|
||||||
|
},
|
||||||
|
"sosl": {
|
||||||
|
"revision": "e63bcdcc26ae808b3fe79dfb8fa61bebdb95bda4"
|
||||||
|
},
|
||||||
"sparql": {
|
"sparql": {
|
||||||
"revision": "05f949d3c1c15e3261473a244d3ce87777374dec"
|
"revision": "05f949d3c1c15e3261473a244d3ce87777374dec"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,15 @@ list.agda = {
|
||||||
maintainers = { "@Decodetalkers" },
|
maintainers = { "@Decodetalkers" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.apex = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/aheber/tree-sitter-sfapex",
|
||||||
|
files = { "src/parser.c" },
|
||||||
|
location = "apex",
|
||||||
|
},
|
||||||
|
maintainers = { "@aheber" },
|
||||||
|
}
|
||||||
|
|
||||||
list.arduino = {
|
list.arduino = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/ObserverOfTime/tree-sitter-arduino",
|
url = "https://github.com/ObserverOfTime/tree-sitter-arduino",
|
||||||
|
|
@ -1545,6 +1554,24 @@ list.solidity = {
|
||||||
maintainers = { "@amaanq" },
|
maintainers = { "@amaanq" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.soql = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/aheber/tree-sitter-sfapex",
|
||||||
|
files = { "src/parser.c" },
|
||||||
|
location = "soql",
|
||||||
|
},
|
||||||
|
maintainers = { "@aheber" },
|
||||||
|
}
|
||||||
|
|
||||||
|
list.sosl = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/aheber/tree-sitter-sfapex",
|
||||||
|
files = { "src/parser.c" },
|
||||||
|
location = "sosl",
|
||||||
|
},
|
||||||
|
maintainers = { "@aheber" },
|
||||||
|
}
|
||||||
|
|
||||||
list.sparql = {
|
list.sparql = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/BonaBeavis/tree-sitter-sparql",
|
url = "https://github.com/BonaBeavis/tree-sitter-sparql",
|
||||||
|
|
|
||||||
6
queries/apex/folds.scm
Normal file
6
queries/apex/folds.scm
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[
|
||||||
|
(class_body)
|
||||||
|
(constructor_declaration)
|
||||||
|
(argument_list)
|
||||||
|
(annotation_argument_list)
|
||||||
|
] @fold
|
||||||
248
queries/apex/highlights.scm
Normal file
248
queries/apex/highlights.scm
Normal file
|
|
@ -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
|
||||||
66
queries/apex/locals.scm
Normal file
66
queries/apex/locals.scm
Normal file
|
|
@ -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
|
||||||
150
queries/soql/highlights.scm
Normal file
150
queries/soql/highlights.scm
Normal file
|
|
@ -0,0 +1,150 @@
|
||||||
|
(field_identifier
|
||||||
|
(identifier) @property)
|
||||||
|
|
||||||
|
(field_identifier
|
||||||
|
(dotted_identifier
|
||||||
|
(identifier) @property))
|
||||||
|
|
||||||
|
(type_of_clause
|
||||||
|
(identifier) @property)
|
||||||
|
|
||||||
|
(when_expression
|
||||||
|
(identifier) @type)
|
||||||
|
|
||||||
|
(when_expression
|
||||||
|
(field_list
|
||||||
|
(identifier) @property))
|
||||||
|
|
||||||
|
(when_expression
|
||||||
|
(field_list
|
||||||
|
(dotted_identifier
|
||||||
|
(identifier) @property )))
|
||||||
|
|
||||||
|
(else_expression
|
||||||
|
(field_list
|
||||||
|
(identifier) @property ))
|
||||||
|
|
||||||
|
(else_expression
|
||||||
|
(field_list
|
||||||
|
(dotted_identifier
|
||||||
|
(identifier) @property )))
|
||||||
|
|
||||||
|
(alias_expression
|
||||||
|
(identifier) @label)
|
||||||
|
|
||||||
|
(storage_identifier) @storageclass
|
||||||
|
(function_name) @function
|
||||||
|
(date_literal) @string.special
|
||||||
|
|
||||||
|
[
|
||||||
|
","
|
||||||
|
"."
|
||||||
|
":"
|
||||||
|
"?"
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
[
|
||||||
|
"AND"
|
||||||
|
"OR"
|
||||||
|
"NOT"
|
||||||
|
"LIKE"
|
||||||
|
"NOT_IN"
|
||||||
|
"INCLUDES"
|
||||||
|
"EXCLUDES"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"="
|
||||||
|
"!="
|
||||||
|
"<="
|
||||||
|
">="
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
(value_comparison_operator [ "<" ">" ] @operator)
|
||||||
|
|
||||||
|
(set_comparison_operator "IN" @keyword.operator)
|
||||||
|
|
||||||
|
[
|
||||||
|
(int)
|
||||||
|
(decimal)
|
||||||
|
(currency_literal)
|
||||||
|
] @number
|
||||||
|
(string_literal) @string
|
||||||
|
(date) @variable.readonly
|
||||||
|
(date_time) @variable.readonly
|
||||||
|
|
||||||
|
[
|
||||||
|
"TRUE"
|
||||||
|
"FALSE"
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
(null_literal) @constant.builtin
|
||||||
|
|
||||||
|
[
|
||||||
|
"ABOVE"
|
||||||
|
"ABOVE_OR_BELOW"
|
||||||
|
"ALL_ROWS"
|
||||||
|
"ALL"
|
||||||
|
"AS"
|
||||||
|
"ASC"
|
||||||
|
"AT"
|
||||||
|
"BELOW"
|
||||||
|
"CUSTOM"
|
||||||
|
"DATA_CATEGORY"
|
||||||
|
"DESC"
|
||||||
|
"END"
|
||||||
|
"FIELDS"
|
||||||
|
"FOR"
|
||||||
|
"FROM"
|
||||||
|
"GROUP_BY"
|
||||||
|
"HAVING"
|
||||||
|
"LIMIT"
|
||||||
|
"NULLS_FIRST"
|
||||||
|
"NULLS_LAST"
|
||||||
|
"OFFSET"
|
||||||
|
"ORDER_BY"
|
||||||
|
"REFERENCE"
|
||||||
|
"SELECT"
|
||||||
|
"STANDARD"
|
||||||
|
"TRACKING"
|
||||||
|
"TYPEOF"
|
||||||
|
"UPDATE"
|
||||||
|
"USING_SCOPE"
|
||||||
|
"VIEW"
|
||||||
|
"VIEWSTAT"
|
||||||
|
"WITH"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"WHERE"
|
||||||
|
"WHEN"
|
||||||
|
"ELSE"
|
||||||
|
"THEN"
|
||||||
|
] @conditional
|
||||||
|
|
||||||
|
; Using Scope
|
||||||
|
[
|
||||||
|
"delegated"
|
||||||
|
"everything"
|
||||||
|
"mine"
|
||||||
|
"mine_and_my_groups"
|
||||||
|
"my_territory"
|
||||||
|
"my_team_territory"
|
||||||
|
"team"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
; With
|
||||||
|
[
|
||||||
|
"maxDescriptorPerRecord"
|
||||||
|
"RecordVisibilityContext"
|
||||||
|
"Security_Enforced"
|
||||||
|
"supportsDomains"
|
||||||
|
"supportsDelegates"
|
||||||
|
"System_Mode"
|
||||||
|
"User_Mode"
|
||||||
|
"UserId"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
|
||||||
28
queries/sosl/highlights.scm
Normal file
28
queries/sosl/highlights.scm
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
(find_clause
|
||||||
|
(term) @string )
|
||||||
|
|
||||||
|
(sobject_return
|
||||||
|
(identifier) @type )
|
||||||
|
|
||||||
|
(with_type (_ "=" @operator))
|
||||||
|
|
||||||
|
[
|
||||||
|
"ALL"
|
||||||
|
"DIVISION"
|
||||||
|
"EMAIL"
|
||||||
|
"FIND"
|
||||||
|
"ListView"
|
||||||
|
"HIGHLIGHT"
|
||||||
|
"IN"
|
||||||
|
"METADATA"
|
||||||
|
"NAME"
|
||||||
|
"NETWORK"
|
||||||
|
"PHONE"
|
||||||
|
"PricebookId"
|
||||||
|
"RETURNING"
|
||||||
|
"SIDEBAR"
|
||||||
|
"SNIPPET"
|
||||||
|
"SPELL_CORRECTION"
|
||||||
|
"target_length"
|
||||||
|
"USING"
|
||||||
|
] @keyword
|
||||||
Loading…
Add table
Add a link
Reference in a new issue