Package ch.usi.si.seart.treesitter
Class Query
- java.lang.Object
-
- ch.usi.si.seart.treesitter.Query
-
- All Implemented Interfaces:
AutoCloseable
public class Query extends 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 query is associated with a particular language, and can only be run on syntax nodes parsed with that language. 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. For example, this pattern would match anybinary_expressionnode whose children are bothnumber_literalnodes:(binary_expression (number_literal) (number_literal))Children can also be omitted. For example, this would match anybinary_expressionwhere at least one of child is astring_literalnode:(binary_expression (string_literal))The underlying query value is immutable and can be safely shared between threads.- Since:
- 1.0.0
- Author:
- Ozren Dabić
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Delete the query, freeing all the memory that it used.intcountCaptures()intcountPatterns()intcountStrings()booleanequals(Object obj)StringgetCaptureName(@NotNull QueryCapture capture)booleanhasCaptures()inthashCode()booleanisNull()StringtoString()
-
-
-
Method Detail
-
close
public void close()
Delete the query, freeing all the memory that it used.- Specified by:
closein interfaceAutoCloseable
-
countStrings
public int countStrings()
- Returns:
- The number of string literals in this query
-
countCaptures
public int countCaptures()
- Returns:
- The number of captures in this query
-
countPatterns
public int countPatterns()
- Returns:
- The number of patterns in this query
-
getCaptureName
public String getCaptureName(@NotNull @NotNull QueryCapture capture)
- Parameters:
capture- The query capture- Returns:
- The name of the provided query captures
-
hasCaptures
public boolean hasCaptures()
- Returns:
- true if the query has captures, false otherwise
-
isNull
public final boolean isNull()
-
-