Package ch.usi.si.seart.treesitter
Class Parser.Builder
- java.lang.Object
-
- ch.usi.si.seart.treesitter.Parser.Builder
-
- Enclosing class:
- Parser
public static class Parser.Builder extends Object
Facilitates the construction of Parser instances. It allows for the step-by-step creation of these objects by providing methods for setting individual attributes. Input validations are performed at each build step.- Since:
- 1.7.0
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Parserbuild()Builds and returns a new Parser instance with the configured language.Parser.Builderlanguage(@NotNull Language language)Sets the programming language intended for parsing.Parser.Buildertimeout(long timeout)Set the maximum duration in microseconds that parsing should be allowed to take.Parser.Buildertimeout(long timeout, @NotNull TimeUnit timeUnit)Set the maximum duration that parsing should be allowed to take.Parser.Buildertimeout(@NotNull Duration duration)Set the maximum duration that parsing should be allowed to take.
-
-
-
Method Detail
-
language
public Parser.Builder language(@NotNull @NotNull Language language)
Sets the programming language intended for parsing.- Parameters:
language- The language used for parsing- Returns:
- this builder
- Throws:
NullPointerException- if the language is nullUnsatisfiedLinkError- if the language was not linked to native codeABIVersionError- if the language ABI version is incompatible with requirements
-
timeout
public Parser.Builder timeout(@NotNull @NotNull Duration duration)
Set the maximum duration that parsing should be allowed to take. If parsing time exceeds this value, an exception is thrown. The duration is rounded down to zero if it does not exceed one microsecond. Timeouts are considered disabled when the value is zero.- Parameters:
duration- the timeout duration- Returns:
- this builder
- Throws:
NullPointerException- if the duration isnull- Since:
- 1.8.0
-
timeout
public Parser.Builder timeout(long timeout, @NotNull @NotNull TimeUnit timeUnit)
Set the maximum duration that parsing should be allowed to take. If parsing time exceeds this value, an exception is thrown. The duration is rounded down to zero if it does not exceed one microsecond. Timeouts are considered disabled when the value is zero.- Parameters:
timeout- the timeout duration amounttimeUnit- the duration time unit- Returns:
- this builder
- Throws:
NullPointerException- if the time unit isnullIllegalArgumentException- if the timeout value is negative- Since:
- 1.8.0
-
timeout
public Parser.Builder timeout(long timeout)
Set the maximum duration in microseconds that parsing should be allowed to take. If parsing time exceeds this value, an exception is thrown. Timeouts are considered disabled when the value is zero.- Parameters:
timeout- the timeout in microseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- if the timeout value is negative- Since:
- 1.8.0
-
build
public Parser build()
Builds and returns a new Parser instance with the configured language.- Returns:
- A new parser instance
- Throws:
NullPointerException- if the language was not previously setIncompatibleLanguageException- if the language can not be set
-
-