(file: lua.File)
| 227 | } |
| 228 | |
| 229 | protected printFile(file: lua.File): SourceNode { |
| 230 | let sourceChunks: SourceChunk[] = [file.trivia]; |
| 231 | |
| 232 | if (!this.options.noHeader) { |
| 233 | sourceChunks.push(tstlHeader); |
| 234 | } |
| 235 | |
| 236 | const luaTarget = this.options.luaTarget ?? LuaTarget.Universal; |
| 237 | const luaLibImport = this.options.luaLibImport ?? LuaLibImportKind.Require; |
| 238 | if ( |
| 239 | (luaLibImport === LuaLibImportKind.Require || luaLibImport === LuaLibImportKind.RequireMinimal) && |
| 240 | file.luaLibFeatures.size > 0 |
| 241 | ) { |
| 242 | // Import lualib features |
| 243 | sourceChunks = this.printStatementArray( |
| 244 | loadImportedLualibFeatures(file.luaLibFeatures, luaTarget, this.emitHost) |
| 245 | ); |
| 246 | } else if (luaLibImport === LuaLibImportKind.Inline && file.luaLibFeatures.size > 0) { |
| 247 | // Inline lualib features |
| 248 | sourceChunks.push("-- Lua Library inline imports\n"); |
| 249 | sourceChunks.push(loadInlineLualibFeatures(file.luaLibFeatures, luaTarget, this.emitHost)); |
| 250 | sourceChunks.push("-- End of Lua Library inline imports\n"); |
| 251 | } |
| 252 | |
| 253 | if (this.options.sourceMapTraceback && !isBundleEnabled(this.options)) { |
| 254 | // In bundle mode the traceback is being generated for the entire file in getBundleResult |
| 255 | // Otherwise, traceback is being generated locally |
| 256 | sourceChunks.push(`${LuaPrinter.sourceMapTracebackPlaceholder}\n`); |
| 257 | } |
| 258 | |
| 259 | // Print reest of the statements in file |
| 260 | sourceChunks.push(...this.printStatementArray(file.statements)); |
| 261 | |
| 262 | return this.concatNodes(...sourceChunks); |
| 263 | } |
| 264 | |
| 265 | protected pushIndent(): void { |
| 266 | this.currentIndent += " "; |
no test coverage detected