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

Function icuStart

packages/core/src/render3/i18n/i18n_parse.ts:571–632  ·  view source on GitHub ↗

* Generate the OpCodes for ICU expressions. * * @param icuExpression * @param index Index where the anchor is stored and an optional `TIcuContainerNode` * - `lView[anchorIdx]` points to a `Comment` node representing the anchor for the ICU. * - `tView.data[anchorIdx]` points to the `TIcuCont

(
  ast: I18nNode[],
  tView: TView,
  lView: LView,
  updateOpCodes: I18nUpdateOpCodes,
  parentIdx: number,
  icuExpression: IcuExpression,
  anchorIdx: number,
)

Source from the content-addressed store, hash-verified

569 * - `tView.data[anchorIdx]` points to the `TIcuContainerNode` if ICU is root (`null` otherwise)
570 */
571function icuStart(
572 ast: I18nNode[],
573 tView: TView,
574 lView: LView,
575 updateOpCodes: I18nUpdateOpCodes,
576 parentIdx: number,
577 icuExpression: IcuExpression,
578 anchorIdx: number,
579) {
580 ngDevMode && assertDefined(icuExpression, 'ICU expression must be defined');
581 let bindingMask = 0;
582 const tIcu: TIcu = {
583 type: icuExpression.type,
584 currentCaseLViewIndex: allocExpando(tView, lView, 1, null),
585 anchorIdx,
586 cases: [],
587 create: [],
588 remove: [],
589 update: [],
590 };
591 addUpdateIcuSwitch(updateOpCodes, icuExpression, anchorIdx);
592 setTIcu(tView, anchorIdx, tIcu);
593 const values = icuExpression.values;
594 const cases: I18nNode[][] = [];
595 for (let i = 0; i < values.length; i++) {
596 // Each value is an array of strings & other ICU expressions
597 const valueArr = values[i];
598 const nestedIcus: IcuExpression[] = [];
599 for (let j = 0; j < valueArr.length; j++) {
600 const value = valueArr[j];
601 if (typeof value !== 'string') {
602 // It is an nested ICU expression
603 const icuIndex = nestedIcus.push(value as IcuExpression) - 1;
604 // Replace nested ICU expression by a comment node
605 valueArr[j] = `<!--�${icuIndex}�-->`;
606 }
607 }
608 const caseAst: I18nNode[] = [];
609 cases.push(caseAst);
610 bindingMask =
611 parseIcuCase(
612 caseAst,
613 tView,
614 tIcu,
615 lView,
616 updateOpCodes,
617 parentIdx,
618 icuExpression.cases[i],
619 valueArr.join(''),
620 nestedIcus,
621 ) | bindingMask;
622 }
623 if (bindingMask) {
624 addUpdateIcuUpdate(updateOpCodes, bindingMask, anchorIdx);
625 }
626 ast.push({
627 kind: I18nNodeKind.ICU,
628 index: anchorIdx,

Callers 2

i18nStartFirstCreatePassFunction · 0.85
walkIcuTreeFunction · 0.85

Calls 8

assertDefinedFunction · 0.90
allocExpandoFunction · 0.90
setTIcuFunction · 0.90
addUpdateIcuSwitchFunction · 0.85
parseIcuCaseFunction · 0.85
addUpdateIcuUpdateFunction · 0.85
joinMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…