From 36b7af36ef75b290eaf0bc6c93ecdf56553c9c07 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 31 May 2026 11:00:49 -0400 Subject: [PATCH] queries: Capture name within definition patterns in tags.scm queries --- runtime/queries/erlang/tags.scm | 39 ++++++++++++++++--------------- runtime/queries/markdown/tags.scm | 2 +- runtime/queries/rust/tags.scm | 20 ++++++++-------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/runtime/queries/erlang/tags.scm b/runtime/queries/erlang/tags.scm index d9d7f0d6..6d90f7cb 100644 --- a/runtime/queries/erlang/tags.scm +++ b/runtime/queries/erlang/tags.scm @@ -1,18 +1,19 @@ ; Modules -(attribute +((attribute name: (atom) @_attr - (arguments (atom) @definition.module) + (arguments (atom) @name)) @definition.module (#eq? @_attr "module")) ; Constants ((attribute name: (atom) @_attr - (arguments - . - [ - (atom) @definition.constant - (call function: [(variable) (atom)] @definition.macro) - ])) + (arguments . (atom) @name)) @definition.constant + (#eq? @_attr "define")) + +; Macros (with arguments) +((attribute + name: (atom) @_attr + (arguments . (call function: [(variable) (atom)] @name))) @definition.macro (#eq? @_attr "define")) ; Record definitions @@ -20,37 +21,37 @@ name: (atom) @_attr (arguments . - (atom) @definition.struct)) + (atom) @name)) @definition.struct (#eq? @_attr "record")) -(attribute +((attribute name: (atom) @_attr (arguments . [(atom) (macro)] ; Record name [ ; Just the field name: - (tuple (atom)? @definition.field) + (tuple (atom)? @name) ; Field name, type OR default: (tuple (binary_operator - left: (atom) @definition.field + left: (atom) @name operator: ["=" "::"])) ; Field name, type AND default: (tuple (binary_operator left: (binary_operator - left: (atom) @definition.field + left: (atom) @name operator: "=") operator: "::")) - ]) + ])) @definition.field (#eq? @_attr "record")) ; Function specs ((attribute name: (atom) @_attr - (stab_clause name: (atom) @definition.interface)) + (stab_clause name: (atom) @name)) @definition.interface (#any-of? @_attr "spec" "callback")) ; Types @@ -59,11 +60,11 @@ (arguments (binary_operator left: [ - (atom) @definition.type - (call function: (atom) @definition.type) + (atom) @name + (call function: (atom) @name) ] - operator: "::"))) + operator: "::"))) @definition.type (#any-of? @_attr "type" "opaque")) ; Functions -(function_clause name: (atom) @definition.function) +(function_clause name: (atom) @name) @definition.function diff --git a/runtime/queries/markdown/tags.scm b/runtime/queries/markdown/tags.scm index 6cf4d955..5232dbb5 100644 --- a/runtime/queries/markdown/tags.scm +++ b/runtime/queries/markdown/tags.scm @@ -1 +1 @@ -(atx_heading) @definition.section +(atx_heading (inline) @name) @definition.section diff --git a/runtime/queries/rust/tags.scm b/runtime/queries/rust/tags.scm index cad37733..9770252e 100644 --- a/runtime/queries/rust/tags.scm +++ b/runtime/queries/rust/tags.scm @@ -1,29 +1,29 @@ (struct_item - name: (type_identifier) @definition.struct) + name: (type_identifier) @name) @definition.struct (const_item - name: (identifier) @definition.constant) + name: (identifier) @name) @definition.constant (trait_item - name: (type_identifier) @definition.interface) + name: (type_identifier) @name) @definition.interface (function_item - name: (identifier) @definition.function) + name: (identifier) @name) @definition.function (function_signature_item - name: (identifier) @definition.function) + name: (identifier) @name) @definition.function (enum_item - name: (type_identifier) @definition.enum) + name: (type_identifier) @name) @definition.enum (enum_variant - name: (identifier) @definition.struct) + name: (identifier) @name) @definition.struct (type_item - name: (type_identifier) @definition.type) + name: (type_identifier) @name) @definition.type (mod_item - name: (identifier) @definition.module) + name: (identifier) @name) @definition.module (macro_definition - name: (identifier) @definition.macro) + name: (identifier) @name) @definition.macro -- 2.51.2