/** * @file 单SQL语句格式化入口 * @author 天一 */ import { FormatOptions } from '../FormatOptions.js'; import Params from './Params.js'; import { AstNode } from '../parser/ast.js'; import Layout from './Layout.js'; interface ExpressionFormatterParams { cfg: FormatOptions; dialectCfg: ProcessedDialectFormatOptions; params: Params; layout: Layout; inline?: boolean; escapeOperatorSpace?: number; forceOneline?: number; } export interface DialectFormatOptions { alwaysDenseOperators?: string[]; onelineClauses: string[]; preserveClauses?: string[]; } export interface ProcessedDialectFormatOptions { alwaysDenseOperators: string[]; onelineClauses: Record; preserveClauses: Record; } /** Formats a generic SQL expression */ export default class ExpressionFormatter { private cfg; private dialectCfg; private params; private layout; private inline; private nodes; private index; private escapeOperatorSpace; private forceOneline; constructor({ cfg, dialectCfg, params, layout, inline, escapeOperatorSpace, forceOneline }: ExpressionFormatterParams); format(nodes: AstNode[]): Layout; private formatNode; private formatNodeWithoutComments; private formatFunctionCall; private formatArraySubscript; private formatPropertyAccess; private formatParenthesis; private formatBetweenPredicate; private formatCaseExpression; private formatCaseWhen; private formatCaseElse; private formatClause; private isOnelineClause; private isPreserveClause; private formatClauseInIndentedStyle; private formatClauseInOnelineStyle; private formatClauseInPreserveStyle; private formatClauseInTabularStyle; private formatSetOperation; private formatLimitClause; private formatAllColumnsAsterisk; private formatLiteral; private formatIdentifier; private formatParameter; private formatOperator; private formatComma; private withComments; private formatComments; private formatLineComment; private formatBlockComment; private isMultilineBlockComment; private splitBlockComment; private formatSubExpression; private formatInlineExpression; private formatKeywordNode; private formatJoin; private formatKeyword; private formatLogicalOperator; private showKw; private showNonTabularKw; private isTabularNewlineKeyword; } export {};