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

Method openFile

packages/language-service/testing/src/project.ts:159–184  ·  view source on GitHub ↗
(projectFileName: string)

Source from the content-addressed store, hash-verified

157 }
158
159 openFile(projectFileName: string): OpenBuffer {
160 if (!this.buffers.has(projectFileName)) {
161 const fileName = absoluteFrom(`/${this.name}/${projectFileName}`);
162 let scriptInfo = this.tsProject.getScriptInfo(fileName);
163 this.projectService.openClientFile(
164 // By attempting to open the file, the compiler is going to try to parse it as
165 // TS which will throw an error. We pass in JSX which is more permissive.
166 fileName,
167 undefined,
168 fileName.endsWith('.html') ? ts.ScriptKind.JSX : ts.ScriptKind.TS,
169 );
170
171 scriptInfo = this.tsProject.getScriptInfo(fileName);
172 if (scriptInfo === undefined) {
173 throw new Error(
174 `Unable to open ScriptInfo for ${projectFileName} in project ${this.tsConfigPath}`,
175 );
176 }
177 this.buffers.set(
178 projectFileName,
179 new OpenBuffer(this.ngLS, this.tsProject, projectFileName, scriptInfo),
180 );
181 }
182
183 return this.buffers.get(projectFileName)!;
184 }
185
186 getSourceFile(projectFileName: string): ts.SourceFile | undefined {
187 const fileName = absoluteFrom(`/${this.name}/${projectFileName}`);

Calls 5

absoluteFromFunction · 0.90
getScriptInfoMethod · 0.80
hasMethod · 0.65
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected