import { ClassReference } from "../ast/ClassReference"; import { IWriter, IAstNode } from "@amplication/ast-types"; /** * Configuration interface for the Writer class. * Defines the settings used to initialize a Writer instance. * * @interface WriterConfig */ export interface WriterConfig { /** The package name for the generated Java code */ packageName: string; /** Whether to skip the package declaration in the output */ skipPackageDeclaration?: boolean; } /** * The Writer class is responsible for writing Java code with proper formatting. * It handles indentation, imports, and provides utility methods for writing code. * This class is the core component for generating properly formatted Java source code. * * @class * @implements {IWriter} */ export declare class Writer implements IWriter { private indentLevel; private buffer; private imports; private references; private packageName; private skipPackageDeclaration; /** * Creates a new Writer instance with the specified configuration. * * @param {WriterConfig} config - The configuration for the writer */ constructor(config: WriterConfig); /** * Increases the current indentation level by one. * Used for proper code formatting. */ indent(): void; /** * Decreases the current indentation level by one. * Used for proper code formatting. */ dedent(): void; /** * Writes text to the buffer without adding a new line. * * @param {string} text - The text to write */ write(text: string): void; /** * Writes a line of text to the buffer with proper indentation. * If no text is provided, only writes a new line. * * @param {string} [text] - The text to write (optional) */ writeLine(text?: string): void; /** * Adds a new line to the buffer. */ newLine(): void; /** * Adds a new line to the buffer only if the last character isn't already a new line. * This prevents multiple consecutive empty lines. */ writeNewLineIfLastLineNot(): void; /** * Adds a class reference to be imported. * References from the same package are not added. * * @param {ClassReference} reference - The class reference to add */ addReference(reference: ClassReference): void; /** * Adds an import statement to the list of imports. * * @param {string} importName - The full import path */ addImport(importName: string): void; /** * Writes an AST node to the buffer. * * @param {IAstNode} node - The AST node to write */ writeNode(node: IAstNode): void; /** * Gets the current indentation as a string. * * @private * @returns {string} The indentation string */ private getIndentation; /** * Generates the final Java code with imports and package declaration. * * @returns {string} The complete Java code as a string */ toString(): string; /** * Formats the output code to have consistent spacing. * * @param {string} code - The code to format * @returns {string} The formatted code */ formatCode(code: string): string; }