MCPcopy Index your code
hub / github.com/devcontainers/cli / CLIHostDocuments

Class CLIHostDocuments

src/spec-configuration/editableFiles.ts:50–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48};
49
50export class CLIHostDocuments implements Documents {
51
52 static scheme = 'vscode-fileHost';
53
54 constructor(private fileHost: FileHost) {
55 }
56
57 async readDocument(uri: URI) {
58 switch (uri.scheme) {
59 case CLIHostDocuments.scheme:
60 try {
61 return (await this.fileHost.readFile(uriToFsPath(uri, this.fileHost.platform))).toString();
62 } catch (err) {
63 return undefined;
64 }
65 default:
66 throw new Error(`Unsupported scheme: ${uri.toString()}`);
67 }
68 }
69
70 async applyEdits(uri: URI, edits: Edit[], content: string) {
71 switch (uri.scheme) {
72 case CLIHostDocuments.scheme:
73 const result = jsonc.applyEdits(content, edits);
74 await this.fileHost.writeFile(uriToFsPath(uri, this.fileHost.platform), Buffer.from(result));
75 break;
76 default:
77 throw new Error(`Unsupported scheme: ${uri.toString()}`);
78 }
79 }
80}
81
82export class RemoteDocuments implements Documents {
83

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected