final class TriviaReader
Restricted visibility: declared "@visibility SqlSemantics". Code outside that scope must not name this declaration.

Reads the comments out of the whitespace and comments a lexer skipped.

Languages differ in how a block comment ends. Some nest block comments. Some have executable comments: a block comment opened by ! and a version number whose body the lexer reads as SQL when the number does not exceed the parsed release, so its opening and closing delimiters are found apart from each other; an ordinary block comment in such a language steps over /* pairs and nests only an executable comment. The rest end at the first * /. Whether the reader is inside an executable comment carries from one run of trivia to the next until a tree has been read.

Methods§

public function __construct(
    private bool $nestedBlocks = false,
    private int|null $executableVersion = null,
)

Parameters

$nestedBlocksboolWhether a block comment inside a block comment must close before the outer one
$executableVersionint|nullThe highest version number of an executable comment the lexer reads as SQL, or null when the language has none
public function comments(string $trivia): list<string>

Splits one run of trivia into its comments, in order, without their surrounding whitespace.

Parameters

$triviastring

Returns

list<string>

Throws

LogicException When the trivia holds text that is not a comment
Test cases 3
Called from 2
Calls 5
public function commentEnd(string $trivia, int $offset): int

Finds where the comment at an offset ends, entering or leaving an executable comment on the way.

Parameters

$triviastring
$offsetint

Returns

int

Throws

LogicException When the offset does not start a comment
Test cases 1
Called from 1
Calls 6
public function blockEnd(string $trivia, int $start): int

Finds the offset just past the block comment that starts at an offset, or the end of the trivia when it never closes.

Parameters

$triviastring
$startint

Returns

int
Test cases 1
Called from 1
Calls 3

Private surface 3§

Implementation details, listed for orientation only.

private bool $executable = false
private bool $nestedBlocks = false
private int|null $executableVersion = null

Test cases 10§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 7
Other tests reaching this symbol 3

Relations§

Instantiated in 4
Method calls 2
Type declarations 2