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 a symbolic expression (S-expression) that matches a certain set of nodes in an abstract syntax tree. Each 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. Query instances are immutable and can be safely shared among threads.- Since:
- 1.0.0
- Author:
- Ozren Dabić
- See Also:
- Query Syntax
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQuery.Builder
-
Constructor Summary
Constructors Constructor Description Query(@NotNull Language language, @NotNull String pattern)Deprecated, for removal: This API element is subject to removal in a future version.UsegetFor(Language, String)orbuilder()instead
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Query.Builderbuilder()Obtain a new builder for constructing a Query instance.voidclose()Delete the external resource, freeing all the memory that it used.intcountCaptures()Deprecated, for removal: This API element is subject to removal in a future version.Just get dedicated collection, and computesize()intcountPatterns()Deprecated, for removal: This API element is subject to removal in a future version.Just get dedicated collection, and computesize()intcountStrings()Deprecated, for removal: This API element is subject to removal in a future version.Just get dedicated collection, and computesize()booleanequals(Object obj)StringgetCaptureName(@NotNull Object ignored)Deprecated, for removal: This API element is subject to removal in a future version.Should not be used anymorestatic QuerygetFor(@NotNull Language language, @NotNull String pattern)Static factory for obtaining new Query instances.StringgetPattern()Returns a concatenated, possibly non-rooted symbolic expression consisting of the individual query patterns.booleanhasCaptures()inthashCode()booleanisNull()StringtoString()
-
-
-
Constructor Detail
-
Query
@Deprecated(since="1.7.0", forRemoval=true) public Query(@NotNull @NotNull Language language, @NotNull @NotNull String pattern)
Deprecated, for removal: This API element is subject to removal in a future version.UsegetFor(Language, String)orbuilder()instead
-
-
Method Detail
-
getFor
public static Query getFor(@NotNull @NotNull Language language, @NotNull @NotNull String pattern)
Static factory for obtaining new Query instances.- Parameters:
language- The language for queryingpattern- The query pattern- Returns:
- A new query instance
- Since:
- 1.7.0
-
builder
public static Query.Builder builder()
Obtain a new builder for constructing a Query instance.- Returns:
- a new query builder
- Since:
- 1.7.0
-
countStrings
@Deprecated(since="1.7.0", forRemoval=true) public int countStrings()
Deprecated, for removal: This API element is subject to removal in a future version.Just get dedicated collection, and computesize()
-
countCaptures
@Deprecated(since="1.7.0", forRemoval=true) public int countCaptures()
Deprecated, for removal: This API element is subject to removal in a future version.Just get dedicated collection, and computesize()
-
countPatterns
@Deprecated(since="1.7.0", forRemoval=true) public int countPatterns()
Deprecated, for removal: This API element is subject to removal in a future version.Just get dedicated collection, and computesize()
-
getCaptureName
@Deprecated(since="1.7.0", forRemoval=true) public String getCaptureName(@NotNull @NotNull Object ignored)
Deprecated, for removal: This API element is subject to removal in a future version.Should not be used anymore- See Also:
QueryMatch
-
hasCaptures
public boolean hasCaptures()
- Returns:
- true if the query has captures, false otherwise
-
getPattern
public String getPattern()
Returns a concatenated, possibly non-rooted symbolic expression consisting of the individual query patterns.- Returns:
- the full query s-expression
-
isNull
public final boolean isNull()
-
close
public void close()
Delete the external resource, freeing all the memory that it used.- Specified by:
closein interfaceAutoCloseable
-
-