2023-02-23 17:04:34 -05:00
|
|
|
;; SCOPES
|
|
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
; declarations
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(program) @scope
|
2020-06-11 22:31:45 +05:30
|
|
|
(class_declaration
|
2020-07-19 17:41:24 +00:00
|
|
|
body: (_) @scope)
|
2021-04-10 02:46:11 +02:00
|
|
|
(record_declaration
|
|
|
|
|
body: (_) @scope)
|
2020-07-19 17:41:24 +00:00
|
|
|
(enum_declaration
|
|
|
|
|
body: (_) @scope)
|
2020-08-12 10:41:31 -05:00
|
|
|
(lambda_expression) @scope
|
|
|
|
|
(enhanced_for_statement) @scope
|
2020-07-19 17:41:24 +00:00
|
|
|
|
|
|
|
|
; block
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(block) @scope
|
|
|
|
|
|
|
|
|
|
; if/else
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(if_statement) @scope ; if+else
|
|
|
|
|
(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
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(try_statement) @scope ; covers try+catch, individual try and catch are covered by (block)
|
|
|
|
|
(catch_clause) @scope ; needed because `Exception` variable
|
2020-06-11 22:31:45 +05:30
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
; loops
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(for_statement) @scope ; whole for_statement because loop iterator variable
|
|
|
|
|
(for_statement ; "for" body in case there are no braces
|
|
|
|
|
body: (_) @scope)
|
|
|
|
|
(do_statement
|
|
|
|
|
body: (_) @scope)
|
|
|
|
|
(while_statement
|
|
|
|
|
body: (_) @scope)
|
|
|
|
|
|
|
|
|
|
; Functions
|
|
|
|
|
|
|
|
|
|
(constructor_declaration) @scope
|
2020-09-07 18:14:54 +02:00
|
|
|
(method_declaration) @scope
|
2020-07-19 17:41:24 +00:00
|
|
|
|
2023-02-23 17:04:34 -05:00
|
|
|
;; DEFINITIONS
|
2020-07-19 17:41:24 +00:00
|
|
|
|
2020-08-12 10:41:31 -05:00
|
|
|
(package_declaration
|
|
|
|
|
(identifier) @definition.namespace)
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(class_declaration
|
2020-09-07 18:14:54 +02:00
|
|
|
name: (identifier) @definition.type)
|
2021-04-10 02:46:11 +02:00
|
|
|
(record_declaration
|
|
|
|
|
name: (identifier) @definition.type)
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(enum_declaration
|
|
|
|
|
name: (identifier) @definition.enum)
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(method_declaration
|
|
|
|
|
name: (identifier) @definition.method)
|
|
|
|
|
|
|
|
|
|
(local_variable_declaration
|
|
|
|
|
declarator: (variable_declarator
|
|
|
|
|
name: (identifier) @definition.var))
|
2023-02-23 17:04:34 -05:00
|
|
|
(enhanced_for_statement ; for (var item : items) {
|
2020-07-19 17:41:24 +00:00
|
|
|
name: (identifier) @definition.var)
|
2023-02-23 17:04:34 -05:00
|
|
|
|
|
|
|
|
(formal_parameter
|
|
|
|
|
name: (identifier) @definition.parameter)
|
2020-07-23 23:33:56 +02:00
|
|
|
(catch_formal_parameter
|
2023-02-23 17:04:34 -05:00
|
|
|
name: (identifier) @definition.parameter)
|
|
|
|
|
(inferred_parameters (identifier) @definition.parameter) ; (x,y) -> ...
|
2020-07-19 17:41:24 +00:00
|
|
|
(lambda_expression
|
2023-02-23 17:04:34 -05:00
|
|
|
parameters: (identifier) @definition.parameter) ; x -> ...
|
2020-07-19 17:41:24 +00:00
|
|
|
|
2020-07-27 10:33:34 +02:00
|
|
|
((scoped_identifier
|
|
|
|
|
(identifier) @definition.import)
|
2021-12-22 13:26:55 -05:00
|
|
|
(#has-ancestor? @definition.import import_declaration))
|
2020-07-19 17:41:24 +00:00
|
|
|
|
|
|
|
|
(field_declaration
|
|
|
|
|
declarator: (variable_declarator
|
|
|
|
|
name: (identifier) @definition.field))
|
2020-06-11 22:31:45 +05:30
|
|
|
|
2023-02-23 17:04:34 -05:00
|
|
|
;; REFERENCES
|
|
|
|
|
|
2020-07-19 17:41:24 +00:00
|
|
|
(identifier) @reference
|
2023-02-23 17:04:34 -05:00
|
|
|
|
2021-12-22 13:26:55 -05:00
|
|
|
(type_identifier) @reference
|