File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,17 @@ import { Printer } from "./LuaPrinter";
22import { Visitors } from "./transformation/context" ;
33
44export interface Plugin {
5- printer ?: Printer ;
5+ /**
6+ * An augmentation to the map of visitors that transform TypeScript AST to Lua AST.
7+ *
8+ * Key is a `SyntaxKind` of a processed node.
9+ */
610 visitors ?: Visitors ;
11+
12+ /**
13+ * A function that converts Lua AST to a string.
14+ *
15+ * Only one plugin can provide `printer`.
16+ */
17+ printer ?: Printer ;
718}
Original file line number Diff line number Diff line change @@ -145,8 +145,20 @@ export type VisitorResult<T extends ts.Node> = T extends ExpressionLikeNode
145145 ? lua . Block
146146 : OneToManyVisitorResult < lua . Node > ;
147147
148- export type FunctionVisitor < T extends ts . Node > = ( node : T , context : TransformationContext ) => VisitorResult < T > ;
149- export type ObjectVisitor < T extends ts . Node > = { transform : FunctionVisitor < T > ; priority ?: number } ;
150148export type Visitor < T extends ts . Node > = FunctionVisitor < T > | ObjectVisitor < T > ;
149+ export type FunctionVisitor < T extends ts . Node > = ( node : T , context : TransformationContext ) => VisitorResult < T > ;
150+ export type ObjectVisitor < T extends ts . Node > = {
151+ transform : FunctionVisitor < T > ;
152+
153+ /**
154+ * Visitors with higher priority are called first.
155+ *
156+ * Higher-priority visitors can call lower ones with `context.superTransformNode`.
157+ *
158+ * Standard visitors have the lowest (`-Infinity`) priority.
159+ */
160+ priority ?: number ;
161+ } ;
162+
151163export type Visitors = { [ P in keyof NodesBySyntaxKind ] ?: Visitor < NodesBySyntaxKind [ P ] > } ;
152164export type VisitorMap = Map < ts . SyntaxKind , Array < ObjectVisitor < ts . Node > > > ;
You can’t perform that action at this time.
0 commit comments