From ac88096c98fc7ea9bb00ea127e3b510980872548 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 24 Feb 2025 12:46:34 -0500 Subject: [PATCH] queries: Rewrite all locals --- runtime/queries/_javascript/locals.scm | 4 +- runtime/queries/_typescript/locals.scm | 7 +- runtime/queries/ada/locals.scm | 21 +----- runtime/queries/bibtex/locals.scm | 0 runtime/queries/cairo/locals.scm | 8 +-- runtime/queries/capnp/locals.scm | 62 +---------------- runtime/queries/circom/locals.scm | 4 +- runtime/queries/dart/locals.scm | 2 +- runtime/queries/ecma/locals.scm | 23 +------ runtime/queries/elm/locals.scm | 4 +- runtime/queries/erlang/locals.scm | 17 ++--- runtime/queries/fsharp/locals.scm | 25 ++----- runtime/queries/gleam/locals.scm | 7 +- runtime/queries/gn/locals.scm | 16 ----- runtime/queries/go/locals.scm | 20 ++---- runtime/queries/gren/locals.scm | 4 +- runtime/queries/groovy/locals.scm | 2 +- runtime/queries/hare/locals.scm | 11 +--- runtime/queries/haskell-persistent/locals.scm | 1 - runtime/queries/haskell/locals.scm | 5 +- runtime/queries/inko/locals.scm | 5 +- runtime/queries/jq/locals.scm | 4 +- runtime/queries/julia/locals.scm | 66 +++---------------- runtime/queries/just/locals.scm | 10 +-- runtime/queries/koka/locals.scm | 19 ++---- runtime/queries/kotlin/locals.scm | 2 +- runtime/queries/koto/locals.scm | 18 ++--- runtime/queries/llvm/locals.scm | 5 +- runtime/queries/matlab/locals.scm | 19 +----- runtime/queries/ocaml/locals.scm | 2 +- runtime/queries/ponylang/locals.scm | 8 +-- runtime/queries/purescript/locals.scm | 5 +- runtime/queries/python/locals.scm | 18 ++--- runtime/queries/r/locals.scm | 6 +- runtime/queries/rescript/locals.scm | 7 -- runtime/queries/ruby/locals.scm | 25 +++---- runtime/queries/rust/locals.scm | 12 +--- runtime/queries/scala/locals.scm | 21 +----- runtime/queries/smali/locals.scm | 24 +------ runtime/queries/solidity/locals.scm | 5 +- runtime/queries/sway/locals.scm | 4 +- runtime/queries/swift/locals.scm | 4 +- runtime/queries/tact/locals.scm | 7 +- runtime/queries/teal/locals.scm | 8 +-- runtime/queries/tera/locals.scm | 4 +- runtime/queries/thrift/locals.scm | 39 +---------- runtime/queries/tlaplus/locals.scm | 52 +++++++-------- runtime/queries/verilog/locals.scm | 34 ++-------- runtime/queries/wren/locals.scm | 14 +--- runtime/queries/yara/locals.scm | 4 +- 50 files changed, 159 insertions(+), 535 deletions(-) delete mode 100644 runtime/queries/bibtex/locals.scm delete mode 100644 runtime/queries/gn/locals.scm delete mode 100644 runtime/queries/haskell-persistent/locals.scm delete mode 100644 runtime/queries/rescript/locals.scm diff --git a/runtime/queries/_javascript/locals.scm b/runtime/queries/_javascript/locals.scm index 943566167..7c7ffe139 100644 --- a/runtime/queries/_javascript/locals.scm +++ b/runtime/queries/_javascript/locals.scm @@ -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)) diff --git a/runtime/queries/_typescript/locals.scm b/runtime/queries/_typescript/locals.scm index 35e3c0db7..1a4428882 100644 --- a/runtime/queries/_typescript/locals.scm +++ b/runtime/queries/_typescript/locals.scm @@ -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 diff --git a/runtime/queries/ada/locals.scm b/runtime/queries/ada/locals.scm index 83d62a437..933f1498a 100644 --- a/runtime/queries/ada/locals.scm +++ b/runtime/queries/ada/locals.scm @@ -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 diff --git a/runtime/queries/bibtex/locals.scm b/runtime/queries/bibtex/locals.scm deleted file mode 100644 index e69de29bb..000000000 diff --git a/runtime/queries/cairo/locals.scm b/runtime/queries/cairo/locals.scm index 68c41a46b..ea309753b 100644 --- a/runtime/queries/cairo/locals.scm +++ b/runtime/queries/cairo/locals.scm @@ -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 diff --git a/runtime/queries/capnp/locals.scm b/runtime/queries/capnp/locals.scm index e98ce2605..43d443483 100644 --- a/runtime/queries/capnp/locals.scm +++ b/runtime/queries/capnp/locals.scm @@ -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 diff --git a/runtime/queries/circom/locals.scm b/runtime/queries/circom/locals.scm index e0ea12de0..d346e8c04 100644 --- a/runtime/queries/circom/locals.scm +++ b/runtime/queries/circom/locals.scm @@ -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 \ No newline at end of file +(identifier) @local.reference diff --git a/runtime/queries/dart/locals.scm b/runtime/queries/dart/locals.scm index 629838e52..15a81f78c 100644 --- a/runtime/queries/dart/locals.scm +++ b/runtime/queries/dart/locals.scm @@ -12,7 +12,7 @@ ;------------ (class_definition - body: (_) @local.definition) + body: (_) @local.definition.type) ; References ;------------ diff --git a/runtime/queries/ecma/locals.scm b/runtime/queries/ecma/locals.scm index df8eb0d39..345cf1770 100644 --- a/runtime/queries/ecma/locals.scm +++ b/runtime/queries/ecma/locals.scm @@ -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 ;------------ diff --git a/runtime/queries/elm/locals.scm b/runtime/queries/elm/locals.scm index ab1031156..63d31ba58 100644 --- a/runtime/queries/elm/locals.scm +++ b/runtime/queries/elm/locals.scm @@ -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) diff --git a/runtime/queries/erlang/locals.scm b/runtime/queries/erlang/locals.scm index 156e40381..ddbddb045 100644 --- a/runtime/queries/erlang/locals.scm +++ b/runtime/queries/erlang/locals.scm @@ -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 diff --git a/runtime/queries/fsharp/locals.scm b/runtime/queries/fsharp/locals.scm index db2291f26..b9b0cf1e6 100644 --- a/runtime/queries/fsharp/locals.scm +++ b/runtime/queries/fsharp/locals.scm @@ -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)))))) ]) )) diff --git a/runtime/queries/gleam/locals.scm b/runtime/queries/gleam/locals.scm index 493005739..4ae2854ce 100644 --- a/runtime/queries/gleam/locals.scm +++ b/runtime/queries/gleam/locals.scm @@ -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 diff --git a/runtime/queries/gn/locals.scm b/runtime/queries/gn/locals.scm deleted file mode 100644 index e8bd995c3..000000000 --- a/runtime/queries/gn/locals.scm +++ /dev/null @@ -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) diff --git a/runtime/queries/go/locals.scm b/runtime/queries/go/locals.scm index 14a6f3e43..305c25cd6 100644 --- a/runtime/queries/go/locals.scm +++ b/runtime/queries/go/locals.scm @@ -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 diff --git a/runtime/queries/gren/locals.scm b/runtime/queries/gren/locals.scm index ab1031156..63d31ba58 100644 --- a/runtime/queries/gren/locals.scm +++ b/runtime/queries/gren/locals.scm @@ -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) diff --git a/runtime/queries/groovy/locals.scm b/runtime/queries/groovy/locals.scm index 380c4ad64..92791b067 100644 --- a/runtime/queries/groovy/locals.scm +++ b/runtime/queries/groovy/locals.scm @@ -1,6 +1,6 @@ (function_definition) @local.scope (parameter - name: (identifier) @local.definition) + name: (identifier) @local.definition.variable.parameter) (identifier) @local.reference diff --git a/runtime/queries/hare/locals.scm b/runtime/queries/hare/locals.scm index b9e0a91b5..1cf066f47 100644 --- a/runtime/queries/hare/locals.scm +++ b/runtime/queries/hare/locals.scm @@ -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 diff --git a/runtime/queries/haskell-persistent/locals.scm b/runtime/queries/haskell-persistent/locals.scm deleted file mode 100644 index 3ffb01a17..000000000 --- a/runtime/queries/haskell-persistent/locals.scm +++ /dev/null @@ -1 +0,0 @@ -(fields (variable)) @local.definition diff --git a/runtime/queries/haskell/locals.scm b/runtime/queries/haskell/locals.scm index ad67fe43f..517d35e58 100644 --- a/runtime/queries/haskell/locals.scm +++ b/runtime/queries/haskell/locals.scm @@ -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 diff --git a/runtime/queries/inko/locals.scm b/runtime/queries/inko/locals.scm index 3266bcae0..c59acf339 100644 --- a/runtime/queries/inko/locals.scm +++ b/runtime/queries/inko/locals.scm @@ -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 diff --git a/runtime/queries/jq/locals.scm b/runtime/queries/jq/locals.scm index 40946e7c3..fefcce8f2 100644 --- a/runtime/queries/jq/locals.scm +++ b/runtime/queries/jq/locals.scm @@ -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 diff --git a/runtime/queries/julia/locals.scm b/runtime/queries/julia/locals.scm index bbf72c0e2..b587e7316 100644 --- a/runtime/queries/julia/locals.scm +++ b/runtime/queries/julia/locals.scm @@ -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 diff --git a/runtime/queries/just/locals.scm b/runtime/queries/just/locals.scm index d612f5da4..f7498b749 100644 --- a/runtime/queries/just/locals.scm +++ b/runtime/queries/just/locals.scm @@ -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 diff --git a/runtime/queries/koka/locals.scm b/runtime/queries/koka/locals.scm index f8a83e0cb..e654f70c0 100644 --- a/runtime/queries/koka/locals.scm +++ b/runtime/queries/koka/locals.scm @@ -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) diff --git a/runtime/queries/kotlin/locals.scm b/runtime/queries/kotlin/locals.scm index 752ed995e..8c85cdcd9 100644 --- a/runtime/queries/kotlin/locals.scm +++ b/runtime/queries/kotlin/locals.scm @@ -8,7 +8,7 @@ ; Definitions (type_parameter - (type_identifier) @local.definition) + (type_identifier) @local.definition.type.parameter) ; References diff --git a/runtime/queries/koto/locals.scm b/runtime/queries/koto/locals.scm index 1886b1886..8b5bd9cb7 100644 --- a/runtime/queries/koto/locals.scm +++ b/runtime/queries/koto/locals.scm @@ -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 diff --git a/runtime/queries/llvm/locals.scm b/runtime/queries/llvm/locals.scm index 1946c2871..f2e46bddd 100644 --- a/runtime/queries/llvm/locals.scm +++ b/runtime/queries/llvm/locals.scm @@ -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 diff --git a/runtime/queries/matlab/locals.scm b/runtime/queries/matlab/locals.scm index d0589a1db..882d98187 100644 --- a/runtime/queries/matlab/locals.scm +++ b/runtime/queries/matlab/locals.scm @@ -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 diff --git a/runtime/queries/ocaml/locals.scm b/runtime/queries/ocaml/locals.scm index 8f3f3fdf6..b2b890493 100644 --- a/runtime/queries/ocaml/locals.scm +++ b/runtime/queries/ocaml/locals.scm @@ -16,7 +16,7 @@ ; Definitions ;------------ -(value_pattern) @local.definition +(value_pattern) @local.definition.variable.parameter ; References ;----------- diff --git a/runtime/queries/ponylang/locals.scm b/runtime/queries/ponylang/locals.scm index e9efd69e7..bf6a5ed24 100644 --- a/runtime/queries/ponylang/locals.scm +++ b/runtime/queries/ponylang/locals.scm @@ -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 ( diff --git a/runtime/queries/purescript/locals.scm b/runtime/queries/purescript/locals.scm index ad67fe43f..517d35e58 100644 --- a/runtime/queries/purescript/locals.scm +++ b/runtime/queries/purescript/locals.scm @@ -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 diff --git a/runtime/queries/python/locals.scm b/runtime/queries/python/locals.scm index f7d5937e9..000a3e49f 100644 --- a/runtime/queries/python/locals.scm +++ b/runtime/queries/python/locals.scm @@ -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 diff --git a/runtime/queries/r/locals.scm b/runtime/queries/r/locals.scm index be6cc6379..ddfd09e60 100644 --- a/runtime/queries/r/locals.scm +++ b/runtime/queries/r/locals.scm @@ -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 diff --git a/runtime/queries/rescript/locals.scm b/runtime/queries/rescript/locals.scm deleted file mode 100644 index 4de73890e..000000000 --- a/runtime/queries/rescript/locals.scm +++ /dev/null @@ -1,7 +0,0 @@ -(switch_expression) @local.scope - -; Definitions -;------------ -(type_declaration) @local.definition -(let_binding) @local.definition -(module_declaration) @local.definition diff --git a/runtime/queries/ruby/locals.scm b/runtime/queries/ruby/locals.scm index 393caafd9..2da5401b9 100644 --- a/runtime/queries/ruby/locals.scm +++ b/runtime/queries/ruby/locals.scm @@ -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) diff --git a/runtime/queries/rust/locals.scm b/runtime/queries/rust/locals.scm index cb75d1557..7958ef04d 100644 --- a/runtime/queries/rust/locals.scm +++ b/runtime/queries/rust/locals.scm @@ -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 diff --git a/runtime/queries/scala/locals.scm b/runtime/queries/scala/locals.scm index 8eaa75ec3..60368f6c0 100644 --- a/runtime/queries/scala/locals.scm +++ b/runtime/queries/scala/locals.scm @@ -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 diff --git a/runtime/queries/smali/locals.scm b/runtime/queries/smali/locals.scm index 343694901..2b2aef272 100644 --- a/runtime/queries/smali/locals.scm +++ b/runtime/queries/smali/locals.scm @@ -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 diff --git a/runtime/queries/solidity/locals.scm b/runtime/queries/solidity/locals.scm index ac8b62a39..69ee8ab99 100644 --- a/runtime/queries/solidity/locals.scm +++ b/runtime/queries/solidity/locals.scm @@ -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 diff --git a/runtime/queries/sway/locals.scm b/runtime/queries/sway/locals.scm index 262d609e9..2ee16c487 100644 --- a/runtime/queries/sway/locals.scm +++ b/runtime/queries/sway/locals.scm @@ -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 diff --git a/runtime/queries/swift/locals.scm b/runtime/queries/swift/locals.scm index 31bc9abf1..597748c14 100644 --- a/runtime/queries/swift/locals.scm +++ b/runtime/queries/swift/locals.scm @@ -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 [ diff --git a/runtime/queries/tact/locals.scm b/runtime/queries/tact/locals.scm index f7a4115a7..5a7e565e6 100644 --- a/runtime/queries/tact/locals.scm +++ b/runtime/queries/tact/locals.scm @@ -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 ; ----------------------------- diff --git a/runtime/queries/teal/locals.scm b/runtime/queries/teal/locals.scm index 879aa71c1..e6463932d 100644 --- a/runtime/queries/teal/locals.scm +++ b/runtime/queries/teal/locals.scm @@ -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 diff --git a/runtime/queries/tera/locals.scm b/runtime/queries/tera/locals.scm index 04b09cb00..9743064b1 100644 --- a/runtime/queries/tera/locals.scm +++ b/runtime/queries/tera/locals.scm @@ -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 diff --git a/runtime/queries/thrift/locals.scm b/runtime/queries/thrift/locals.scm index 538b49962..9c4a74400 100644 --- a/runtime/queries/thrift/locals.scm +++ b/runtime/queries/thrift/locals.scm @@ -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 diff --git a/runtime/queries/tlaplus/locals.scm b/runtime/queries/tlaplus/locals.scm index aee8d612b..89a9f984f 100644 --- a/runtime/queries/tlaplus/locals.scm +++ b/runtime/queries/tlaplus/locals.scm @@ -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 diff --git a/runtime/queries/verilog/locals.scm b/runtime/queries/verilog/locals.scm index 507ddea44..83b7bcfa3 100644 --- a/runtime/queries/verilog/locals.scm +++ b/runtime/queries/verilog/locals.scm @@ -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 diff --git a/runtime/queries/wren/locals.scm b/runtime/queries/wren/locals.scm index 38f39d913..ba3a1de59 100644 --- a/runtime/queries/wren/locals.scm +++ b/runtime/queries/wren/locals.scm @@ -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 diff --git a/runtime/queries/yara/locals.scm b/runtime/queries/yara/locals.scm index 16f8768a0..7a4814dfa 100644 --- a/runtime/queries/yara/locals.scm +++ b/runtime/queries/yara/locals.scm @@ -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)