rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
41 lines (40 loc) • 1.71 kB
TypeScript
import { FormattingLexeme } from '../models/FormattingLexeme';
/**
* Restores SQL strings from FormattingLexeme arrays while preserving original formatting
* This class handles the restoration of SQL text with exact whitespace, comments, and indentation
*/
export declare class OriginalFormatRestorer {
/**
* Restores SQL string from FormattingLexeme array preserving original formatting
* @param lexemes Array of FormattingLexeme with formatting information
* @returns Restored SQL string with original formatting preserved
*/
restore(lexemes: FormattingLexeme[]): string;
/**
* Restores SQL with inline comments preserved at their original positions
* @param lexemes Array of FormattingLexeme with formatting information
* @param includeComments Whether to include inline comments in output
* @returns Restored SQL string
*/
restoreWithComments(lexemes: FormattingLexeme[], includeComments?: boolean): string;
/**
* Extracts formatting patterns from FormattingLexemes for analysis
* @param lexemes Array of FormattingLexeme
* @returns Object containing formatting statistics
*/
analyzeFormatting(lexemes: FormattingLexeme[]): {
totalWhitespace: number;
totalComments: number;
indentationStyle: 'spaces' | 'tabs' | 'mixed' | 'none';
averageIndentSize: number;
};
/**
* Validates that lexemes contain proper formatting information
* @param lexemes Array of FormattingLexeme to validate
* @returns Validation result with details
*/
validateFormattingLexemes(lexemes: FormattingLexeme[]): {
isValid: boolean;
issues: string[];
};
}