MCPcopy Create free account
hub / github.com/angular/angular / visitIfStmt

Function visitIfStmt

packages/compiler/src/output/abstract_emitter.ts:270–296  ·  view source on GitHub ↗
(stmt: o.IfStmt, ctx: EmitterVisitorContext)

Source from the content-addressed store, hash-verified

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';

Callers

nothing calls this directly

Calls 8

printLeadingCommentsMethod · 0.80
visitAllStatementsMethod · 0.80
printlnMethod · 0.80
printMethod · 0.45
visitExpressionMethod · 0.45
removeEmptyLastLineMethod · 0.45
incIndentMethod · 0.45
decIndentMethod · 0.45

Tested by

no test coverage detected