MCPcopy Create free account
hub / github.com/angular/dev-infra / getSourceFile

Method getSourceFile

ng-dev/ts-circular-dependencies/analyzer.ts:80–94  ·  view source on GitHub ↗

Gets the TypeScript source file of the specified path.

(filePath: string)

Source from the content-addressed store, hash-verified

78
79 /** Gets the TypeScript source file of the specified path. */
80 getSourceFile(filePath: string): ts.SourceFile {
81 const resolvedPath = resolve(filePath);
82 if (this._sourceFileCache.has(resolvedPath)) {
83 return this._sourceFileCache.get(resolvedPath)!;
84 }
85 const fileContent = readFileSync(resolvedPath, 'utf8');
86 const sourceFile = ts.createSourceFile(
87 resolvedPath,
88 fileContent,
89 ts.ScriptTarget.Latest,
90 false,
91 );
92 this._sourceFileCache.set(resolvedPath, sourceFile);
93 return sourceFile;
94 }
95
96 /** Resolves the given import specifier with respect to the specified containing file path. */
97 private _resolveImport(specifier: string, containingFilePath: string): string | null {

Callers 2

mainFunction · 0.95
findCyclesMethod · 0.95

Calls 4

resolveFunction · 0.85
hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected