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

Method driveIndexer

packages/compiler-cli/test/ngtsc/env.ts:447–498  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

445 }
446
447 driveIndexer(): Map<DeclarationNode, IndexedComponent<DeclarationNode>> {
448 if (isNgpTestMode()) {
449 const {rootNames, options} = readNgcCommandLineAndConfiguration(this.commandLineArgs);
450 const tsconfigPath = this.fs.resolve(this.basePath, 'tsconfig.json');
451 const result = performNgpCompilationSync({
452 fs: this.fs,
453 basePath: this.basePath,
454 tsconfigPath,
455 rootNames,
456 options,
457 emit: false,
458 closeAnalyzer: false,
459 });
460 try {
461 const rawIndexed = runNgpSync(
462 result.compiler.getIndexedComponents(),
463 result.compiler.analyzer,
464 );
465 const out = new Map<DeclarationNode, IndexedComponent<DeclarationNode>>();
466 for (const [, comp] of rawIndexed.entries()) {
467 const fsFileUrl = this.fs.resolve(comp.fileUrl);
468 const sf =
469 result.originalSourceFiles.get(fsFileUrl) ?? result.tsProgram.getSourceFile(fsFileUrl);
470 if (!sf) continue;
471 let classDecl: DeclarationNode | undefined;
472 for (const stmt of sf.statements) {
473 if (ts.isClassDeclaration(stmt) && stmt.name?.text === comp.name) {
474 classDecl = stmt;
475 break;
476 }
477 }
478 if (!classDecl) continue;
479 const fsTemplateFileUrl = this.fs.resolve(comp.template.fileUrl);
480 out.set(classDecl, {
481 ...comp,
482 fileUrl: fsFileUrl,
483 template: {
484 ...comp.template,
485 fileUrl: fsTemplateFileUrl,
486 },
487 } as unknown as IndexedComponent<DeclarationNode>);
488 }
489 return out;
490 } finally {
491 result.compiler.analyzer.close();
492 }
493 }
494 const {rootNames, options} = readNgcCommandLineAndConfiguration(this.commandLineArgs);
495 const host = createCompilerHost({options});
496 const program = createProgram({rootNames, host, options});
497 return (program as NgtscProgram).getIndexedComponents();
498 }
499
500 driveDocsExtraction(entryPoint: string): DocEntry[] {
501 if (isNgpTestMode()) {

Callers 1

Calls 13

isNgpTestModeFunction · 0.90
runNgpSyncFunction · 0.90
createCompilerHostFunction · 0.85
resolveMethod · 0.65
getMethod · 0.65
setMethod · 0.65
closeMethod · 0.65
createProgramFunction · 0.50
getIndexedComponentsMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected