helixbass / tree-sitter-grep

The Unlicense
10 stars 1 forks source link

Should capture_index really be a list of capture indices? #62

Open helixbass opened 1 year ago

helixbass commented 1 year ago

Thinking about this in working on tree-sitter-lint

I believe the way tree-sitter works is that you could have the same capture name in multiple places, and then the query captures API will return you all nodes that match either one of those captures (of the same name), and the capture index I'm guessing would be different depending on which "instance" of that capture name matches but they would both resolve to the same capture name?

That's definitely worth sanity-checking

But if so then I think that implies that our CaptureIndex should in fact store eg a Vec<usize> or whatever which would represent all of the capture indices corresponding to the specified/default capture name?