MCPcopy Index your code
hub / github.com/angular/angular / visitIfStmt

Function visitIfStmt

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

Source from the content-addressed store, hash-verified

239 }
240
241 visitIfStmt(stmt: o.IfStmt, ctx: EmitterVisitorContext): void {
242 this.printLeadingComments(stmt, ctx);
243 ctx.print(stmt, `if (`);
244 this.lastIfCondition = stmt.condition; // We can skip redundant parentheses for the condition.
245 stmt.condition.visitExpression(this, ctx);
246 this.lastIfCondition = null;
247 ctx.print(stmt, `) {`);
248 const hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0;
249 if (stmt.trueCase.length <= 1 && !hasElseCase) {
250 ctx.print(stmt, ` `);
251 this.visitAllStatements(stmt.trueCase, ctx);
252 ctx.removeEmptyLastLine();
253 ctx.print(stmt, ` `);
254 } else {
255 ctx.println();
256 ctx.incIndent();
257 this.visitAllStatements(stmt.trueCase, ctx);
258 ctx.decIndent();
259 if (hasElseCase) {
260 ctx.println(stmt, `} else {`);
261 ctx.incIndent();
262 this.visitAllStatements(stmt.falseCase, ctx);
263 ctx.decIndent();
264 }
265 }
266 ctx.println(stmt, `}`);
267 }
268
269 visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): void {
270 const varKind = stmt.hasModifier(o.StmtModifier.Final) ? 'const' : 'let';

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…