tree-sitter / tree-sitter-go

Go grammar for tree-sitter
MIT License
317 stars 63 forks source link

Query with multiple variable identifiers (var + const) #142

Closed matansha closed 3 months ago

matansha commented 6 months ago

Hi,

I trying to query all the variables in my program, but it seems when we have multiple variables in var or const it's not catch them.

For example from tree sitter playground:

image

It seems we have multiple fields in the same name (name) that enforce me to create N queries for N variable name declarations.

Thanks!

amaanq commented 6 months ago

use name: (_)+ - https://tree-sitter.github.io/tree-sitter/using-parsers#quantification-operators

matansha commented 6 months ago

As you can see it didn't works

image

Also, in many other languages, i didn't saw same fields like we got here

amaanq commented 6 months ago

oh - yeah that doesn't work because the field seems to include the commas too - and (_) will match any named nodes, not these commas. this should be fixed since commas are not a name

matansha commented 6 months ago

Do you have any time estimation when it going to be fixed? Also, why not replace the multiple "name" with identifiers_list like the expression_list