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