From 3edf8097b3eb75f2aca80d8e55ca301558ee8fd5 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Sat, 5 Jul 2025 17:30:37 -0700 Subject: [PATCH] handle cases where function declarations have no body --- .../hole-queries/typescript.scm | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/tree-sitter/static-context-queries/hole-queries/typescript.scm b/extensions/vscode/tree-sitter/static-context-queries/hole-queries/typescript.scm index e69122b07..02de34466 100644 --- a/extensions/vscode/tree-sitter/static-context-queries/hole-queries/typescript.scm +++ b/extensions/vscode/tree-sitter/static-context-queries/hole-queries/typescript.scm @@ -21,7 +21,7 @@ (function_type return_type: (type_identifier) @return.type) -;; Capture any parse errors (e.g., the `??`) +;; Capture any parse errors (e.g., the `@`) (ERROR) @error.node ;; Capture the entire function declaration line @@ -34,3 +34,26 @@ (import_specifier name: (identifier) @import.name))) source: (string) @import.source) + +;; Capture standalone function declarations +(function_declaration + name: (identifier) @function.name) @function.decl + +;; Capture the function signature including parameters and return type +(function_declaration + parameters: (formal_parameters) @function.params + return_type: (type_annotation)? @function.type) + +;; For function expressions or arrow functions +(function_type + parameters: (formal_parameters) @function.params) @function.decl + +;; For arrow functions +(arrow_function + parameters: (formal_parameters) @function.params) @function.decl + +;; For function signatures without a body (like in your example) +(function_signature + name: (identifier) @function.name + parameters: (formal_parameters) @function.params + return_type: (type_annotation)? @function.type) @function.decl