(statement: lua.IfStatement, isElseIf = false)
| 459 | } |
| 460 | |
| 461 | public printIfStatement(statement: lua.IfStatement, isElseIf = false): SourceNode { |
| 462 | const chunks: SourceChunk[] = []; |
| 463 | |
| 464 | const prefix = isElseIf ? "elseif" : "if"; |
| 465 | chunks.push(this.indent(prefix + " "), this.printExpression(statement.condition), " then\n"); |
| 466 | |
| 467 | this.pushIndent(); |
| 468 | chunks.push(this.printBlock(statement.ifBlock)); |
| 469 | this.popIndent(); |
| 470 | |
| 471 | if (statement.elseBlock) { |
| 472 | if (lua.isIfStatement(statement.elseBlock)) { |
| 473 | chunks.push(this.printIfStatement(statement.elseBlock, true)); |
| 474 | } else { |
| 475 | chunks.push(this.indent("else\n")); |
| 476 | this.pushIndent(); |
| 477 | chunks.push(this.printBlock(statement.elseBlock)); |
| 478 | this.popIndent(); |
| 479 | chunks.push(this.indent("end")); |
| 480 | } |
| 481 | } else { |
| 482 | chunks.push(this.indent("end")); |
| 483 | } |
| 484 | |
| 485 | return this.concatNodes(...chunks); |
| 486 | } |
| 487 | |
| 488 | public printWhileStatement(statement: lua.WhileStatement): SourceNode { |
| 489 | const chunks: SourceChunk[] = []; |
no test coverage detected