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

Function extractHmrMetatadata

packages/compiler-cli/src/ngtsc/hmr/src/metadata.ts:34–79  ·  view source on GitHub ↗
(
  clazz: DeclarationNode,
  reflection: ReflectionHost,
  evaluator: PartialEvaluator,
  compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>,
  rootDirs: readonly string[],
  definition: R3CompiledExpression,
  factory: CompileResult,
  deferBlockMetadata: R3ComponentDeferMetadata,
  classMetadata: o.Statement | null,
  debugInfo: o.Statement | null,
)

Source from the content-addressed store, hash-verified

32 * @param debugInfo Analyzed `setClassDebugInfo` expression, if any.
33 */
34export function extractHmrMetatadata(
35 clazz: DeclarationNode,
36 reflection: ReflectionHost,
37 evaluator: PartialEvaluator,
38 compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>,
39 rootDirs: readonly string[],
40 definition: R3CompiledExpression,
41 factory: CompileResult,
42 deferBlockMetadata: R3ComponentDeferMetadata,
43 classMetadata: o.Statement | null,
44 debugInfo: o.Statement | null,
45): R3HmrMetadata | null {
46 if (!reflection.isClass(clazz)) {
47 return null;
48 }
49
50 const sourceFile = ts.getOriginalNode(clazz).getSourceFile();
51 const filePath =
52 getProjectRelativePath(sourceFile.fileName, rootDirs, compilerHost) ||
53 compilerHost.getCanonicalFileName(sourceFile.fileName);
54
55 const dependencies = extractHmrDependencies(
56 clazz,
57 definition,
58 factory,
59 deferBlockMetadata,
60 classMetadata,
61 debugInfo,
62 reflection,
63 evaluator,
64 );
65
66 if (dependencies === null) {
67 return null;
68 }
69
70 const meta: R3HmrMetadata = {
71 type: new o.WrappedNodeExpr(clazz.name),
72 className: clazz.name.text,
73 filePath,
74 localDependencies: dependencies.local,
75 namespaceDependencies: dependencies.external,
76 };
77
78 return meta;
79}

Callers 4

compileFullMethod · 0.90
compilePartialMethod · 0.90
compileLocalMethod · 0.90

Calls 5

getProjectRelativePathFunction · 0.90
extractHmrDependenciesFunction · 0.90
isClassMethod · 0.65
getSourceFileMethod · 0.45
getCanonicalFileNameMethod · 0.45

Tested by

no test coverage detected