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

Method editFile

ngp-vscode-ng-language-service/tests/test_helpers.ts:398–413  ·  view source on GitHub ↗
(filePath: string, content: string, type: 'virtual' | 'physical' = 'physical')

Source from the content-addressed store, hash-verified

396 }
397
398 async editFile(filePath: string, content: string, type: 'virtual' | 'physical' = 'physical') {
399 const normPath = await normalizePath(filePath);
400 const {text} = await this.fileManager.editFile(normPath, content, type);
401
402 if (type === 'physical') {
403 if (!this.openedFiles.includes(normPath)) {
404 await this.lspClient.didChangeWatchedFiles(normPath);
405 }
406 } else {
407 if (this.openedFiles.includes(normPath)) {
408 await this.lspClient.didChange(normPath, text);
409 } else {
410 throw new Error('cannot make virtual changes to a file that is not open');
411 }
412 }
413 }
414
415 async getFileContent(filePath: string): Promise<string> {
416 return this.fileManager.getFileContent(await normalizePath(filePath));

Callers 4

createFileMethod · 0.95

Calls 3

didChangeWatchedFilesMethod · 0.80
didChangeMethod · 0.80
normalizePathFunction · 0.50

Tested by

no test coverage detected