(document: TextDocument)
| 186 | |
| 187 | private startMultiLanguageService(): void { |
| 188 | const didOpenTextDocument = async (document: TextDocument) => { |
| 189 | if (document.uri.scheme !== 'file' && document.uri.scheme !== 'untitled' && document.uri.scheme !== 'vscode-notebook-cell') { |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | if (document.languageId !== 'r' && document.languageId !== 'rmd') { |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | const folder = workspace.getWorkspaceFolder(document.uri); |
| 198 | |
| 199 | // Each notebook uses a server started from parent folder |
| 200 | if (document.uri.scheme === 'vscode-notebook-cell') { |
| 201 | const key = this.getKey(document.uri); |
| 202 | if (!this.checkClient(key)) { |
| 203 | console.log(`Start language server for ${document.uri.toString(true)}`); |
| 204 | const documentSelector: DocumentFilter[] = [ |
| 205 | { scheme: 'vscode-notebook-cell', language: 'r', pattern: `${document.uri.fsPath}` }, |
| 206 | ]; |
| 207 | const client = await this.createClient(documentSelector, |
| 208 | dirname(document.uri.fsPath), folder, this.outputChannel); |
| 209 | this.clients.set(key, client); |
| 210 | this.initSet.delete(key); |
| 211 | } |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | if (folder) { |
| 216 | |
| 217 | // Each workspace uses a server started from the workspace folder |
| 218 | const key = this.getKey(folder.uri); |
| 219 | if (!this.checkClient(key)) { |
| 220 | console.log(`Start language server for ${document.uri.toString(true)}`); |
| 221 | const pattern = `${folder.uri.fsPath}/**/*`; |
| 222 | const documentSelector: DocumentFilter[] = [ |
| 223 | { scheme: 'file', language: 'r', pattern: pattern }, |
| 224 | { scheme: 'file', language: 'rmd', pattern: pattern }, |
| 225 | ]; |
| 226 | const client = await this.createClient(documentSelector, folder.uri.fsPath, folder, this.outputChannel); |
| 227 | this.clients.set(key, client); |
| 228 | this.initSet.delete(key); |
| 229 | } |
| 230 | |
| 231 | } else { |
| 232 | |
| 233 | // All untitled documents share a server started from home folder |
| 234 | if (document.uri.scheme === 'untitled') { |
| 235 | const key = this.getKey(document.uri); |
| 236 | if (!this.checkClient(key)) { |
| 237 | console.log(`Start language server for ${document.uri.toString(true)}`); |
| 238 | const documentSelector: DocumentFilter[] = [ |
| 239 | { scheme: 'untitled', language: 'r' }, |
| 240 | { scheme: 'untitled', language: 'rmd' }, |
| 241 | ]; |
| 242 | const client = await this.createClient(documentSelector, os.homedir(), undefined, this.outputChannel); |
| 243 | this.clients.set(key, client); |
| 244 | this.initSet.delete(key); |
| 245 | } |
nothing calls this directly
no test coverage detected