UNPKG

rawsql-ts

Version:

High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

29 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractLexemeComments = extractLexemeComments; // Extracts positioned comments from a lexeme while preserving order and duplicates. function extractLexemeComments(lexeme) { const before = []; const after = []; if (!lexeme) { return { before, after }; } if (lexeme.positionedComments && lexeme.positionedComments.length > 0) { for (const positioned of lexeme.positionedComments) { if (!positioned.comments || positioned.comments.length === 0) { continue; } if (positioned.position === "before") { before.push(...positioned.comments); } else if (positioned.position === "after") { after.push(...positioned.comments); } } } else if (lexeme.comments && lexeme.comments.length > 0) { before.push(...lexeme.comments); } return { before, after }; } //# sourceMappingURL=LexemeCommentUtils.js.map