/** * The canonical layout of a file, line by line. * * `language.md` 3.13 states the rules; this applies them. The two halves are * separate because the specification is what another implementation writes a * formatter from, and a rule that lived only here would be a rule only this * formatter has. * * ## What is preserved, and why that is the safe direction * * The writer's line breaks are kept. A formatter that joined a call spanning * four lines into one would be correct and unusable: it would take the layout * somebody chose to make a long argument list readable and hand back a line * nobody can read. So this decides indentation and spacing, which have one right * answer, and leaves the choice of where to break a long statement to the person * writing it, which does not. * * It is also the safe direction. A break that was there before is a break the * lexer already accepted, so preserving them cannot turn a legal file into an * illegal one, while inventing or removing one can: a statement continues onto * the next line only under the three conditions of 3.11, and a formatter that * moved a break would have to know them, which is the language's rule * implemented twice. * * ## Comments * * A comment on a line of its own takes the indentation of the next line that * carries a token, so a commented-out statement sits with the block it belongs * to. This is safe for a reason worth stating: such a line produces no token at * all, so its indentation says nothing about block structure and cannot open or * close one (3.10). A comment after code stays where it is, two spaces clear of * the code. */ import type { SourceFile, Token } from '../core/index.js'; import type { Highlight } from './scan.js'; import type { Shapes } from './spacing.js'; /** * The whole file, laid out. * * The pieces are the covering scan, which is where the comments come from and * where a line continuation backslash is found. A backslash is kept wherever it * was written rather than worked out again: whether a statement needs one is the * lexer's rule, and the file in front of this one has already been through the * lexer with it in place. */ export declare function layOut(file: SourceFile, tokens: readonly Token[], pieces: readonly Highlight[], shapes: Shapes): string; //# sourceMappingURL=layout.d.ts.map