prettier-sql
Version:
Format whitespace in a SQL query to make it more readable
36 lines (35 loc) • 1.26 kB
TypeScript
import { Token } from './token';
/**
* Bookkeeper for inline blocks.
*
* Inline blocks are parenthesised expressions that are shorter than INLINE_MAX_LENGTH.
* These blocks are formatted on a single line, unlike longer parenthesised
* expressions where open-parenthesis causes newline and increase of indentation.
*/
export default class InlineBlock {
level: number;
lineWidth: number;
constructor(lineWidth: number);
/**
* Begins inline block when lookahead through upcoming tokens determines
* that the block would be smaller than INLINE_MAX_LENGTH.
* @param {Token[]} tokens Array of all tokens
* @param {Number} index Current token position
*/
beginIfPossible(tokens: Token[], index: number): void;
/**
* Finishes current inline block.
* There might be several nested ones.
*/
end(): void;
/**
* True when inside an inline block
*/
isActive(): boolean;
/**
* Check if this should be an inline parentheses block
* Examples are "NOW()", "COUNT(*)", "int(10)", key(`somecolumn`), DECIMAL(7,2)
*/
isInlineBlock(tokens: Token[], index: number): boolean;
isForbiddenToken({ type, value }: Token): boolean;
}