| 48 | }; |
| 49 | |
| 50 | export 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 | |
| 82 | export class RemoteDocuments implements Documents { |
| 83 |
nothing calls this directly
no outgoing calls
no test coverage detected