Skip to content

Commit 85fc1da

Browse files
committed
Added function that returns the AST and string
1 parent 88b7029 commit 85fc1da

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/LuaTranspiler.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as fs from "fs";
22
import * as path from "path";
33
import * as ts from "typescript";
44

5+
import * as tstl from "./LuaAST";
6+
57
import {CompilerOptions, LuaLibImportKind} from "./CompilerOptions";
68
import {LuaPrinter} from "./LuaPrinter";
79
import {LuaTransformer} from "./LuaTransformer";
@@ -111,6 +113,13 @@ export class LuaTranspiler {
111113
return this.luaPrinter.print(luaAST, lualibFeatureSet);
112114
}
113115

116+
public transpileSourceFileKeepAST(sourceFile: ts.SourceFile): [tstl.Block, string] {
117+
// Transform AST
118+
const [luaAST, lualibFeatureSet] = this.luaTransformer.transformSourceFile(sourceFile);
119+
// Print AST
120+
return [luaAST, this.luaPrinter.print(luaAST, lualibFeatureSet)];
121+
}
122+
114123
public reportDiagnostic(diagnostic: ts.Diagnostic): void {
115124
if (diagnostic.file) {
116125
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);

0 commit comments

Comments
 (0)