final class Layout
    uses Snapshot
Public API: explicitly declared with @visibility public.

The written spelling of a region whose spelling the database makes observable.

Rule: CORE-SPELLING-001. Some databases name an unaliased result column after the text of its expression (SQLite, MySQL). Where a database does so, the text is part of the meaning, and the model keeps it as a layout: one spelled token per token the rendering of the region produces, in order. The tokens themselves still come from the structure; a layout only chooses the trivia between them and after the last of them, and an equivalent spelling of each. Publication refuses a layout that does not align one to one with the rendered tokens, whose spellings are not the same tokens, or whose gaps are not trivia, and the rendered SQL must lower to the same structure, layout included. A layout never stands for structure, and nothing is rendered from it alone. Status: Implemented.

Reading the text a region was written asdoctest
$layout = new \SqlSemantics\Platform\Sqlite\Model\Statement\Spelling\Layout([new \SqlSemantics\Platform\Sqlite\Model\Statement\Spelling\Spelled('', '1'), new \SqlSemantics\Platform\Sqlite\Model\Statement\Spelling\Spelled('', '+'), new \SqlSemantics\Platform\Sqlite\Model\Statement\Spelling\Spelled('', '1')]);
    $layout->text() // => '1+1'

Properties§

public non-empty-list<Spelled> $tokens
public string $trail = ''

Methods§

public function __construct(list<Spelled> $tokens, public string $trail = '')

Parameters

$tokenslist<Spelled>The spelled tokens in order; at least one
$trailstringThe whitespace and comments written after the last token, before whatever follows the region
Calls 2

Test cases 17§

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

Dedicated tests 3
Other tests reaching this symbol 14

Relations§

Instantiated in 2
Method calls 1
Type declarations 6