emacs-devel
[Top][All Lists]
Advanced

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

Re: Question on getting tree-sitter matches


From: Yuan Fu
Subject: Re: Question on getting tree-sitter matches
Date: Sun, 12 Mar 2023 19:34:59 -0700


> On Mar 12, 2023, at 7:32 AM, Abin Simon <mail@meain.io> wrote:
> 
> 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>)
>    )
> 

Unfortunately, that’s currently not possible. Could you elaborate on why you 
need such feature?

Thanks,
Yuan




reply via email to

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