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

Method _consumeExpansion

packages/compiler/src/ml_parser/parser.ts:195–231  ·  view source on GitHub ↗
(token: ExpansionFormStartToken)

Source from the content-addressed store, hash-verified

193 }
194
195 private _consumeExpansion(token: ExpansionFormStartToken) {
196 const switchValue = this._advance<TextToken>();
197
198 const type = this._advance<TextToken>();
199 const cases: html.ExpansionCase[] = [];
200
201 // read =
202 while (this._peek.type === TokenType.EXPANSION_CASE_VALUE) {
203 const expCase = this._parseExpansionCase();
204 if (!expCase) return; // error
205 cases.push(expCase);
206 }
207
208 // read the final }
209 if (this._peek.type !== TokenType.EXPANSION_FORM_END) {
210 this.errors.push(
211 TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '}'.`),
212 );
213 return;
214 }
215 const sourceSpan = new ParseSourceSpan(
216 token.sourceSpan.start,
217 this._peek.sourceSpan.end,
218 token.sourceSpan.fullStart,
219 );
220 this._addToParent(
221 new html.Expansion(
222 switchValue.parts[0],
223 type.parts[0],
224 cases,
225 sourceSpan,
226 switchValue.sourceSpan,
227 ),
228 );
229
230 this._advance();
231 }
232
233 private _parseExpansionCase(): html.ExpansionCase | null {
234 const value = this._advance<ExpansionCaseValueToken>();

Callers 1

buildMethod · 0.95

Calls 5

_advanceMethod · 0.95
_parseExpansionCaseMethod · 0.95
_addToParentMethod · 0.95
createMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected