-
My title might not be quite accurate to what I want as I'm new to tree-sitter, but essentially I am trying to match all parameter types in one capture, for example in the following C code: Color ColorAlpha(Color c, float n) {
return c;
} I'd like to match (function_definition
type: (_) @return_type
declarator: (function_declarator
declarator: (identifier) @function_name
parameters: (parameter_list
(parameter_declaration
type: (_)* @parameter_type
)
)
)
)
) This will return 2 matches, one with:
and the other with:
Is there a way for me to write a query where only a single match is made, with both of the parameter types in one capture? Currently I get all the matches, and then merge them by name and return type, but I was wondering if there was a simpler way to do this. So far, I've tried various usages of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Fix the query like the next: (function_definition
type: (_) @return_type
declarator: (function_declarator
declarator: (identifier) @function_name
parameters: (parameter_list
(
(parameter_declaration
type: _ @parameter_type
)
","?
)*
)
)
) |
Beta Was this translation helpful? Give feedback.
Fix the query like the next: