classCanonical
final class Canonical
Reads the spelling a node has when it is rendered without a layout of its own.
Rule: CORE-SPELLING-001 (SQLite part). A layout is kept only where it differs from this spelling, so that a node rendered without a layout reads back without one, and a layout always records a spelling the rendering would not produce by itself. Layouts nested in the node keep their effect, as they do when the node is rendered. The trivia after a region belongs to its spelling only when it holds a comment: SQLite drops the whitespace at the end of a span (sqlite3DbSpanDup() in malloc.c), so whitespace alone spells nothing. Status: Implemented.
Constants§
public const SPACE = " \t\n\v\f\r"The characters SQLite treats as whitespace (sqlite3Isspace()).
Methods§
Answers the layout of the text a node renders to: its pieces with the gaps the lexical writer puts between them.
Parameters
$node | Node |
Returns
Test cases 2
Called from 3
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\ResultRule::column() packages/sql-semantics-sqlite/src/Lowering/Query/ResultRule.php:89
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::span() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:73
- method-call SqlSemantics\Platform\Sqlite\Statement\Query\ResultColumn::__construct() packages/sql-semantics-sqlite/src/Statement/Query/ResultColumn.php:52
public function trail(string $trivia): stringAnswers the part of the trivia after a region that its spelling keeps: all of it when it holds a comment, nothing when it is whitespace alone.
Parameters
$trivia | string |
Returns
stringTest cases 1
Called from 2
Calls 2
- function-call
rtrimline 56 - class-const Canonical::SPACE() line 56
public function span(Layout $layout): stringAnswers the text a region of a layout names: its tokens and the trivia after them, without the whitespace at the end.
Parameters
$layout | Layout |
Returns
stringTest cases 1
Called from 1
Calls 3
- function-call
rtrimline 64 - method-call Layout::text() line 64
- class-const Canonical::SPACE() line 64
Tells whether two layouts spell the same tokens with the same gaps and the same trivia after them.
Returns
boolTest cases 1
Called from 2
Calls 1
- function-call
countline 72
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
CanonicalTest::testLayoutKeepsTheLayoutsNestedInTheNodecallsCanonicalTest::testLayoutSpellsTheRenderedPiecesWithTheirGapscallsCanonicalTest::testSameComparesTheTokensAndTheGapsAfterTheFirstcallsCanonicalTest::testSpanEndsBeforeTheWhitespaceAfterTheLastCommentcallsCanonicalTest::testTrailKeepsTheTriviaOnlyWhenItHoldsACommentcalls
Relations§
Instantiated in 6
- new SqlSemantics\Platform\Sqlite\Lowering\Query\ResultRule::column() packages/sql-semantics-sqlite/src/Lowering/Query/ResultRule.php:87
- new SqlSemantics\Platform\Sqlite\Lowering\Query\ResultRule::column() packages/sql-semantics-sqlite/src/Lowering/Query/ResultRule.php:89
- new SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::span() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:73
- new SqlSemantics\Platform\Sqlite\Statement\Query\ResultColumn::__construct() packages/sql-semantics-sqlite/src/Statement/Query/ResultColumn.php:52
- new SqlSemantics\Platform\Sqlite\Statement\Query\ResultColumn::__construct() packages/sql-semantics-sqlite/src/Statement/Query/ResultColumn.php:54
- new SqlSemantics\Platform\Sqlite\Statement\Query\ResultColumn::__construct() packages/sql-semantics-sqlite/src/Statement/Query/ResultColumn.php:55
Method calls 8
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\ResultRule::column() packages/sql-semantics-sqlite/src/Lowering/Query/ResultRule.php:87
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\ResultRule::column() packages/sql-semantics-sqlite/src/Lowering/Query/ResultRule.php:89
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\ResultRule::column() packages/sql-semantics-sqlite/src/Lowering/Query/ResultRule.php:89
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::span() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:73
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::span() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:73
- method-call SqlSemantics\Platform\Sqlite\Statement\Query\ResultColumn::__construct() packages/sql-semantics-sqlite/src/Statement/Query/ResultColumn.php:52
- method-call SqlSemantics\Platform\Sqlite\Statement\Query\ResultColumn::__construct() packages/sql-semantics-sqlite/src/Statement/Query/ResultColumn.php:54
- method-call SqlSemantics\Platform\Sqlite\Statement\Query\ResultColumn::__construct() packages/sql-semantics-sqlite/src/Statement/Query/ResultColumn.php:55