-
Notifications
You must be signed in to change notification settings - Fork 686
/
Copy pathOmnisharpStatusBarObserver.ts
55 lines (51 loc) · 2.93 KB
/
OmnisharpStatusBarObserver.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { BaseEvent, DownloadStart, InstallationStart, DownloadProgress, OmnisharpServerOnStdErr } from "../omnisharp/loggingEvents";
import { BaseStatusBarItemObserver } from './BaseStatusBarItemObserver';
import { EventType } from "../omnisharp/EventType";
export enum StatusBarColors {
Red = 'rgb(218,0,0)',
Green = 'rgb(0,218,0)',
Yellow = 'rgb(218,218,0)',
White = 'rgb(256,256,256)'
}
export class OmnisharpStatusBarObserver extends BaseStatusBarItemObserver {
public post = (event: BaseEvent) => {
switch (event.type) {
case EventType.OmnisharpServerOnServerError:
this.SetAndShowStatusBar('$(flame)', 'o.showOutput', StatusBarColors.Red, 'Error starting OmniSharp');
break;
case EventType.OmnisharpServerOnStdErr:
let msg = (<OmnisharpServerOnStdErr>event).message;
this.SetAndShowStatusBar('$(flame)', 'o.showOutput', StatusBarColors.Red, `OmniSharp process errored:${msg}`);
break;
case EventType.OmnisharpOnBeforeServerInstall:
this.SetAndShowStatusBar('$(flame) Installing OmniSharp...', 'o.showOutput');
break;
case EventType.OmnisharpOnBeforeServerStart:
this.SetAndShowStatusBar('$(flame)', 'o.showOutput', StatusBarColors.Yellow, 'Starting OmniSharp server');
break;
case EventType.OmnisharpServerOnStop:
this.ResetAndHideStatusBar();
break;
case EventType.OmnisharpServerOnStart:
this.SetAndShowStatusBar('$(flame)', 'o.showOutput', StatusBarColors.White, 'OmniSharp server is running');
break;
case EventType.DownloadStart:
this.SetAndShowStatusBar("$(cloud-download) Downloading packages", '', '', `Downloading package '${(<DownloadStart>event).packageDescription}...' `);
break;
case EventType.InstallationStart:
this.SetAndShowStatusBar("$(desktop-download) Installing packages...", '', '', `Installing package '${(<InstallationStart>event).packageDescription}'`);
break;
case EventType.InstallationSuccess:
this.ResetAndHideStatusBar();
break;
case EventType.DownloadProgress:
let progressEvent = <DownloadProgress>event;
this.SetAndShowStatusBar("$(cloud-download) Downloading packages", '', '', `Downloading package '${progressEvent.packageDescription}'... ${progressEvent.downloadPercentage}%`);
break;
}
}
}