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

Method driveHmr

packages/compiler-cli/test/ngtsc/env.ts:364–381  ·  view source on GitHub ↗
(fileName: string, className: string)

Source from the content-addressed store, hash-verified

362 }
363
364 driveHmr(fileName: string, className: string): string | null {
365 const {rootNames, options} = readNgcCommandLineAndConfiguration(this.commandLineArgs);
366 const host = createCompilerHost({options});
367 const program = createProgram({rootNames, host, options});
368 const sourceFile = program.getTsProgram().getSourceFile(fileName);
369
370 if (sourceFile == null) {
371 throw new Error(`Cannot find file at "${fileName}"`);
372 }
373
374 for (const node of sourceFile.statements) {
375 if (ts.isClassDeclaration(node) && node.name != null && node.name.text === className) {
376 return (program as NgtscProgram).compiler.emitHmrUpdateModule(node);
377 }
378 }
379
380 throw new Error(`Cannot find class with name "${className}" in "${fileName}"`);
381 }
382}
383
384class AugmentedCompilerHost extends NgtscTestCompilerHost {

Callers 1

hmr_spec.tsFile · 0.80

Calls 6

createCompilerHostFunction · 0.85
emitHmrUpdateModuleMethod · 0.80
getTsProgramMethod · 0.65
createProgramFunction · 0.50
getSourceFileMethod · 0.45

Tested by

no test coverage detected