MCPcopy Index your code
hub / github.com/angular/angular / makeProgramFromGraph

Function makeProgramFromGraph

packages/compiler-cli/src/ngtsc/cycles/test/util.ts:37–67  ·  view source on GitHub ↗
(
  fs: PathManipulation,
  graph: string,
)

Source from the content-addressed store, hash-verified

35 * An import can be suffixed with ! to make it a type-only import.
36 */
37export function makeProgramFromGraph(
38 fs: PathManipulation,
39 graph: string,
40): {
41 program: ts.Program;
42 host: ts.CompilerHost;
43 options: ts.CompilerOptions;
44} {
45 const files: TestFile[] = graph.split(';').map((fileSegment) => {
46 const [name, importList] = fileSegment.split(':');
47 const contents =
48 (importList ? importList.split(',') : [])
49 .map((i) => {
50 if (i.startsWith('*')) {
51 const sym = i.slice(1);
52 return `export {${sym}} from './${sym}';`;
53 } else if (i.endsWith('!')) {
54 const sym = i.slice(0, -1);
55 return `import type {${sym}} from './${sym}';`;
56 } else {
57 return `import {${i}} from './${i}';`;
58 }
59 })
60 .join('\n') + `export const ${name} = '${name}';\n`;
61 return {
62 name: fs.resolve(`/${name}.ts`),
63 contents,
64 };
65 });
66 return makeProgram(files);
67}
68
69export function importPath(files: ts.SourceFile[]): string {
70 const fs = getFileSystem();

Callers 2

makeImportGraphFunction · 0.90
makeAnalyzerFunction · 0.90

Calls 4

makeProgramFunction · 0.90
mapMethod · 0.80
joinMethod · 0.65
resolveMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…