-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathuiUtil.ts
More file actions
81 lines (74 loc) · 2.94 KB
/
uiUtil.ts
File metadata and controls
81 lines (74 loc) · 2.94 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
export interface UiUtil {
languageId(uri: string): Promise<string>;
workspaceFoldersFirstPath(): string | undefined;
getConfiguration(key1: string, key2: string): string | undefined;
updateConfiguration(key1: string, key2: string, value: string): Promise<void>;
secretStorageGet(key: string): Promise<string | undefined>;
writeFile(uri: string, content: string): Promise<void>;
showInputBox(option: object): Promise<string | undefined>;
storeSecret(key: string, value: string): Promise<void>;
extensionPath(): string;
runTerminal(terminalName:string, command: string): void;
// current active file path
activeFilePath(): string | undefined;
// current selected range, return undefined if no selection
selectRange(): [number, number] | undefined;
// current selected text
selectText(): string | undefined;
showErrorMessage(message: string): void;
getLSPBrigePort(): Promise<number | undefined>;
}
export class UiUtilWrapper {
private static _uiUtil: UiUtil | undefined;
public static init(uiUtil: UiUtil): void {
this._uiUtil = uiUtil;
}
public static async languageId(uri: string): Promise<string | undefined> {
return await this._uiUtil?.languageId(uri);
}
public static workspaceFoldersFirstPath(): string | undefined {
return this._uiUtil?.workspaceFoldersFirstPath();
}
public static getConfiguration(key1: string, key2: string): string | undefined {
return this._uiUtil?.getConfiguration(key1, key2);
}
public static async updateConfiguration(key1: string, key2: string, value: string): Promise<void> {
return await this._uiUtil?.updateConfiguration(key1, key2, value);
}
public static async secretStorageGet(key: string): Promise<string | undefined> {
return await this._uiUtil?.secretStorageGet(key);
}
public static async writeFile(uri: string, content: string): Promise<void> {
return await this._uiUtil?.writeFile(uri, content);
}
public static async showInputBox(option: object): Promise<string | undefined> {
return await this._uiUtil?.showInputBox(option);
}
public static async storeSecret(key: string, value: string): Promise<void> {
return await this._uiUtil?.storeSecret(key, value);
}
public static extensionPath(): string {
return this._uiUtil?.extensionPath()!;
}
public static runTerminal(terminalName: string, command: string): void {
this._uiUtil?.runTerminal(terminalName, command);
}
// current active file path
public static activeFilePath(): string | undefined {
return this._uiUtil?.activeFilePath();
}
// current selected range, return undefined if no selection
public static selectRange(): [number, number] | undefined {
return this._uiUtil?.selectRange();
}
// current selected text
public static selectText(): string | undefined {
return this._uiUtil?.selectText();
}
public static showErrorMessage(message: string): void {
this._uiUtil?.showErrorMessage(message);
}
public static async getLSPBrigePort(): Promise<number | undefined> {
return await this._uiUtil?.getLSPBrigePort();
}
}