(client: LanguageClient, rPath: string, args: readonly string[], options: CommonOptions & { cwd: string })
| 25 | } |
| 26 | |
| 27 | private spawnServer(client: LanguageClient, rPath: string, args: readonly string[], options: CommonOptions & { cwd: string }): DisposableProcess { |
| 28 | const childProcess = spawn(rPath, args, options); |
| 29 | const pid = childProcess.pid || -1; |
| 30 | client.outputChannel.appendLine(`R Language Server (${pid}) started`); |
| 31 | childProcess.stderr.on('data', (chunk: Buffer) => { |
| 32 | client.outputChannel.appendLine(chunk.toString()); |
| 33 | }); |
| 34 | childProcess.on('exit', (code, signal) => { |
| 35 | client.outputChannel.appendLine(`R Language Server (${pid}) exited ` + |
| 36 | (signal ? `from signal ${signal}` : `with exit code ${code || 'null'}`)); |
| 37 | if (code !== 0) { |
| 38 | if (code === 10) { |
| 39 | // languageserver is not installed. |
| 40 | void promptToInstallRPackage( |
| 41 | 'languageserver', 'lsp.promptToInstall', options.cwd, |
| 42 | 'R package {languageserver} is required to enable R language service features such as code completion, function signature, find references, etc. Do you want to install it?', |
| 43 | 'You may need to reopen an R file to start the language service after the package is installed.' |
| 44 | ); |
| 45 | } else { |
| 46 | client.outputChannel.show(); |
| 47 | } |
| 48 | } |
| 49 | void client.stop(); |
| 50 | }); |
| 51 | return childProcess; |
| 52 | } |
| 53 | |
| 54 | private async createClient(selector: DocumentFilter[], |
| 55 | cwd: string, workspaceFolder: WorkspaceFolder | undefined, outputChannel: OutputChannel): Promise<LanguageClient> { |
no test coverage detected