import { J } from "../java"; /** * Gets the effective last whitespace from a Space. * When there are comments, the last whitespace is the suffix of the last comment. * When there are no comments, it's the whitespace property. */ export declare function lastWhitespace(space: J.Space): string; /** * Replaces the effective last whitespace in a Space using a transform function. * When there are comments, updates the suffix of the last comment. * When there are no comments, updates the whitespace property. * * @param space The Space to modify (Mutative draft) * @param transform Function that receives the current last whitespace and returns the new value */ export declare function replaceLastWhitespace(space: J.Space, transform: (ws: string) => string): J.Space; /** * Strips leading spaces and tabs from a string (but not newlines). */ export declare function stripLeadingIndent(s: string): string; /** * Replaces the indentation after the last newline in a whitespace string. * If there's no newline, returns just the new indent. */ export declare function replaceIndentAfterLastNewline(ws: string, newIndent: string): string; /** * Checks if a Space contains any newlines (in whitespace or comment suffixes). */ export declare function spaceContainsNewline(space: J.Space | undefined): boolean; /** * Normalizes indentation in an entire Space: whitespace and comment suffixes take the target * indent, and the interior lines of a multi-line comment shift with it, so they stay aligned with * the opening delimiter that the surrounding whitespace positions. * * @param space The Space to normalize * @param targetIndent The indentation to use after newlines * @returns The normalized Space, or the original if unchanged */ export declare function normalizeSpaceIndent(space: J.Space, targetIndent: string): J.Space; /** * Handles element removal from lists while preserving LST formatting. * Automatically applies prefixes from removed elements to the next kept element, * handling whitespace and comment preservation. * * @example * const formatter = new ElementRemovalFormatter(); * * for (const stmt of statements) { * if (shouldRemove(stmt)) { * formatter.markRemoved(stmt.element); * continue; * } * const adjusted = formatter.processKept(stmt.element); * filteredList.push({...stmt, element: adjusted}); * } * * if (formatter.hasRemovals) { * // Apply the filtered list * } */ export declare class ElementRemovalFormatter { private readonly preserveFirstElementComments; private lastRemoved?; private keptCount; private removedCount; /** * @param preserveFirstElementComments Whether to preserve comments from the first removed element. * Set to true for imports (to preserve file headers). Defaults to false. */ constructor(preserveFirstElementComments?: boolean); /** * Returns true if any elements have been marked as removed. */ get hasRemovals(): boolean; /** * Mark an element as removed. Only the first consecutive removed element is tracked. */ markRemoved(elem: T): void; /** * Process a kept element, applying prefix from any previously removed element if needed. */ processKept(elem: T): T; } //# sourceMappingURL=formatting-utils.d.ts.map