MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / printFunctionExpression

Method printFunctionExpression

src/LuaPrinter.ts:664–689  ·  view source on GitHub ↗
(expression: lua.FunctionExpression)

Source from the content-addressed store, hash-verified

662 }
663
664 public printFunctionExpression(expression: lua.FunctionExpression): SourceNode {
665 const chunks: SourceChunk[] = [];
666
667 chunks.push("function(");
668 chunks.push(...this.printFunctionParameters(expression));
669 chunks.push(")");
670
671 if (lua.isInlineFunctionExpression(expression)) {
672 const returnStatement = expression.body.statements[0];
673 chunks.push(" ");
674 const returnNode: SourceChunk[] = [
675 "return ",
676 ...this.joinChunksWithComma(returnStatement.expressions.map(e => this.printExpression(e))),
677 ];
678 chunks.push(this.createSourceNode(returnStatement, returnNode));
679 chunks.push(this.createSourceNode(expression, " end"));
680 } else {
681 chunks.push("\n");
682 this.pushIndent();
683 chunks.push(this.printBlock(expression.body));
684 this.popIndent();
685 chunks.push(this.indent(this.createSourceNode(expression, "end")));
686 }
687
688 return this.createSourceNode(expression, chunks);
689 }
690
691 public printFunctionDefinition(statement: lua.FunctionDefinition): SourceNode {
692 const expression = statement.right[0];

Callers 1

printExpressionMethod · 0.95

Calls 8

joinChunksWithCommaMethod · 0.95
printExpressionMethod · 0.95
createSourceNodeMethod · 0.95
pushIndentMethod · 0.95
printBlockMethod · 0.95
popIndentMethod · 0.95
indentMethod · 0.95

Tested by

no test coverage detected