ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
264 lines (263 loc) • 11.7 kB
TypeScript
import * as ts from "typescript";
import { Constructor } from "./../../Constructor";
import { ClassDeclarationStructure, InterfaceDeclarationStructure, TypeAliasDeclarationStructure, FunctionDeclarationStructure, EnumDeclarationStructure, NamespaceDeclarationStructure } from "./../../structures";
import { Node } from "./../common";
import * as classes from "./../class";
import * as enums from "./../enum";
import * as functions from "./../function";
import * as interfaces from "./../interface";
import * as namespaces from "./../namespace";
import * as types from "./../type";
import * as variable from "./../variable";
export declare type StatementedNodeExtensionType = Node<ts.SourceFile | ts.FunctionDeclaration | ts.ModuleDeclaration | ts.FunctionLikeDeclaration>;
export interface StatementedNode {
/**
* Adds an class declaration as a child.
* @param structure - Structure of the class declaration to add.
*/
addClass(structure: ClassDeclarationStructure): classes.ClassDeclaration;
/**
* Adds class declarations as a child.
* @param structures - Structures of the class declarations to add.
*/
addClasses(structures: ClassDeclarationStructure[]): classes.ClassDeclaration[];
/**
* Inserts an class declaration as a child.
* @param index - Index to insert at.
* @param structure - Structure of the class declaration to insert.
*/
insertClass(index: number, structure: ClassDeclarationStructure): classes.ClassDeclaration;
/**
* Inserts class declarations as a child.
* @param index - Index to insert at.
* @param structures - Structures of the class declarations to insert.
*/
insertClasses(index: number, structures: ClassDeclarationStructure[]): classes.ClassDeclaration[];
/**
* Gets the direct class declaration children.
*/
getClasses(): classes.ClassDeclaration[];
/**
* Gets a class.
* @param name - Name of the class.
*/
getClass(name: string): classes.ClassDeclaration | undefined;
/**
* Gets a class.
* @param findFunction - Function to use to find the class.
*/
getClass(findFunction: (declaration: classes.ClassDeclaration) => boolean): classes.ClassDeclaration | undefined;
/**
* Adds an enum declaration as a child.
* @param structure - Structure of the enum declaration to add.
*/
addEnum(structure: EnumDeclarationStructure): enums.EnumDeclaration;
/**
* Adds enum declarations as a child.
* @param structures - Structures of the enum declarations to add.
*/
addEnums(structures: EnumDeclarationStructure[]): enums.EnumDeclaration[];
/**
* Inserts an enum declaration as a child.
* @param index - Index to insert at.
* @param structure - Structure of the enum declaration to insert.
*/
insertEnum(index: number, structure: EnumDeclarationStructure): enums.EnumDeclaration;
/**
* Inserts enum declarations as a child.
* @param index - Index to insert at.
* @param structures - Structures of the enum declarations to insert.
*/
insertEnums(index: number, structures: EnumDeclarationStructure[]): enums.EnumDeclaration[];
/**
* Gets the direct enum declaration children.
*/
getEnums(): enums.EnumDeclaration[];
/**
* Gets an enum.
* @param name - Name of the enum.
*/
getEnum(name: string): enums.EnumDeclaration | undefined;
/**
* Gets an enum.
* @param findFunction - Function to use to find the enum.
*/
getEnum(findFunction: (declaration: enums.EnumDeclaration) => boolean): enums.EnumDeclaration | undefined;
/**
* Adds a function declaration as a child.
* @param structure - Structure of the function declaration to add.
*/
addFunction(structure: FunctionDeclarationStructure): functions.FunctionDeclaration;
/**
* Adds function declarations as a child.
* @param structures - Structures of the function declarations to add.
*/
addFunctions(structures: FunctionDeclarationStructure[]): functions.FunctionDeclaration[];
/**
* Inserts an function declaration as a child.
* @param index - Index to insert at.
* @param structure - Structure of the function declaration to insert.
*/
insertFunction(index: number, structure: FunctionDeclarationStructure): functions.FunctionDeclaration;
/**
* Inserts function declarations as a child.
* @param index - Index to insert at.
* @param structures - Structures of the function declarations to insert.
*/
insertFunctions(index: number, structures: FunctionDeclarationStructure[]): functions.FunctionDeclaration[];
/**
* Gets the direct function declaration children.
*/
getFunctions(): functions.FunctionDeclaration[];
/**
* Gets a function.
* @param name - Name of the function.
*/
getFunction(name: string): functions.FunctionDeclaration | undefined;
/**
* Gets a function.
* @param findFunction - Function to use to find the function.
*/
getFunction(findFunction: (declaration: functions.FunctionDeclaration) => boolean): functions.FunctionDeclaration | undefined;
/**
* Adds a interface declaration as a child.
* @param structure - Structure of the interface declaration to add.
*/
addInterface(structure: InterfaceDeclarationStructure): interfaces.InterfaceDeclaration;
/**
* Adds interface declarations as a child.
* @param structures - Structures of the interface declarations to add.
*/
addInterfaces(structures: InterfaceDeclarationStructure[]): interfaces.InterfaceDeclaration[];
/**
* Inserts an interface declaration as a child.
* @param index - Index to insert at.
* @param structure - Structure of the interface declaration to insert.
*/
insertInterface(index: number, structure: InterfaceDeclarationStructure): interfaces.InterfaceDeclaration;
/**
* Inserts interface declarations as a child.
* @param index - Index to insert at.
* @param structures - Structures of the interface declarations to insert.
*/
insertInterfaces(index: number, structures: InterfaceDeclarationStructure[]): interfaces.InterfaceDeclaration[];
/**
* Gets the direct interface declaration children.
*/
getInterfaces(): interfaces.InterfaceDeclaration[];
/**
* Gets an interface.
* @param name - Name of the interface.
*/
getInterface(name: string): interfaces.InterfaceDeclaration | undefined;
/**
* Gets an interface.
* @param findFunction - Function to use to find the interface.
*/
getInterface(findFunction: (declaration: interfaces.InterfaceDeclaration) => boolean): interfaces.InterfaceDeclaration | undefined;
/**
* Adds a namespace declaration as a child.
* @param structure - Structure of the namespace declaration to add.
*/
addNamespace(structure: NamespaceDeclarationStructure): namespaces.NamespaceDeclaration;
/**
* Adds namespace declarations as a child.
* @param structures - Structures of the namespace declarations to add.
*/
addNamespaces(structures: NamespaceDeclarationStructure[]): namespaces.NamespaceDeclaration[];
/**
* Inserts an namespace declaration as a child.
* @param index - Index to insert at.
* @param structure - Structure of the namespace declaration to insert.
*/
insertNamespace(index: number, structure: NamespaceDeclarationStructure): namespaces.NamespaceDeclaration;
/**
* Inserts namespace declarations as a child.
* @param index - Index to insert at.
* @param structures - Structures of the namespace declarations to insert.
*/
insertNamespaces(index: number, structures: NamespaceDeclarationStructure[]): namespaces.NamespaceDeclaration[];
/**
* Gets the direct namespace declaration children.
*/
getNamespaces(): namespaces.NamespaceDeclaration[];
/**
* Gets a namespace.
* @param name - Name of the namespace.
*/
getNamespace(name: string): namespaces.NamespaceDeclaration | undefined;
/**
* Gets a namespace.
* @param findFunction - Function to use to find the namespace.
*/
getNamespace(findFunction: (declaration: namespaces.NamespaceDeclaration) => boolean): namespaces.NamespaceDeclaration | undefined;
/**
* Adds a type alias declaration as a child.
* @param structure - Structure of the type alias declaration to add.
*/
addTypeAlias(structure: TypeAliasDeclarationStructure): types.TypeAliasDeclaration;
/**
* Adds type alias declarations as a child.
* @param structures - Structures of the type alias declarations to add.
*/
addTypeAliases(structures: TypeAliasDeclarationStructure[]): types.TypeAliasDeclaration[];
/**
* Inserts an type alias declaration as a child.
* @param index - Index to insert at.
* @param structure - Structure of the type alias declaration to insert.
*/
insertTypeAlias(index: number, structure: TypeAliasDeclarationStructure): types.TypeAliasDeclaration;
/**
* Inserts type alias declarations as a child.
* @param index - Index to insert at.
* @param structures - Structures of the type alias declarations to insert.
*/
insertTypeAliases(index: number, structures: TypeAliasDeclarationStructure[]): types.TypeAliasDeclaration[];
/**
* Gets the direct type alias declaration children.
*/
getTypeAliases(): types.TypeAliasDeclaration[];
/**
* Gets a type alias.
* @param name - Name of the type alias.
*/
getTypeAlias(name: string): types.TypeAliasDeclaration | undefined;
/**
* Gets a type alias.
* @param findFunction - Function to use to find the type alias.
*/
getTypeAlias(findFunction: (declaration: types.TypeAliasDeclaration) => boolean): types.TypeAliasDeclaration | undefined;
/**
* Gets the direct variable statement children.
*/
getVariableStatements(): variable.VariableStatement[];
/**
* Gets a variable statement.
* @param findFunction - Function to use to find the variable statement.
*/
getVariableStatement(findFunction: (declaration: variable.VariableStatement) => boolean): variable.VariableStatement | undefined;
/**
* Gets the variable declaration lists of the direct variable statement children.
*/
getVariableDeclarationLists(): variable.VariableDeclarationList[];
/**
* Gets a variable declaration list.
* @param findFunction - Function to use to find the variable declaration list.
*/
getVariableDeclarationList(findFunction: (declaration: variable.VariableDeclarationList) => boolean): variable.VariableDeclarationList | undefined;
/**
* Gets all the variable declarations within all the variable declarations of the direct variable statement children.
*/
getVariableDeclarations(): variable.VariableDeclaration[];
/**
* Gets a variable declaration.
* @param name - Name of the variable declaration.
*/
getVariableDeclaration(name: string): variable.VariableDeclaration | undefined;
/**
* Gets a variable declaration.
* @param findFunction - Function to use to find the variable declaration.
*/
getVariableDeclaration(findFunction: (declaration: variable.VariableDeclaration) => boolean): variable.VariableDeclaration | undefined;
}
export declare function StatementedNode<T extends Constructor<StatementedNodeExtensionType>>(Base: T): Constructor<StatementedNode> & T;