Caveats and known limitations
Parenthesis in queries
Due to a limitation of how the syntax is parsed, to use ( or ) in a query you must wrap the argument with a double quote " so that the parser does not confuse it for a list boundary. For example, to search for the string (c):
clojure
(str "(c)")Rust: Macro invocations are not semantically parsed
Tree-sitter's Rust grammar does not semantically parse the contents of macro invocations. Instead, the macro body is represented as a token_tree containing raw tokens (identifiers, literals, punctuation) without semantic structure.
For example, Foo::A is parsed differently depending on context:
rust
test(Foo::A); // scoped_identifier { path: "Foo", name: "A" }
eprintln!("{}", Foo::A); // token_tree { identifier "Foo", identifier "A" }This means structural selectors like (enum Foo A) will match Foo::A in regular code but not inside macro invocations.
Workaround: Use (:text) to match patterns inside macros:
clojure
;; Match Foo::A only inside macros
(:and (:text /Foo::A/) (:kind "token_tree"))
;; Match Foo::A everywhere (both inside and outside macros)
(:or (enum Foo A) (:and (:text /Foo::A/) (:kind "token_tree")))