( uri: string, languageId: string, view: EditorView, )
| 61 | } |
| 62 | |
| 63 | #getOrCreateFile( |
| 64 | uri: string, |
| 65 | languageId: string, |
| 66 | view: EditorView, |
| 67 | ): AcodeWorkspaceFile { |
| 68 | let file = this.#fileMap.get(uri); |
| 69 | if (!file) { |
| 70 | const doc = view.state?.doc; |
| 71 | if (!doc) { |
| 72 | throw new Error( |
| 73 | `Cannot create workspace file without document: ${uri}`, |
| 74 | ); |
| 75 | } |
| 76 | file = new AcodeWorkspaceFile( |
| 77 | uri, |
| 78 | languageId, |
| 79 | this.#nextFileVersion(uri), |
| 80 | doc, |
| 81 | view, |
| 82 | ); |
| 83 | this.#fileMap.set(uri, file); |
| 84 | this.files.push(file); |
| 85 | this.client.didOpen(file); |
| 86 | } |
| 87 | file.views.add(view); |
| 88 | return file; |
| 89 | } |
| 90 | |
| 91 | #getFileEntry(uri: string): AcodeWorkspaceFile | null { |
| 92 | return this.#fileMap.get(uri) ?? null; |
no test coverage detected