classTriviaRule
final class TriviaRule
Answers the whitespace and comments written after a region of a command.
Rule: SQLITE-TRIVIA-001. SQLite takes the name of an unaliased result column from the text between its first token and the start of the token that follows it (scanpt in parse.y, sqlite3ExprListSetSpan() in expr.c), so a comment written after the expression is part of the name. The trivia after a region is the leading trivia of the next token of the command; every command ends with a semicolon, which the parser supplies with the trivia at the end of the input when none is written, so a region inside a command is always followed by a token. Source: https://sqlite.org/c3ref/column_name.html. Status: Implemented.
Methods§
public function __construct()Starts without an indexed command.
Calls 1
- new
WeakMapline 39
public function index(Node $command): voidRecords the trivia after each token of a command before it is lowered.
Parameters
$command | Node |
Test cases 2
Called from 1
Calls 2
- new
WeakMapline 47 - method-call Node::tokens() line 49
public function after(Node $region): stringAnswers the trivia written between the last token of a region and the next token of its command.
Parameters
$region | Node |
Returns
stringThrows
InvariantViolation When the region is empty or its command was not indexedTest cases 4
Calls 3
- method-call Node::tokens() line 64
- static-call Check::invariant() line 65
- function-call
countline 66
Private surface 1§
Implementation details, listed for orientation only.
private WeakMap<Token, string> $followingTest cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.