UNPKG

ts-budgie

Version:

Converts TypeScript code to Budgie.

69 lines (68 loc) 2.48 kB
import { CaseStyleConverterBag, NameSplitter } from "budgie"; import * as tsutils from "tsutils"; import * as ts from "typescript"; import { BudgieLine } from "../output/budgieLine"; import { Transformation } from "../output/transformation"; import { RootAliaser } from "../parsing/aliasers/rootAliaser"; import { TransformationsPrinter } from "../printing/transformationsPrinter"; import { VisitorContext } from "./context"; import { VisitorCreatorsBag } from "./visitorCreatorsBag"; export interface INodeVisitRouterDependencies { aliaser: RootAliaser; casing: CaseStyleConverterBag; printer: TransformationsPrinter; nameSplitter: NameSplitter; sourceFile: ts.SourceFile; typeChecker: ts.TypeChecker; variableUsage: Map<ts.Identifier, tsutils.VariableInfo>; visitorContext: VisitorContext; visitorCreatorsBag: VisitorCreatorsBag; } /** * Routes visitors for node types. */ export declare class NodeVisitRouter { /** * Dependencies used for initialization. */ private readonly dependencies; /** * Lazily creates visitors for node types. */ private readonly visitorsBag; /** * Initializes a new instance of the NodeVisitRouter. * * @param dependencies Dependencies to be used for initialization. */ constructor(dependencies: INodeVisitRouterDependencies); /** * Retrieves the output transformations for a node. * * @param node Node to retrieve transformations for. * @returns Output transformations for the node. */ recurseIntoNode(node: ts.Node): Transformation[]; /** * Retrieves the Budgie output for a set of nodes. * * @param node Node to transform. * @param parent Common parent of the nodes. * @returns Transformed Budgie output for the nodes. */ recurseIntoNodes(nodes: ReadonlyArray<ts.Node>): Transformation[]; /** * Retrieves the Budgie output for an inline value. * * @param node Node to transform. * @returns Transformed Budgie output for the inline value. */ recurseIntoValue(node: ts.Node): string | BudgieLine; /** * Retrieves the Budgie output for a set of inline values. * * @param nodes Nodes to transform. * @returns Transformed Budgie output for the inline values. */ recurseIntoValues(nodes: ts.NodeArray<ts.Node>): (string | BudgieLine)[]; }