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

Method driveHmr

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

Source from the content-addressed store, hash-verified

368 }
369
370 driveHmr(fileName: string, className: string): string | null {
371 const {rootNames, options} = readNgcCommandLineAndConfiguration(this.commandLineArgs);
372 const host = createCompilerHost({options});
373 const program = createProgram({rootNames, host, options});
374 const sourceFile = program.getTsProgram().getSourceFile(fileName);
375
376 if (sourceFile == null) {
377 throw new Error(`Cannot find file at "${fileName}"`);
378 }
379
380 for (const node of sourceFile.statements) {
381 if (ts.isClassDeclaration(node) && node.name != null && node.name.text === className) {
382 return (program as NgtscProgram).compiler.emitHmrUpdateModule(node);
383 }
384 }
385
386 throw new Error(`Cannot find class with name "${className}" in "${fileName}"`);
387 }
388}
389
390class 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