nvim-treesitter/queries/java/locals.scm

101 lines
2.2 KiB
Scheme
Raw Normal View History

2024-01-06 15:05:50 +09:00
; SCOPES
; declarations
(program) @local.scope
2024-01-06 15:05:50 +09:00
2020-06-11 22:31:45 +05:30
(class_declaration
body: (_) @local.scope)
2024-01-06 15:05:50 +09:00
(record_declaration
body: (_) @local.scope)
2024-01-06 15:05:50 +09:00
(enum_declaration
body: (_) @local.scope)
2024-01-06 15:05:50 +09:00
(lambda_expression) @local.scope
2024-01-06 15:05:50 +09:00
(enhanced_for_statement) @local.scope
; block
(block) @local.scope
; if/else
(if_statement) @local.scope ; if+else
2024-01-06 15:05:50 +09:00
(if_statement
consequence: (_) @local.scope) ; if body in case there are no braces
2024-01-06 15:05:50 +09:00
(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)
2024-01-06 15:05:50 +09:00
(catch_clause) @local.scope ; needed because `Exception` variable
2020-06-11 22:31:45 +05:30
; loops
(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
body: (_) @local.scope)
2024-01-06 15:05:50 +09:00
(do_statement
body: (_) @local.scope)
2024-01-06 15:05:50 +09:00
(while_statement
body: (_) @local.scope)
; Functions
(constructor_declaration) @local.scope
2024-01-06 15:05:50 +09:00
(method_declaration) @local.scope
2024-01-06 15:05:50 +09:00
; DEFINITIONS
2020-08-12 10:41:31 -05:00
(package_declaration
(identifier) @local.definition.namespace)
(class_declaration
name: (identifier) @local.definition.type)
2024-01-06 15:05:50 +09:00
(record_declaration
name: (identifier) @local.definition.type)
(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))
2024-01-06 15:05:50 +09:00
(enhanced_for_statement
; for (var item : items) {
name: (identifier) @local.definition.var)
(formal_parameter
name: (identifier) @local.definition.parameter)
2024-01-06 15:05:50 +09:00
(catch_formal_parameter
name: (identifier) @local.definition.parameter)
2024-01-06 15:05:50 +09:00
(inferred_parameters
(identifier) @local.definition.parameter) ; (x,y) -> ...
(lambda_expression
2024-01-06 15:05:50 +09:00
parameters: (identifier) @local.definition.parameter) ; x -> ...
((scoped_identifier
(identifier) @local.definition.import)
2024-01-06 15:05:50 +09:00
(#has-ancestor? @local.definition.import import_declaration))
(field_declaration
declarator: (variable_declarator
name: (identifier) @local.definition.field))
2024-01-06 15:05:50 +09:00
; REFERENCES
(identifier) @local.reference
(type_identifier) @local.reference