unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Question on getting tree-sitter matches
@ 2023-03-12 14:32 Abin Simon
  2023-03-13  2:34 ` Yuan Fu
  0 siblings, 1 reply; 10+ messages in thread
From: Abin Simon @ 2023-03-12 14:32 UTC (permalink / raw)
  To: emacs-devel

Hey,

How would I get the set of matches from tree-sitter with items from the
same query together.

For example if I have a query of the following form:

    (function_declaration (identifier) @id) @func

elisp-tree-sitter returns this as the output of `tsc-query-matches`:

    [(0 . [
           (func . #<user-ptr ptr=0x4f7fa40 finalizer=0x7f2173b15780>)
           (id . #<user-ptr ptr=0x4f7fa00 finalizer=0x7f2173b15780>)
          ]
     )
     (0 . [
           (func . #<user-ptr ptr=0x10043a0 finalizer=0x7f2173b15780>)
           (id . #<user-ptr ptr=0x7b9a660 finalizer=0x7f2173b15780>)
          ]
     )
    ]


This groups the matches from the same "query" together.

I could only find `treesit-query-capture` which just returns a list of
captures items in the following form:

    (
     (func . #<treesit-node function_declaration in 441-791>)
     (id . #<treesit-node identifier in 446-460>)
     (func . #<treesit-node function_declaration in 865-1052>)
     (id . #<treesit-node identifier in 870-888>)
    )



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-03-21  3:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-12 14:32 Question on getting tree-sitter matches Abin Simon
2023-03-13  2:34 ` Yuan Fu
2023-03-13  3:29   ` Abin Simon
2023-03-14 23:31     ` Yuan Fu
2023-03-15  4:24       ` Abin Simon
2023-03-19 21:59         ` Yuan Fu
2023-03-20  4:09           ` Abin Simon
2023-03-20 20:27           ` Ergus
2023-03-20 23:25             ` Yuan Fu
2023-03-21  3:29               ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).