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

Method _consumeExpansion

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

Source from the content-addressed store, hash-verified

204 }
205
206 private _consumeExpansion(token: ExpansionFormStartToken) {
207 const switchValue = this._advance<TextToken>();
208
209 const type = this._advance<TextToken>();
210 const cases: html.ExpansionCase[] = [];
211
212 // read =
213 while (this._peek.type === TokenType.EXPANSION_CASE_VALUE) {
214 const expCase = this._parseExpansionCase();
215 if (!expCase) return; // error
216 cases.push(expCase);
217 }
218
219 // read the final }
220 if (this._peek.type !== TokenType.EXPANSION_FORM_END) {
221 this.errors.push(
222 TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '}'.`),
223 );
224 return;
225 }
226 const sourceSpan = new ParseSourceSpan(
227 token.sourceSpan.start,
228 this._peek.sourceSpan.end,
229 token.sourceSpan.fullStart,
230 );
231 this._addToParent(
232 new html.Expansion(
233 switchValue.parts[0],
234 type.parts[0],
235 cases,
236 sourceSpan,
237 switchValue.sourceSpan,
238 ),
239 );
240
241 this._advance();
242 }
243
244 private _parseExpansionCase(): html.ExpansionCase | null {
245 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