emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question on getting tree-sitter matches


From: Abin Simon
Subject: Question on getting tree-sitter matches
Date: Sun, 12 Mar 2023 20:02:18 +0530

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>)
    )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]