import { IFormatterBase } from "./i-formatter"; import { BindingName, Block, CallExpression, ClassDeclaration, ClassElement, ConstructorDeclaration, Decorator, Expression, ExpressionWithTypeArguments, GetAccessorDeclaration, HeritageClause, Identifier, ImportClause, ImportDeclaration, KeywordTypeNode, MethodDeclaration, Modifier, ModifiersArray, NamedExports, NamedImports, NamespaceImport, Node, NodeArray, ParameterDeclaration, PropertyDeclaration, SetAccessorDeclaration, Statement, StringLiteral, SyntaxKind, Token, TypeNode, TypeParameterDeclaration } from "typescript"; import { IParser } from "../parser/i-parser"; import { ClassElementCtor } from "../light-ast/ctor/class-element/class-element-ctor"; import { HeritageCtor, IExtendsHeritageCtor, IImplementsHeritageCtor } from "../light-ast/ctor/heritage/i-heritage-ctor"; import { IClassCtor } from "../light-ast/ctor/class/i-class-ctor"; import { IConstructorCtor } from "../light-ast/ctor/constructor/i-constructor-ctor"; import { IClassPropertyCtor } from "../light-ast/ctor/class-property/i-class-property-ctor"; import { IMethodCtor } from "../light-ast/ctor/method/i-method-ctor"; import { IClassMethodCtor } from "../light-ast/ctor/class-method/i-class-method-ctor"; import { ClassAccessorCtor, IClassGetAccessorCtor, IClassSetAccessorCtor } from "../light-ast/ctor/class-accessor/class-accessor-ctor"; import { AccessorCtor, IGetAccessorCtor, ISetAccessorCtor } from "../light-ast/ctor/accessor/accessor-ctor"; import { IImportClauseCtor } from "../light-ast/ctor/import-clause/i-import-clause-ctor"; import { IImportCtor } from "../light-ast/ctor/import/i-import-ctor"; import { INamedImportExportCtor } from "../light-ast/ctor/named-import-export/i-named-import-export-ctor"; import { IParameterCtor } from "../light-ast/ctor/parameter/i-parameter-ctor"; import { BindingNameCtor } from "../light-ast/ctor/binding-name/binding-name-ctor"; import { IDecoratorCtor } from "../light-ast/ctor/decorator/i-decorator-ctor"; import { IAllModifiersCtor } from "../light-ast/ctor/modifier/i-all-modifiers-ctor"; import { INameWithTypeArguments } from "../light-ast/dict/name-with-type-arguments/i-name-with-type-arguments"; import { ModifierKind } from "../light-ast/dict/modifier/modifier-kind"; import { ICallExpressionCtor } from "../light-ast/ctor/call-expression/i-call-expression-ctor"; /** * A class that helps with transforming simple ctor-objects into Typescript Nodes */ export declare class Formatter implements IFormatterBase { private readonly parseService; constructor(parseService: IParser); /** * Formats a CallExpression from the provided ICallExpressionCtor * @param {ICallExpressionCtor} callExpression * @returns {ts.CallExpression} */ formatCallExpression(callExpression: ICallExpressionCtor): CallExpression; /** * Formats a NodeArray from the provided Iterable * @param {Iterable?} nodes * @returns {NodeArray} */ formatNodeArray(nodes?: Iterable | undefined): NodeArray; /** * Formats an 'undefined' KeywordTypeNode * @returns {KeywordTypeNode} */ formatUndefined(): KeywordTypeNode; /** * Formats a ClassElement * @param {ClassElementCtor} member * @returns {ClassElement} */ formatClassElement(member: ClassElementCtor): ClassElement; /** * Formats an Iterable of ClassElementCtors * @param {Iterable} members * @returns {NodeArray} */ formatClassElements(members: Iterable): NodeArray; /** * Formats the provided HeritageClause * @param {HeritageCtor} clause * @returns {HeritageClause} */ formatHeritageClause(clause: HeritageCtor): HeritageClause; /** * Formats all of the provided HeritageClauses * @param {Iterable} clauses * @returns {NodeArray} */ formatHeritageClauses(clauses: Iterable): NodeArray; /** * Formats an ExpressionWithTypeArguments * @param {string} name * @param {Iterable} typeArguments * @returns {ExpressionWithTypeArguments} */ formatExpressionWithTypeArguments({ name, typeArguments }: INameWithTypeArguments): ExpressionWithTypeArguments; /** * Creates a Heritage Clause for an extends relation * @param {INameWithTypeArguments} extend * @returns {HeritageClause} */ formatExtendsHeritageClause({ name, typeArguments }: IExtendsHeritageCtor): HeritageClause; /** * Formats the provided 'implements' heritage clause * @param {INameWithTypeArguments[]} elements * @returns {HeritageClause} */ formatImplementsHeritageClause({ elements }: IImplementsHeritageCtor): HeritageClause; /** * Creates an Identifier from the provided name * @param {string} name * @returns {Identifier} */ formatIdentifier(name: string): Identifier; /** * Formats a ClassDeclaration * @param {boolean} isAbstract * @param {IImplementsHeritageCtor} implementsInterfaces * @param {Iterable} decorators * @param {string} name * @param {IExtendsHeritageCtor} extendsClass * @param {Iterable} members * @param {Iterable} typeParameters * @returns {ClassDeclaration} */ formatClassDeclaration({ isAbstract, implementsInterfaces, decorators, name, extendsClass, members, typeParameters }: IClassCtor): ClassDeclaration; /** * Creates a ConstructorDeclaration from the provided options * @param {string} body * @param {Iterable} parameters * @returns {ConstructorDeclaration} */ formatConstructor({ body, parameters }: IConstructorCtor): ConstructorDeclaration; /** * Creates a PropertyDeclaration from the provided options * @param {Iterable} decorators * @param {boolean} isStatic * @param {boolean} isOptional * @param {boolean} isAbstract * @param {VisibilityKind} visibility * @param {boolean} isAsync * @param {string} name * @param {string} type * @param {string} initializer * @param {boolean} isReadonly * @returns {PropertyDeclaration} */ formatClassProperty({ decorators, isStatic, isOptional, isAbstract, visibility, isAsync, name, type, initializer, isReadonly }: IClassPropertyCtor): PropertyDeclaration; /** * Creates a MethodDeclaration from the provided options * @param {Iterable} decorators * @param {string} body * @param {Iterable} typeParameters * @param {boolean} isAsync * @param {string} name * @param {Iterable} parameters * @param {string} type * @returns {ts.MethodDeclaration} */ formatMethod({ decorators, body, typeParameters, isAsync, name, parameters, type }: IMethodCtor): MethodDeclaration; /** * Formats a MethodDeclaration from the provided options * @param {Iterable} decorators * @param {string} type * @param {Iterable} parameters * @param {string} name * @param {boolean} isAsync * @param {Iterable} typeParameters * @param {string} body * @param {VisibilityKind} visibility * @param {boolean} isStatic * @param {boolean} isAbstract * @param {boolean} isOptional * @returns {MethodDeclaration} */ formatClassMethod({ decorators, type, parameters, name, isAsync, typeParameters, body, visibility, isStatic, isAbstract, isOptional }: IClassMethodCtor): MethodDeclaration; /** * Formats the provided options into a GetAccessorDeclaration or a SetAccessorDeclaration * @param {ClassAccessorCtor} accessor * @returns {GetAccessorDeclaration | SetAccessorDeclaration} */ formatClassAccessor(accessor: ClassAccessorCtor): GetAccessorDeclaration | SetAccessorDeclaration; /** * Formats a GetAccessor from the provided options * @param {Iterable} decorators * @param {boolean} isStatic * @param {boolean} isAbstract * @param {VisibilityKind} visibility * @param {string} name * @param {string} type * @param {string} body * @returns {ts.GetAccessorDeclaration} */ formatClassGetAccessor({ decorators, isStatic, isAbstract, visibility, name, type, body }: IClassGetAccessorCtor): GetAccessorDeclaration; /** * Formats the provided options into a SetAccessorDeclaration * @param {Iterable} decorators * @param {boolean} isStatic * @param {boolean} isAbstract * @param {VisibilityKind} visibility * @param {string} name * @param {string} body * @param {Iterable} parameters * @returns {SetAccessorDeclaration} */ formatClassSetAccessor({ decorators, isStatic, isAbstract, visibility, name, body, parameters }: IClassSetAccessorCtor): SetAccessorDeclaration; /** * Formats the provided options into a GetAccessorDeclaration or a SetAccessorDeclaration * @param {AccessorCtor} accessor * @returns {GetAccessorDeclaration | SetAccessorDeclaration} */ formatAccessor(accessor: AccessorCtor): GetAccessorDeclaration | SetAccessorDeclaration; /** * Formats a GetAccessor from the provided options * @param {Iterable} decorators * @param {string} type * @param {string} body * @param {string} name * @returns {GetAccessorDeclaration} */ formatGetAccessor({ decorators, type, body, name }: IGetAccessorCtor): GetAccessorDeclaration; /** * Formats the provided options into a SetAccessorDeclaration * @param {Iterable} decorators * @param {string} name * @param {string} body * @param {Iterable} parameters * @returns {SetAccessorDeclaration} */ formatSetAccessor({ decorators, name, body, parameters }: ISetAccessorCtor): SetAccessorDeclaration; /** * Formats a StringLiteral * @param {string} literal * @returns {StringLiteral} */ formatStringLiteral(literal: string): StringLiteral; /** * Formats an ImportClause * @param {Iterable} namedImports * @param {string} namespace * @param {string} defaultName * @returns {ImportClause?} */ formatImportClause({ namedImports, namespace, defaultName }: IImportClauseCtor): ImportClause | undefined; /** * Creates a new ImportDeclaration * @param {string} path * @param {Iterable} namedImports * @param {string} namespace * @param {string} defaultName * @returns {ImportDeclaration} */ formatImportDeclaration({ path, namedImports, namespace, defaultName }: IImportCtor): ImportDeclaration; /** * Creates NamedImports from all of the provided named import names * @param {INamedImportExportCtor | Iterable} namedImports * @returns {NamedImports} */ formatNamedImports(namedImports: INamedImportExportCtor | Iterable): NamedImports; /** * Creates NamedExports from all of the provided named import names * @param {INamedImportExportCtor | Iterable} namedExports * @returns {NamedExports} */ formatNamedExports(namedExports: INamedImportExportCtor | Iterable): NamedExports; /** * Creates a NamespaceImport with the provided name * @param {string} namespaceName * @returns {NamespaceImport} */ formatNamespaceImport(namespaceName: string): NamespaceImport; /** * Creates a Modifier from the provided ModifierKind * @param {ModifierKind} modifier * @returns {Modifier} */ formatModifier(modifier: ModifierKind): Modifier; /** * Formats all of the provided modifiers and returns a NodeArray of Modifiers * @param {boolean} isAbstract * @param {boolean} isAsync * @param {boolean} isStatic * @param {boolean} isReadonly * @param {boolean} isConst * @param {boolean} isExported * @param {boolean} isDeclared * @param {boolean} isDefault * @param {VisibilityKind} visibility * @returns {NodeArray} */ formatModifiers({ isAbstract, isAsync, isStatic, isReadonly, isConst, isExported, isDeclared, isDefault, visibility }: Partial): ModifiersArray; /** * Formats an expression * @param {string} expression * @returns {Expression} */ formatExpression(expression: string): Expression; /** * Formats a Statement * @param {string} statement * @returns {Expression} */ formatStatement(statement: string): Statement; /** * Formats a DotDotDotToken * @param {boolean} isRestSpread * @returns {Token} */ formatDotDotDotToken(isRestSpread: boolean): Token | undefined; /** * Formats a QuestionToken * @param {boolean} isOptional * @returns {Token} */ formatQuestionToken(isOptional: boolean): Token | undefined; /** * Generates a Decorator from the provided options * @param {IDecoratorCtor} decorator * @returns {Decorator} */ formatDecorator(decorator: IDecoratorCtor): Decorator; /** * Formats all of the provided DecoratorCtors into a NodeArray of Decorators * @param {Iterable} decorators * @returns {NodeArray} */ formatDecorators(decorators: Iterable): NodeArray; /** * Formats a BindingName from the provided BindingNameDit * @param {BindingNameCtor} name * @returns {BindingName} */ formatBindingName(name: BindingNameCtor): BindingName; /** * Generates a Parameter from the provided options * @param {INormalBindingNameCtor | IObjectBindingNameCtor | IArrayBindingNameCtor} name * @param {Iterable} decorators * @param {boolean} isRestSpread * @param {boolean} isOptional * @param {string} type * @param {string} initializer * @returns {ParameterDeclaration} */ formatParameter({ name, decorators, isRestSpread, isOptional, type, initializer }: IParameterCtor): ParameterDeclaration; /** * Formats all of the provided parameters * @param {Iterable} parameters * @returns {NodeArray} */ formatParameters(parameters: Iterable): NodeArray; /** * Creates a TypeParameterDeclaration from the provided string representation of it * @param {string} type * @returns {TypeParameterDeclaration} */ formatTypeParameter(type: string): TypeParameterDeclaration; /** * Creates a NodeArray of all the TypeParameterDeclaration expressions that are provided in the given Iterable of strings * @param {Iterable} types * @returns {NodeArray} */ formatTypeParameters(types: Iterable): NodeArray; /** * Creates a TypeNode from the provided string representation of it * @param {string} type * @returns {TypeNode} */ formatType(type: string): TypeNode; /** * Creates a NodeArray of TypeNodes from the provided Iterable of string expressions * @param {Iterable} types * @returns {NodeArray} */ formatTypes(types: Iterable): NodeArray; /** * Creates a Block from the provided string * @param {string} instructions * @returns {Block} */ formatBlock(instructions: string): Block; /** * Creates a tuple of identifiers for NamedImports. The first item is for the name, the second is for the propertyName, if any is given. * @param {INamedImportExportCtor} namedImport * @returns {[Identifier , Identifier]} */ private createNamedImportExportIdentifiers; }