(stmt: o.IfStmt, ctx: EmitterVisitorContext)
| 268 | } |
| 269 | |
| 270 | visitIfStmt(stmt: o.IfStmt, ctx: EmitterVisitorContext): void { |
| 271 | this.printLeadingComments(stmt, ctx); |
| 272 | ctx.print(stmt, `if (`); |
| 273 | this.lastIfCondition = stmt.condition; // We can skip redundant parentheses for the condition. |
| 274 | stmt.condition.visitExpression(this, ctx); |
| 275 | this.lastIfCondition = null; |
| 276 | ctx.print(stmt, `) {`); |
| 277 | const hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0; |
| 278 | if (stmt.trueCase.length <= 1 && !hasElseCase) { |
| 279 | ctx.print(stmt, ` `); |
| 280 | this.visitAllStatements(stmt.trueCase, ctx); |
| 281 | ctx.removeEmptyLastLine(); |
| 282 | ctx.print(stmt, ` `); |
| 283 | } else { |
| 284 | ctx.println(); |
| 285 | ctx.incIndent(); |
| 286 | this.visitAllStatements(stmt.trueCase, ctx); |
| 287 | ctx.decIndent(); |
| 288 | if (hasElseCase) { |
| 289 | ctx.println(stmt, `} else {`); |
| 290 | ctx.incIndent(); |
| 291 | this.visitAllStatements(stmt.falseCase, ctx); |
| 292 | ctx.decIndent(); |
| 293 | } |
| 294 | } |
| 295 | ctx.println(stmt, `}`); |
| 296 | } |
| 297 | |
| 298 | visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): void { |
| 299 | const varKind = stmt.hasModifier(o.StmtModifier.Final) ? 'const' : 'let'; |
nothing calls this directly
no test coverage detected