mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-03 10:57:48 +03:00
queries: Rewrite all locals
This commit is contained in:
parent
8ead488fd5
commit
ac88096c98
50 changed files with 159 additions and 535 deletions
|
@ -6,9 +6,9 @@
|
|||
|
||||
; (i)
|
||||
(formal_parameters
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
; (i = 1)
|
||||
(formal_parameters
|
||||
(assignment_pattern
|
||||
left: (identifier) @local.definition))
|
||||
left: (identifier) @local.definition.variable.parameter))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
;------------
|
||||
|
||||
(type_parameter
|
||||
name: (type_identifier) @local.definition)
|
||||
name: (type_identifier) @local.definition.type.parameter)
|
||||
|
||||
; Javascript and Typescript Treesitter grammars deviate when defining the
|
||||
; tree structure for parameters, so we need to address them in each specific
|
||||
|
@ -20,14 +20,15 @@
|
|||
; (i: t)
|
||||
; (i: t = 1)
|
||||
(required_parameter
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
; (i?: t)
|
||||
; (i?: t = 1) // Invalid but still possible to highlight.
|
||||
(optional_parameter
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
;-----------
|
||||
|
||||
(type_identifier) @local.reference
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -5,25 +5,6 @@
|
|||
(subprogram_body) @local.scope
|
||||
(block_statement) @local.scope
|
||||
|
||||
(with_clause (_) @local.definition)
|
||||
(procedure_specification name: (_) @local.definition)
|
||||
(function_specification name: (_) @local.definition)
|
||||
(package_declaration name: (_) @local.definition)
|
||||
(package_body name: (_) @local.definition)
|
||||
(generic_instantiation . name: (_) @local.definition)
|
||||
(component_declaration . (identifier) @local.definition)
|
||||
(exception_declaration . (identifier) @local.definition)
|
||||
(formal_object_declaration . (identifier) @local.definition)
|
||||
(object_declaration . (identifier) @local.definition)
|
||||
(parameter_specification . (identifier) @local.definition)
|
||||
(full_type_declaration . (identifier) @local.definition)
|
||||
(private_type_declaration . (identifier) @local.definition)
|
||||
(private_extension_declaration . (identifier) @local.definition)
|
||||
(incomplete_type_declaration . (identifier) @local.definition)
|
||||
(protected_type_declaration . (identifier) @local.definition)
|
||||
(formal_complete_type_declaration . (identifier) @local.definition)
|
||||
(formal_incomplete_type_declaration . (identifier) @local.definition)
|
||||
(task_type_declaration . (identifier) @local.definition)
|
||||
(subtype_declaration . (identifier) @local.definition)
|
||||
(parameter_specification . (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
; Definitions
|
||||
|
||||
(parameter
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
(type_parameters
|
||||
(type_identifier) @local.definition)
|
||||
(type_identifier) @local.definition.type.parameter)
|
||||
(constrained_type_parameter
|
||||
left: (type_identifier) @local.definition)
|
||||
left: (type_identifier) @local.definition.type.parameter)
|
||||
|
||||
(closure_parameters (identifier) @local.definition)
|
||||
(closure_parameters (identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -30,67 +30,7 @@
|
|||
|
||||
; Definitions
|
||||
|
||||
(annotation_definition_identifier) @local.definition
|
||||
|
||||
(const_identifier) @local.definition
|
||||
|
||||
(enum (enum_identifier) @local.definition)
|
||||
|
||||
[
|
||||
(enum_member)
|
||||
(field_identifier)
|
||||
] @local.definition
|
||||
|
||||
(method_identifier) @local.definition
|
||||
|
||||
(namespace) @local.definition
|
||||
|
||||
[
|
||||
(param_identifier)
|
||||
(return_identifier)
|
||||
] @local.definition
|
||||
|
||||
(group (type_identifier) @local.definition)
|
||||
|
||||
(struct (type_identifier) @local.definition)
|
||||
|
||||
(union (type_identifier) @local.definition)
|
||||
|
||||
(interface (type_identifier) @local.definition)
|
||||
|
||||
; Generics Related (don't know how to combine these)
|
||||
|
||||
(struct
|
||||
(generics
|
||||
(generic_parameters
|
||||
(generic_identifier) @local.definition)))
|
||||
|
||||
(interface
|
||||
(generics
|
||||
(generic_parameters
|
||||
(generic_identifier) @local.definition)))
|
||||
|
||||
(method
|
||||
(implicit_generics
|
||||
(implicit_generic_parameters
|
||||
(generic_identifier) @local.definition)))
|
||||
|
||||
(method
|
||||
(generics
|
||||
(generic_parameters
|
||||
(generic_identifier) @local.definition)))
|
||||
|
||||
(annotation
|
||||
(generics
|
||||
(generic_parameters
|
||||
(generic_identifier) @local.definition)))
|
||||
|
||||
(replace_using
|
||||
(generics
|
||||
(generic_parameters
|
||||
(generic_identifier) @local.definition)))
|
||||
|
||||
(return_type
|
||||
(generics
|
||||
(generic_parameters
|
||||
(generic_identifier) @local.definition)))
|
||||
] @local.definition.variable.parameter
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
(main_component_definition) @local.scope
|
||||
(block_statement) @local.scope
|
||||
|
||||
(parameter name: (identifier) @local.definition) @local.definition
|
||||
(parameter name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
|
||||
(identifier) @local.reference
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
;------------
|
||||
|
||||
(class_definition
|
||||
body: (_) @local.definition)
|
||||
body: (_) @local.definition.type)
|
||||
|
||||
; References
|
||||
;------------
|
||||
|
|
|
@ -12,30 +12,9 @@
|
|||
; Definitions
|
||||
;------------
|
||||
|
||||
; ...i
|
||||
(rest_pattern
|
||||
(identifier) @local.definition)
|
||||
|
||||
; { i }
|
||||
(object_pattern
|
||||
(shorthand_property_identifier_pattern) @local.definition)
|
||||
|
||||
; { a: i }
|
||||
(object_pattern
|
||||
(pair_pattern
|
||||
value: (identifier) @local.definition))
|
||||
|
||||
; [ i ]
|
||||
(array_pattern
|
||||
(identifier) @local.definition)
|
||||
|
||||
; i => ...
|
||||
(arrow_function
|
||||
parameter: (identifier) @local.definition)
|
||||
|
||||
; const/let/var i = ...
|
||||
(variable_declarator
|
||||
name: (identifier) @local.definition)
|
||||
parameter: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
;------------
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
(infix_declaration) @local.scope
|
||||
(let_in_expr) @local.scope
|
||||
|
||||
(function_declaration_left (lower_pattern (lower_case_identifier)) @local.definition)
|
||||
(function_declaration_left (lower_case_identifier) @local.definition)
|
||||
(function_declaration_left (lower_pattern (lower_case_identifier)) @local.definition.function)
|
||||
(function_declaration_left (lower_case_identifier) @local.definition.function)
|
||||
|
||||
(value_expr(value_qid(upper_case_identifier)) @local.reference)
|
||||
(value_expr(value_qid(lower_case_identifier)) @local.reference)
|
||||
|
|
|
@ -1,30 +1,23 @@
|
|||
; Specs and Callbacks
|
||||
(attribute
|
||||
(stab_clause
|
||||
pattern: (arguments (variable)? @local.definition)
|
||||
pattern: (arguments (variable)? @local.definition.variable.parameter)
|
||||
; If a spec uses a variable as the return type (and later a `when` clause to type it):
|
||||
body: (variable)? @local.definition)) @local.scope
|
||||
body: (variable)? @local.definition.variable.parameter)) @local.scope
|
||||
|
||||
; parametric `-type`s
|
||||
((attribute
|
||||
name: (atom) @_type
|
||||
(arguments
|
||||
(binary_operator
|
||||
left: (call (arguments (variable) @local.definition))
|
||||
left: (call (arguments (variable) @local.definition.variable.parameter))
|
||||
operator: "::") @local.scope))
|
||||
(#match? @_type "(type|opaque)"))
|
||||
|
||||
; macros
|
||||
((attribute
|
||||
name: (atom) @_define
|
||||
(arguments
|
||||
(call (arguments (variable) @local.definition)))) @local.scope
|
||||
(#eq? @_define "define"))
|
||||
|
||||
; `fun`s
|
||||
(anonymous_function (stab_clause pattern: (arguments (variable) @local.definition))) @local.scope
|
||||
(anonymous_function (stab_clause pattern: (arguments (variable) @local.definition.variable.parameter))) @local.scope
|
||||
|
||||
; Ordinary functions
|
||||
(function_clause pattern: (arguments (variable) @local.definition)) @local.scope
|
||||
(function_clause pattern: (arguments (variable) @local.definition.variable.parameter)) @local.scope
|
||||
|
||||
(variable) @local.reference
|
||||
|
|
|
@ -6,27 +6,16 @@
|
|||
(function_or_value_defn)
|
||||
] @local.scope
|
||||
|
||||
(value_declaration_left
|
||||
.
|
||||
[
|
||||
(_ (identifier) @local.definition)
|
||||
(_ (_ (identifier) @local.definition))
|
||||
(_ (_ (_ (identifier) @local.definition)))
|
||||
(_ (_ (_ (_ (identifier) @local.definition))))
|
||||
(_ (_ (_ (_ (_ (identifier) @local.definition)))))
|
||||
(_ (_ (_ (_ (_ (_ (identifier) @local.definition))))))
|
||||
])
|
||||
|
||||
(function_declaration_left
|
||||
.
|
||||
((_) @local.definition)
|
||||
((_) @local.definition.function)
|
||||
((argument_patterns
|
||||
[
|
||||
(_ (identifier) @local.definition)
|
||||
(_ (_ (identifier) @local.definition))
|
||||
(_ (_ (_ (identifier) @local.definition)))
|
||||
(_ (_ (_ (_ (identifier) @local.definition))))
|
||||
(_ (_ (_ (_ (_ (identifier) @local.definition)))))
|
||||
(_ (_ (_ (_ (_ (_ (identifier) @local.definition))))))
|
||||
(_ (identifier) @local.definition.variable.parameter)
|
||||
(_ (_ (identifier) @local.definition.variable.parameter))
|
||||
(_ (_ (_ (identifier) @local.definition.variable.parameter)))
|
||||
(_ (_ (_ (_ (identifier) @local.definition.variable.parameter))))
|
||||
(_ (_ (_ (_ (_ (identifier) @local.definition.variable.parameter)))))
|
||||
(_ (_ (_ (_ (_ (_ (identifier) @local.definition.variable.parameter))))))
|
||||
])
|
||||
))
|
||||
|
|
|
@ -4,12 +4,7 @@
|
|||
(case_clause) @local.scope
|
||||
|
||||
; Definitions
|
||||
(let pattern: (identifier) @local.definition)
|
||||
(function_parameter name: (identifier) @local.definition)
|
||||
(list_pattern (identifier) @local.definition)
|
||||
(list_pattern assign: (identifier) @local.definition)
|
||||
(tuple_pattern (identifier) @local.definition)
|
||||
(record_pattern_argument pattern: (identifier) @local.definition)
|
||||
(function_parameter name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
; Copyright (C) 2021 Will Cassella (github@willcassella.com)
|
||||
;
|
||||
; Licensed under the Apache License, Version 2.0 (the "License");
|
||||
; you may not use this file except in compliance with the License.
|
||||
; You may obtain a copy of the License at
|
||||
;
|
||||
; http://www.apache.org/licenses/LICENSE-2.0
|
||||
;
|
||||
; Unless required by applicable law or agreed to in writing, software
|
||||
; distributed under the License is distributed on an "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
; See the License for the specific language governing permissions and
|
||||
; limitations under the License.
|
||||
|
||||
(source_file) @local.scope
|
||||
(assignment target: (identifier) @local.definition)
|
|
@ -10,26 +10,14 @@
|
|||
|
||||
(type_parameter_list
|
||||
(parameter_declaration
|
||||
name: (identifier) @local.definition))
|
||||
name: (identifier) @local.definition.variable.parameter))
|
||||
|
||||
(parameter_declaration (identifier) @local.definition)
|
||||
(variadic_parameter_declaration (identifier) @local.definition)
|
||||
|
||||
(short_var_declaration
|
||||
left: (expression_list
|
||||
(identifier) @local.definition))
|
||||
|
||||
(var_spec
|
||||
(identifier) @local.definition)
|
||||
|
||||
(for_statement
|
||||
(range_clause
|
||||
left: (expression_list
|
||||
(identifier) @local.definition)))
|
||||
(parameter_declaration (identifier) @local.definition.variable.parameter)
|
||||
(variadic_parameter_declaration (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(const_declaration
|
||||
(const_spec
|
||||
name: (identifier) @local.definition))
|
||||
name: (identifier) @local.definition.constant))
|
||||
|
||||
; References
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
(infix_declaration) @local.scope
|
||||
(let_in_expr) @local.scope
|
||||
|
||||
(function_declaration_left (lower_pattern (lower_case_identifier)) @local.definition)
|
||||
(function_declaration_left (lower_case_identifier) @local.definition)
|
||||
(function_declaration_left (lower_pattern (lower_case_identifier)) @local.definition.function)
|
||||
(function_declaration_left (lower_case_identifier) @local.definition.function)
|
||||
|
||||
(value_expr(value_qid(upper_case_identifier)) @local.reference)
|
||||
(value_expr(value_qid(lower_case_identifier)) @local.reference)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(function_definition) @local.scope
|
||||
|
||||
(parameter
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -3,17 +3,10 @@
|
|||
(function_declaration) @local.scope
|
||||
(compound_expression) @local.scope
|
||||
|
||||
(global_binding
|
||||
(identifier) @local.definition)
|
||||
(constant_binding
|
||||
(identifier) @local.definition)
|
||||
(type_binding
|
||||
(identifier) @local.definition)
|
||||
|
||||
(function_declaration
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.function)
|
||||
(function_declaration
|
||||
(parameter (name) @local.definition))
|
||||
(parameter (name) @local.definition.variable.parameter))
|
||||
|
||||
(identifier) @local.reference
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
(fields (variable)) @local.definition
|
|
@ -1,4 +1,3 @@
|
|||
(signature name: (variable)) @local.definition
|
||||
(function name: (variable)) @local.definition
|
||||
(pat_name (variable)) @local.definition
|
||||
(signature name: (variable) @local.definition.function)
|
||||
(function name: (variable) @local.definition.function)
|
||||
(exp_name (variable)) @local.reference
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
(block)
|
||||
] @local.scope
|
||||
|
||||
(argument name: _ @local.definition)
|
||||
(define_variable name: _ @local.definition)
|
||||
(named_argument name: _ @local.definition)
|
||||
(argument name: _ @local.definition.variable.parameter)
|
||||
(named_argument name: _ @local.definition.variable.parameter)
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
;; From nvim-treesitter, contributed by @ObserverOfTime et al.
|
||||
|
||||
(funcdef
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.function)
|
||||
|
||||
(funcdefargs
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
(funcname) @local.reference
|
||||
|
||||
|
|
|
@ -2,81 +2,30 @@
|
|||
; Definitions
|
||||
; -----------
|
||||
|
||||
; Variables
|
||||
(assignment
|
||||
(identifier) @local.definition)
|
||||
|
||||
(assignment
|
||||
(tuple_expression
|
||||
(identifier) @local.definition))
|
||||
|
||||
; Constants
|
||||
(const_statement
|
||||
(assignment
|
||||
. (identifier) @local.definition))
|
||||
|
||||
; let/const bindings
|
||||
(let_binding
|
||||
(identifier) @local.definition)
|
||||
|
||||
(let_binding
|
||||
(tuple_expression
|
||||
(identifier) @local.definition))
|
||||
|
||||
; For bindings
|
||||
(for_binding
|
||||
(identifier) @local.definition)
|
||||
|
||||
(for_binding
|
||||
(tuple_expression
|
||||
(identifier) @local.definition))
|
||||
|
||||
; Types
|
||||
(struct_definition
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(abstract_definition
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(abstract_definition
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(type_parameter_list
|
||||
(identifier) @local.definition)
|
||||
|
||||
; Module imports
|
||||
(import_statement
|
||||
(identifier) @local.definition)
|
||||
. (identifier) @local.definition.constant))
|
||||
|
||||
; Parameters
|
||||
(parameter_list
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
(optional_parameter
|
||||
.
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
(slurp_parameter
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
(typed_parameter
|
||||
parameter: (identifier) @local.definition
|
||||
parameter: (identifier) @local.definition.variable.parameter
|
||||
(_))
|
||||
|
||||
; Single parameter arrow function
|
||||
(function_expression
|
||||
.
|
||||
(identifier) @local.definition)
|
||||
|
||||
; Function/macro definitions
|
||||
(function_definition
|
||||
name: (identifier) @local.definition) @local.scope
|
||||
|
||||
(short_function_definition
|
||||
name: (identifier) @local.definition) @local.scope
|
||||
|
||||
(macro_definition
|
||||
name: (identifier) @local.definition) @local.scope
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
; ----------
|
||||
; References
|
||||
|
@ -97,5 +46,8 @@
|
|||
(let_statement)
|
||||
(quote_statement)
|
||||
(do_clause)
|
||||
(function_definition)
|
||||
(short_function_definition)
|
||||
(macro_definition)
|
||||
] @local.scope
|
||||
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
; Definitions
|
||||
|
||||
(alias
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.variable)
|
||||
|
||||
(assignment
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.variable)
|
||||
|
||||
(mod
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.namespace)
|
||||
|
||||
(recipe_parameter
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(recipe
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.function)
|
||||
|
||||
; References
|
||||
|
||||
|
|
|
@ -2,29 +2,24 @@
|
|||
|
||||
(block) @local.scope
|
||||
|
||||
(pattern
|
||||
(identifier
|
||||
(varid) @local.definition))
|
||||
|
||||
(decl
|
||||
(apattern
|
||||
(pattern
|
||||
(identifier
|
||||
(varid) @local.definition))))
|
||||
(pparameter
|
||||
(pattern
|
||||
(identifier
|
||||
(varid) @local.definition.variable.parameter)))
|
||||
|
||||
(puredecl
|
||||
(funid
|
||||
(identifier
|
||||
(varid) @local.definition)))
|
||||
(varid) @local.definition.function)))
|
||||
|
||||
(puredecl
|
||||
(binder
|
||||
(identifier
|
||||
(varid) @local.definition)))
|
||||
(varid) @local.definition.function)))
|
||||
|
||||
(decl
|
||||
(binder
|
||||
(identifier
|
||||
(varid) @local.definition)))
|
||||
(varid) @local.definition.function)))
|
||||
|
||||
(identifier (varid) @local.reference)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
; Definitions
|
||||
|
||||
(type_parameter
|
||||
(type_identifier) @local.definition)
|
||||
(type_identifier) @local.definition.type.parameter)
|
||||
|
||||
; References
|
||||
|
||||
|
|
|
@ -5,26 +5,20 @@
|
|||
body: (_) @local.scope)
|
||||
|
||||
; Definitions
|
||||
(assign
|
||||
lhs: (identifier) @local.definition)
|
||||
|
||||
(variable
|
||||
(identifier) @local.definition)
|
||||
(arg
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
(arg
|
||||
(identifier) @local.definition)
|
||||
|
||||
(arg
|
||||
(variable (identifier)) @local.definition)
|
||||
(variable (identifier)) @local.definition.parameter)
|
||||
|
||||
(import_item
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.namespace)
|
||||
|
||||
(entry_block
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.other.member)
|
||||
|
||||
(entry_inline
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.other.member)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
; Definitions
|
||||
|
||||
(argument
|
||||
(value (var (local_var) @local.definition)))
|
||||
|
||||
(instruction
|
||||
(local_var) @local.definition)
|
||||
(value (var (local_var) @local.definition.variable.parameter)))
|
||||
|
||||
; References
|
||||
(local_var) @local.reference
|
||||
|
|
|
@ -1,19 +1,6 @@
|
|||
(function_definition name: (identifier) @local.definition ?) @local.scope
|
||||
(function_arguments (identifier)* @local.definition)
|
||||
(function_definition name: (identifier) @local.definition.function ?) @local.scope
|
||||
(function_arguments (identifier)* @local.definition.variable.parameter)
|
||||
|
||||
(lambda (arguments (identifier) @local.definition)) @local.scope
|
||||
|
||||
(assignment left: ((function_call
|
||||
name: (identifier) @local.definition)))
|
||||
(assignment left: ((field_expression . [(function_call
|
||||
name: (identifier) @local.definition)
|
||||
(identifier) @local.definition])))
|
||||
(assignment left: (_) @local.definition)
|
||||
(assignment (multioutput_variable (_) @local.definition))
|
||||
|
||||
(iterator . (identifier) @local.definition)
|
||||
(global_operator (identifier) @local.definition)
|
||||
(persistent_operator (identifier) @local.definition)
|
||||
(catch_clause (identifier) @local.definition)
|
||||
(lambda (arguments (identifier) @local.definition.variable.parameter)) @local.scope
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
; Definitions
|
||||
;------------
|
||||
|
||||
(value_pattern) @local.definition
|
||||
(value_pattern) @local.definition.variable.parameter
|
||||
|
||||
; References
|
||||
;-----------
|
||||
|
|
|
@ -23,12 +23,8 @@
|
|||
(try_block then_block: (block) @local.scope)
|
||||
(with else_block: (block) @local.scope)
|
||||
|
||||
(field name: (identifier) @local.definition)
|
||||
(local name: (identifier) @local.definition)
|
||||
(param name: (identifier) @local.definition)
|
||||
(lambdaparam name: (identifier) @local.definition)
|
||||
("for" element: (idseq (identifier) @local.definition))
|
||||
(withelem name: (idseq (identifier) @local.definition))
|
||||
(param name: (identifier) @local.definition.variable.parameter)
|
||||
(lambdaparam name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
; only lower case identifiers are references
|
||||
(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
(signature name: (variable)) @local.definition
|
||||
(function name: (variable)) @local.definition
|
||||
(pat_name (variable)) @local.definition
|
||||
(signature name: (variable) @local.definition.function)
|
||||
(function name: (variable) @local.definition.function)
|
||||
(exp_name (variable)) @local.reference
|
||||
|
|
|
@ -10,33 +10,33 @@
|
|||
|
||||
; Parameters
|
||||
(parameters
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
(parameters
|
||||
(typed_parameter
|
||||
(identifier) @local.definition))
|
||||
(identifier) @local.definition.variable.parameter))
|
||||
(parameters
|
||||
(default_parameter
|
||||
name: (identifier) @local.definition))
|
||||
name: (identifier) @local.definition.variable.parameter))
|
||||
(parameters
|
||||
(typed_default_parameter
|
||||
name: (identifier) @local.definition))
|
||||
name: (identifier) @local.definition.variable.parameter))
|
||||
(parameters
|
||||
(list_splat_pattern ; *args
|
||||
(identifier) @local.definition))
|
||||
(identifier) @local.definition.variable.parameter))
|
||||
(parameters
|
||||
(dictionary_splat_pattern ; **kwargs
|
||||
(identifier) @local.definition))
|
||||
(identifier) @local.definition.variable.parameter))
|
||||
|
||||
(lambda_parameters
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
; Imports
|
||||
(import_statement
|
||||
name: (dotted_name
|
||||
(identifier) @local.definition))
|
||||
(identifier) @local.definition.namespace))
|
||||
|
||||
(aliased_import
|
||||
alias: (identifier) @local.definition)
|
||||
alias: (identifier) @local.definition.namespace)
|
||||
|
||||
;; References
|
||||
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
(function_definition) @local.scope
|
||||
|
||||
(formal_parameters (identifier) @local.definition)
|
||||
|
||||
(left_assignment name: (identifier) @local.definition)
|
||||
(equals_assignment name: (identifier) @local.definition)
|
||||
(right_assignment name: (identifier) @local.definition)
|
||||
(formal_parameters (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
(switch_expression) @local.scope
|
||||
|
||||
; Definitions
|
||||
;------------
|
||||
(type_declaration) @local.definition
|
||||
(let_binding) @local.definition
|
||||
(module_declaration) @local.definition
|
|
@ -7,21 +7,14 @@
|
|||
(do_block)
|
||||
] @local.scope
|
||||
|
||||
(block_parameter (identifier) @local.definition)
|
||||
(block_parameters (identifier) @local.definition)
|
||||
(destructured_parameter (identifier) @local.definition)
|
||||
(hash_splat_parameter (identifier) @local.definition)
|
||||
(lambda_parameters (identifier) @local.definition)
|
||||
(method_parameters (identifier) @local.definition)
|
||||
(splat_parameter (identifier) @local.definition)
|
||||
|
||||
(keyword_parameter name: (identifier) @local.definition)
|
||||
(optional_parameter name: (identifier) @local.definition)
|
||||
(block_parameter (identifier) @local.definition.variable.parameter)
|
||||
(block_parameters (identifier) @local.definition.variable.parameter)
|
||||
(destructured_parameter (identifier) @local.definition.variable.parameter)
|
||||
(hash_splat_parameter (identifier) @local.definition.variable.parameter)
|
||||
(lambda_parameters (identifier) @local.definition.variable.parameter)
|
||||
(method_parameters (identifier) @local.definition.variable.parameter)
|
||||
(splat_parameter (identifier) @local.definition.variable.parameter)
|
||||
(keyword_parameter name: (identifier) @local.definition.variable.parameter)
|
||||
(optional_parameter name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(identifier) @local.reference
|
||||
|
||||
(assignment left: (identifier) @local.definition)
|
||||
(operator_assignment left: (identifier) @local.definition)
|
||||
(left_assignment_list (identifier) @local.definition)
|
||||
(rest_assignment (identifier) @local.definition)
|
||||
(destructured_left_assignment (identifier) @local.definition)
|
||||
|
|
|
@ -15,17 +15,9 @@
|
|||
; Definitions
|
||||
|
||||
(parameter
|
||||
(identifier) @local.definition)
|
||||
pattern: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(type_parameters
|
||||
(type_identifier) @local.definition)
|
||||
(constrained_type_parameter
|
||||
left: (type_identifier) @local.definition)
|
||||
(optional_type_parameter
|
||||
name: (type_identifier) @local.definition)
|
||||
|
||||
(closure_parameters (identifier) @local.definition)
|
||||
(closure_parameters (identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
(type_identifier) @local.reference
|
||||
|
|
|
@ -3,27 +3,12 @@
|
|||
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @local.definition) @local.scope
|
||||
name: (identifier) @local.definition.function) @local.scope
|
||||
|
||||
(function_definition
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.function)
|
||||
|
||||
(parameter
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(binding
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(val_definition
|
||||
pattern: (identifier) @local.definition)
|
||||
|
||||
(var_definition
|
||||
pattern: (identifier) @local.definition)
|
||||
|
||||
(val_declaration
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(var_declaration
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -16,27 +16,7 @@
|
|||
(jmp_label)
|
||||
] @local.reference
|
||||
|
||||
(enum_reference
|
||||
(field_identifier) @local.definition)
|
||||
|
||||
((field_definition
|
||||
(access_modifiers) @_mod
|
||||
(field_identifier) @local.definition)
|
||||
(#eq? @_mod "enum"))
|
||||
|
||||
(field_definition
|
||||
(field_identifier) @local.definition
|
||||
(field_type) @local.definition)
|
||||
|
||||
(annotation_key) @local.definition
|
||||
|
||||
(method_definition
|
||||
(method_signature (method_identifier) @local.definition))
|
||||
(method_signature (method_identifier) @local.definition.function.method))
|
||||
|
||||
(param_identifier) @local.definition
|
||||
|
||||
(annotation_directive
|
||||
(class_identifier) @local.definition)
|
||||
|
||||
(class_directive
|
||||
(class_identifier) @local.definition)
|
||||
(param_identifier) @local.definition.variable.parameter
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
(constructor_definition) @local.scope
|
||||
(block_statement) @local.scope
|
||||
|
||||
(function_definition (parameter name: (identifier) @local.definition))
|
||||
(constructor_definition (parameter name: (identifier) @local.definition))
|
||||
(variable_declaration name: (identifier) @local.definition)
|
||||
(function_definition (parameter name: (identifier) @local.definition.variable.parameter))
|
||||
(constructor_definition (parameter name: (identifier) @local.definition.variable.parameter))
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
; Definitions
|
||||
|
||||
(parameter
|
||||
(identifier) @local.definition)
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
(closure_parameters (identifier) @local.definition)
|
||||
(closure_parameters (identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
; Upstream: https://github.com/alex-pinkus/tree-sitter-swift/blob/57c1c6d6ffa1c44b330182d41717e6fe37430704/queries/locals.scm
|
||||
(import_declaration (identifier) @definition.import)
|
||||
(function_declaration name: (simple_identifier) @definition.function)
|
||||
(import_declaration (identifier) @local.definition.namespace)
|
||||
(function_declaration name: (simple_identifier) @local.definition.function)
|
||||
|
||||
; Scopes
|
||||
[
|
||||
|
|
|
@ -14,14 +14,11 @@
|
|||
; Definitions @local.definition
|
||||
; ------------------------------
|
||||
|
||||
(let_statement
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(parameter
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(constant
|
||||
name: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition.constant)
|
||||
|
||||
; References @local.reference
|
||||
; -----------------------------
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
|
||||
(var_declaration
|
||||
declarators: (var_declarators
|
||||
(var (identifier)) @local.definition))
|
||||
(var (identifier)) @local.definition.variable))
|
||||
|
||||
(var_assignment
|
||||
variables: (assignment_variables
|
||||
(var (identifier) @local.definition)))
|
||||
(var (identifier) @local.definition.variable)))
|
||||
|
||||
(arg name: (identifier) @local.definition)
|
||||
(arg name: (identifier) @local.definition.variable.parameter)
|
||||
|
||||
(anon_function) @local.scope
|
||||
((function_statement
|
||||
(function_name) @local.definition) @local.scope)
|
||||
(function_name) @local.definition.function) @local.scope)
|
||||
|
||||
(program) @local.scope
|
||||
(if_statement) @local.scope
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(identifier) @local.reference
|
||||
(assignment_expression
|
||||
left: (identifier) @local.definition)
|
||||
left: (identifier) @local.definition.variable)
|
||||
(macro_statement
|
||||
(parameter_list
|
||||
(identifier) @local.definition))
|
||||
(identifier) @local.definition.variable.parameter))
|
||||
(macro_statement) @local.scope
|
||||
|
|
|
@ -11,41 +11,4 @@
|
|||
|
||||
; Definitions
|
||||
|
||||
(annotation_identifier) @local.definition
|
||||
|
||||
; (const_definition (identifier) @definition.constant)
|
||||
|
||||
; (enum_definition "enum"
|
||||
; . (identifier) @definition.enum
|
||||
; "{" (identifier) @definition.constant "}")
|
||||
|
||||
; (senum_definition "senum"
|
||||
; . (identifier) @definition.enum)
|
||||
|
||||
; (field (identifier) @definition.field)
|
||||
|
||||
; (function_definition (identifier) @definition.function)
|
||||
|
||||
; (namespace_declaration
|
||||
; "namespace" (namespace_scope)
|
||||
; . (_) @definition.namespace
|
||||
; (namespace_uri)?)
|
||||
|
||||
; (parameter (identifier) @definition.parameter)
|
||||
|
||||
; (struct_definition
|
||||
; "struct" . (identifier) @definition.type)
|
||||
|
||||
; (union_definition
|
||||
; "union" . (identifier) @definition.type)
|
||||
|
||||
; (exception_definition
|
||||
; "exception" . (identifier) @definition.type)
|
||||
|
||||
; (service_definition
|
||||
; "service" . (identifier) @definition.type)
|
||||
|
||||
; (interaction_definition
|
||||
; "interaction" . (identifier) @definition.type)
|
||||
|
||||
; (typedef_identifier) @definition.type
|
||||
(annotation_identifier) @local.definition.attribute
|
||||
|
|
|
@ -15,22 +15,22 @@
|
|||
] @local.scope
|
||||
|
||||
; Definitions
|
||||
(choose (identifier) @local.definition)
|
||||
(choose (tuple_of_identifiers (identifier) @local.definition))
|
||||
(constant_declaration (identifier) @local.definition)
|
||||
(constant_declaration (operator_declaration name: (_) @local.definition))
|
||||
(function_definition name: (identifier) @local.definition)
|
||||
(lambda (identifier) @local.definition)
|
||||
(module_definition name: (_) @local.definition)
|
||||
(module_definition parameter: (identifier) @local.definition)
|
||||
(module_definition parameter: (operator_declaration name: (_) @local.definition))
|
||||
(operator_definition name: (_) @local.definition)
|
||||
(operator_definition parameter: (identifier) @local.definition)
|
||||
(operator_definition parameter: (operator_declaration name: (_) @local.definition))
|
||||
(quantifier_bound (identifier) @local.definition)
|
||||
(quantifier_bound (tuple_of_identifiers (identifier) @local.definition))
|
||||
(unbounded_quantification (identifier) @local.definition)
|
||||
(variable_declaration (identifier) @local.definition)
|
||||
(choose (identifier) @local.definition.variable.parameter)
|
||||
(choose (tuple_of_identifiers (identifier) @local.definition.variable.parameter))
|
||||
(constant_declaration (identifier) @local.definition.constant)
|
||||
(constant_declaration (operator_declaration name: (_) @local.definition.constant))
|
||||
(function_definition name: (identifier) @local.definition.function)
|
||||
(lambda (identifier) @local.definition.function)
|
||||
(module_definition name: (_) @local.definition.namespace)
|
||||
(module_definition parameter: (identifier) @local.definition.variable.parameter)
|
||||
(module_definition parameter: (operator_declaration name: (_) @local.definition.variable.parameter))
|
||||
(operator_definition name: (_) @local.definition.operator)
|
||||
(operator_definition parameter: (identifier) @local.definition.variable.parameter)
|
||||
(operator_definition parameter: (operator_declaration name: (_) @local.definition.variable.parameter))
|
||||
(quantifier_bound (identifier) @local.definition.variable.parameter)
|
||||
(quantifier_bound (tuple_of_identifiers (identifier) @local.definition.variable.parameter))
|
||||
(unbounded_quantification (identifier) @local.definition.variable.parameter)
|
||||
(variable_declaration (identifier) @local.definition.variable.builtin)
|
||||
|
||||
; Proof scopes and definitions
|
||||
[
|
||||
|
@ -39,12 +39,12 @@
|
|||
(theorem)
|
||||
] @local.scope
|
||||
|
||||
(assume_prove (new (identifier) @local.definition))
|
||||
(assume_prove (new (operator_declaration name: (_) @local.definition)))
|
||||
(assumption name: (identifier) @local.definition)
|
||||
(pick_proof_step (identifier) @local.definition)
|
||||
(take_proof_step (identifier) @local.definition)
|
||||
(theorem name: (identifier) @local.definition)
|
||||
(assume_prove (new (identifier) @local.definition.variable.parameter))
|
||||
(assume_prove (new (operator_declaration name: (_) @local.definition.variable.parameter)))
|
||||
(assumption name: (identifier) @local.definition.constant)
|
||||
(pick_proof_step (identifier) @local.definition.variable.parameter)
|
||||
(take_proof_step (identifier) @local.definition.variable.parameter)
|
||||
(theorem name: (identifier) @local.definition.constant)
|
||||
|
||||
;PlusCal scopes and definitions
|
||||
[
|
||||
|
@ -54,10 +54,10 @@
|
|||
(pcal_with)
|
||||
] @local.scope
|
||||
|
||||
(pcal_macro_decl parameter: (identifier) @local.definition)
|
||||
(pcal_proc_var_decl (identifier) @local.definition)
|
||||
(pcal_var_decl (identifier) @local.definition)
|
||||
(pcal_with (identifier) @local.definition)
|
||||
(pcal_macro_decl parameter: (identifier) @local.definition.variable.parameter)
|
||||
(pcal_proc_var_decl (identifier) @local.definition.variable.parameter)
|
||||
(pcal_var_decl (identifier) @local.definition.variable.parameter)
|
||||
(pcal_with (identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
(identifier_ref) @local.reference
|
||||
|
|
|
@ -8,54 +8,32 @@
|
|||
(module_declaration)
|
||||
] @scope
|
||||
|
||||
(data_declaration
|
||||
(list_of_variable_decl_assignments
|
||||
(variable_decl_assignment
|
||||
(simple_identifier) @definition.var)))
|
||||
|
||||
(genvar_initialization
|
||||
(genvar_identifier
|
||||
(simple_identifier) @definition.var))
|
||||
|
||||
(for_initialization
|
||||
(for_variable_declaration
|
||||
(simple_identifier) @definition.var))
|
||||
|
||||
(net_declaration
|
||||
(list_of_net_decl_assignments
|
||||
(net_decl_assignment
|
||||
(simple_identifier) @definition.var)))
|
||||
|
||||
(ansi_port_declaration
|
||||
(port_identifier
|
||||
(simple_identifier) @definition.var))
|
||||
|
||||
(parameter_declaration
|
||||
(list_of_param_assignments
|
||||
(param_assignment
|
||||
(parameter_identifier
|
||||
(simple_identifier) @definition.parameter))))
|
||||
(simple_identifier) @local.definition.variable.parameter))))
|
||||
|
||||
(local_parameter_declaration
|
||||
(list_of_param_assignments
|
||||
(param_assignment
|
||||
(parameter_identifier
|
||||
(simple_identifier) @definition.parameter))))
|
||||
(simple_identifier) @local.definition.variable.parameter))))
|
||||
|
||||
;; TODO: fixme
|
||||
;(function_declaration
|
||||
;(function_identifier
|
||||
;(simple_identifier) @definition.function))
|
||||
;(simple_identifier) @local.definition.function))
|
||||
|
||||
(function_declaration
|
||||
(function_body_declaration
|
||||
(function_identifier
|
||||
(function_identifier
|
||||
(simple_identifier) @definition.function))))
|
||||
(simple_identifier) @local.definition.function))))
|
||||
|
||||
(tf_port_item1
|
||||
(port_identifier
|
||||
(simple_identifier) @definition.parameter))
|
||||
(simple_identifier) @local.definition.variable.parameter))
|
||||
|
||||
; too broad, now includes types etc
|
||||
(simple_identifier) @reference
|
||||
(simple_identifier) @local.reference
|
||||
|
|
|
@ -6,16 +6,4 @@
|
|||
(field) @local.reference
|
||||
(static_field) @local.reference
|
||||
|
||||
(for_statement
|
||||
loop_variable: (name) @local.definition)
|
||||
|
||||
(variable_definition
|
||||
name: (name) @local.definition)
|
||||
|
||||
(assignment
|
||||
left: (field) @local.definition)
|
||||
|
||||
(assignment
|
||||
left: (static_field) @local.definition)
|
||||
|
||||
(parameter) @local.definition
|
||||
(parameter) @local.definition.variable.parameter
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(rule_definition) @local.definition
|
||||
(string_identifier) @local.definition
|
||||
(rule_definition name: (identifier) @local.definition.string.special)
|
||||
(string_identifier) @local.definition.string.special.symbol
|
||||
|
||||
(for_expression
|
||||
(string_identifier) @local.reference)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue