Skip to content

Commit 9637b5d

Browse files
cexbrayatpkozlowski-opensource
authored andcommitted
refactor(compiler): cleanup unused code in template builder pipeline (#54654)
This removes some unused code and fixes a few typos across the pipeline code. PR Close #54654
1 parent 7ead0fc commit 9637b5d

17 files changed

Lines changed: 22 additions & 66 deletions

packages/compiler/src/template/pipeline/ir/src/enums.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,6 @@ export enum ExpressionKind {
360360
*/
361361
ReadTemporaryExpr,
362362

363-
/**
364-
* An expression representing a sanitizer function.
365-
*/
366-
SanitizerExpr,
367-
368-
/**
369-
* An expression representing a function to create trusted values.
370-
*/
371-
TrustedValueFnExpr,
372-
373363
/**
374364
* An expression that will cause a literal slot index to be emitted.
375365
*/
@@ -380,12 +370,6 @@ export enum ExpressionKind {
380370
*/
381371
ConditionalCase,
382372

383-
/**
384-
* A variable for use inside a repeater, providing one of the ambiently-available context
385-
* properties ($even, $first, etc.).
386-
*/
387-
DerivedRepeaterVar,
388-
389373
/**
390374
* An expression that will be automatically extracted to the component const array.
391375
*/
@@ -442,15 +426,6 @@ export enum CompatibilityMode {
442426
TemplateDefinitionBuilder,
443427
}
444428

445-
/**
446-
* Enumeration of the different kinds of `@defer` secondary blocks.
447-
*/
448-
export enum DeferSecondaryKind {
449-
Loading,
450-
Placeholder,
451-
Error,
452-
}
453-
454429
/**
455430
* Enumeration of the types of attributes which can be applied to an element.
456431
*/
@@ -507,7 +482,7 @@ export enum I18nParamResolutionTime {
507482
Creation,
508483

509484
/**
510-
* Param is resolved during post-processing. This should be used for params who's value comes from
485+
* Param is resolved during post-processing. This should be used for params whose value comes from
511486
* an ICU.
512487
*/
513488
Postproccessing
@@ -536,7 +511,7 @@ export enum I18nParamValueFlags {
536511
None = 0b0000,
537512

538513
/**
539-
* This value represtents an element tag.
514+
* This value represents an element tag.
540515
*/
541516
ElementTag = 0b1,
542517

packages/compiler/src/template/pipeline/ir/src/ops/create.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,10 +1387,3 @@ export function createI18nAttributesOp(
13871387
* component.
13881388
*/
13891389
export type ConstIndex = number&{__brand: 'ConstIndex'};
1390-
1391-
export function literalOrArrayLiteral(value: any): o.Expression {
1392-
if (Array.isArray(value)) {
1393-
return o.literalArr(value.map(literalOrArrayLiteral));
1394-
}
1395-
return o.literal(value, o.INFERRED_TYPE);
1396-
}

packages/compiler/src/template/pipeline/ir/src/traits.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@ export const TRAIT_CONSUMES_VARS: ConsumesVarsTrait = {
122122
[ConsumesVarsTrait]: true,
123123
} as const;
124124

125-
/**
126-
* Default values for `UsesVarOffset` fields (used with the spread operator to initialize
127-
* implementors of this trait).
128-
*/
129-
export const TRAIT_USES_VAR_OFFSET: UsesVarOffsetTrait = {
130-
[UsesVarOffset]: true,
131-
varOffset: null,
132-
} as const;
133-
134125
/**
135126
* Test whether an operation implements `ConsumesSlotOpTrait`.
136127
*/

packages/compiler/src/template/pipeline/src/ingest.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ function ingestDeferBlock(unit: ViewCompilationUnit, deferBlock: t.DeferredBlock
565565
function ingestIcu(unit: ViewCompilationUnit, icu: t.Icu) {
566566
if (icu.i18n instanceof i18n.Message && isSingleI18nIcu(icu.i18n)) {
567567
const xref = unit.job.allocateXrefId();
568-
const icuNode = icu.i18n.nodes[0];
569568
unit.create.push(ir.createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null!));
570569
for (const [placeholder, text] of Object.entries({...icu.vars, ...icu.placeholders})) {
571570
if (text instanceof t.BoundText) {

packages/compiler/src/template/pipeline/src/phases/attribute_extraction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function extractAttributes(job: CompilationJob): void {
3838
}
3939

4040
ir.OpList.insertBefore<ir.CreateOp>(
41-
// Deliberaly null i18nMessage value
41+
// Deliberately null i18nMessage value
4242
ir.createExtractedAttributeOp(
4343
op.target, bindingKind, null, op.name, /* expression */ null,
4444
/* i18nContext */ null,

packages/compiler/src/template/pipeline/src/phases/const_collection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ElementAttributes {
133133

134134
constructor(private compatibility: ir.CompatibilityMode) {}
135135

136-
private isKnown(kind: ir.BindingKind, name: string, value: o.Expression|null) {
136+
private isKnown(kind: ir.BindingKind, name: string) {
137137
const nameToValue = this.known.get(kind) ?? new Set<string>();
138138
this.known.set(kind, nameToValue);
139139
if (nameToValue.has(name)) {
@@ -151,7 +151,7 @@ class ElementAttributes {
151151
const allowDuplicates = this.compatibility === ir.CompatibilityMode.TemplateDefinitionBuilder &&
152152
(kind === ir.BindingKind.Attribute || kind === ir.BindingKind.ClassName ||
153153
kind === ir.BindingKind.StyleProperty);
154-
if (!allowDuplicates && this.isKnown(kind, name, value)) {
154+
if (!allowDuplicates && this.isKnown(kind, name)) {
155155
return;
156156
}
157157

packages/compiler/src/template/pipeline/src/phases/extract_i18n_messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function createI18nMessage(
143143
*/
144144
function formatIcuPlaceholder(op: ir.IcuPlaceholderOp) {
145145
if (op.strings.length !== op.expressionPlaceholders.length + 1) {
146-
throw Error(`AsserionError: Invalid ICU placeholder with ${op.strings.length} strings and ${
146+
throw Error(`AssertionError: Invalid ICU placeholder with ${op.strings.length} strings and ${
147147
op.expressionPlaceholders.length} expressions`);
148148
}
149149
const values = op.expressionPlaceholders.map(formatValue);

packages/compiler/src/template/pipeline/src/phases/naming.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ function addNamesToView(
8989
const emptyView = unit.job.views.get(op.emptyView)!;
9090
// Repeater empty view function is at slot +2 (metadata is in the first slot).
9191
addNamesToView(
92-
emptyView, `${baseName}_${`${op.functionNameSuffix}Empty`}_${op.handle.slot + 2}`,
93-
state, compatibility);
92+
emptyView, `${baseName}_${op.functionNameSuffix}Empty_${op.handle.slot + 2}`, state,
93+
compatibility);
9494
}
9595
// Repeater primary view function is at slot +1 (metadata is in the first slot).
9696
addNamesToView(

packages/compiler/src/template/pipeline/src/phases/propagate_i18n_blocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function propagateI18nBlocksToTemplates(
4747
case ir.OpKind.RepeaterCreate:
4848
// Propagate i18n blocks to the @for template.
4949
const forView = unit.job.views.get(op.xref)!;
50-
subTemplateIndex = propagateI18nBlocksForView(
51-
unit.job.views.get(op.xref)!, i18nBlock, op.i18nPlaceholder, subTemplateIndex);
50+
subTemplateIndex =
51+
propagateI18nBlocksForView(forView, i18nBlock, op.i18nPlaceholder, subTemplateIndex);
5252
// Then if there's an @empty template, propagate the i18n blocks for it as well.
5353
if (op.emptyView !== null) {
5454
subTemplateIndex = propagateI18nBlocksForView(

packages/compiler/src/template/pipeline/src/phases/remove_empty_bindings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as ir from '../../ir';
1010
import type {CompilationJob} from '../compilation';
1111

1212
/**
13-
* Bidningd with no content can be safely deleted.
13+
* Binding with no content can be safely deleted.
1414
*/
1515
export function removeEmptyBindings(job: CompilationJob): void {
1616
for (const unit of job.units) {

0 commit comments

Comments
 (0)