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

Method openFile

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

Source from the content-addressed store, hash-verified

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