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

Function appendCompiledClass

packages/compiler-cli/preprocessor/src/processor.ts:2081–2162  ·  view source on GitHub ↗
(
  compiled: CompiledClass,
  out: OutputSourceMapBuilder,
  printer: ExpressionPrinter,
  ctx: HybridCompilerContext,
)

Source from the content-addressed store, hash-verified

2079}
2080
2081function appendCompiledClass(
2082 compiled: CompiledClass,
2083 out: OutputSourceMapBuilder,
2084 printer: ExpressionPrinter,
2085 ctx: HybridCompilerContext,
2086): void {
2087 const {
2088 classMeta: {span},
2089 fields,
2090 ngModule,
2091 classMetadataStmt,
2092 debugInfoStmt,
2093 hmrInitializerStmt,
2094 } = compiled;
2095
2096 for (const field of fields) {
2097 const compiledFactory = field.factory ? compileFactoryField(field.factory, printer, ctx) : '';
2098 const compiledDef = createStaticField(
2099 field.def.name,
2100 printer.print(field.def.def.expression),
2101 printer.emitTypes ? printer.printType(field.def.def.type) : null,
2102 true,
2103 ctx.isClosureCompilerEnabled,
2104 );
2105 out.appendLeft(span.end - 1, compiledFactory + compiledDef + (field.coercionMembers ?? ''));
2106 }
2107
2108 let ngModuleStatements = '';
2109 if (ngModule !== null) {
2110 const compiledFac = compileFactoryField(ngModule.factory, printer, ctx);
2111 const compiledMod = createStaticField(
2112 'ɵmod',
2113 printer.print(ngModule.mod.expression),
2114 printer.emitTypes ? printer.printType(ngModule.mod.type) : null,
2115 true,
2116 ctx.isClosureCompilerEnabled,
2117 );
2118 if (ngModule.statements.length > 0) {
2119 ngModuleStatements = ngModule.statements
2120 .map((stmt) => printer.printStatement(stmt, 0))
2121 .join('\n');
2122 }
2123 const compiledInj = createStaticField(
2124 'ɵinj',
2125 printer.print(ngModule.inj.expression),
2126 printer.emitTypes ? printer.printType(ngModule.inj.type) : null,
2127 true,
2128 ctx.isClosureCompilerEnabled,
2129 );
2130 out.appendLeft(span.end - 1, compiledFac + compiledMod + compiledInj);
2131 }
2132
2133 if (classMetadataStmt !== null) {
2134 const emitOutsideClass =
2135 !!ctx.complianceMode || !!compiled.classMeta.hasNonAngularClassDecorators;
2136 const metadata = printSetClassMetadata(classMetadataStmt, printer, emitOutsideClass);
2137 if (emitOutsideClass) {
2138 out.appendRight(span.end, '\n' + metadata);

Callers 1

serializeOutputFunction · 0.85

Calls 10

compileFactoryFieldFunction · 0.85
createStaticFieldFunction · 0.85
printSetClassMetadataFunction · 0.85
printTypeMethod · 0.80
appendLeftMethod · 0.80
mapMethod · 0.80
printStatementMethod · 0.80
appendRightMethod · 0.80
joinMethod · 0.65
printMethod · 0.45

Tested by

no test coverage detected