()
| 311 | } |
| 312 | |
| 313 | private async stop(): Promise<void> { |
| 314 | this.setSessionStatus("Stopping...", SessionStatus.Stopping); |
| 315 | // Cancel start-up if we're still waiting. |
| 316 | this.startCancellationTokenSource?.cancel(); |
| 317 | |
| 318 | // Stop and dispose the language client. |
| 319 | try { |
| 320 | // If the stop fails, so will the dispose, I think this is a bug in |
| 321 | // the client library. |
| 322 | await this.languageClient?.stop(2000); |
| 323 | await this.languageClient?.dispose(); |
| 324 | } catch (err) { |
| 325 | this.logger.writeError( |
| 326 | `Error occurred while stopping language client:\n${err}`, |
| 327 | ); |
| 328 | } |
| 329 | |
| 330 | this.languageClient = undefined; |
| 331 | |
| 332 | // Stop and dispose the PowerShell process(es). |
| 333 | this.debugSessionProcess?.dispose(); |
| 334 | this.debugSessionProcess = undefined; |
| 335 | this.debugEventHandler?.dispose(); |
| 336 | this.debugEventHandler = undefined; |
| 337 | |
| 338 | this.languageServerProcess?.dispose(); |
| 339 | this.languageServerProcess = undefined; |
| 340 | |
| 341 | // Clean up state to start again. |
| 342 | this.startCancellationTokenSource?.dispose(); |
| 343 | this.startCancellationTokenSource = undefined; |
| 344 | this.sessionDetails = undefined; |
| 345 | this.traceLogLevelHandler?.dispose(); |
| 346 | this.traceLogLevelHandler = undefined; |
| 347 | |
| 348 | this.setSessionStatus("Not Started", SessionStatus.NotStarted); |
| 349 | } |
| 350 | |
| 351 | private async restartSession(exeNameOverride?: string): Promise<void> { |
| 352 | this.logger.write("Restarting session..."); |
no test coverage detected