TreeSitter::Query
Inherits Reference / Object
A query consists of one or more patterns, where each pattern is an S-expression that matches a certain set of nodes in a syntax tree. The expression to match a given node consists of a pair of parentheses containing two things: the node’s type, and optionally, a series of other S-expressions that match the node’s children.
Constructors
new(language : Language, source : String)
Create a new query from a string containing one or more S-expression patterns. The query is associated with a particular language, and can only be run on syntax nodes parsed with that language.
If all of the given patterns are valid, this returns a Query.
If a pattern is invalid, this raises an Error exception that provides two pieces
of information about the problem:
- The byte offset of the error.
- The type of error.
Instance methods
capture_count
Sourcepattern_count
Sourcestring_count
Source