-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathcreate_interface.ts
42 lines (36 loc) · 1.11 KB
/
create_interface.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
import * as fs from "fs";
import * as p from "vscode-languageserver-protocol";
import { LanguageClient, RequestType } from "vscode-languageclient/node";
import { window } from "vscode";
export const createInterfaceRequest = new RequestType<
p.TextDocumentIdentifier,
p.TextDocumentIdentifier,
void
>("textDocument/createInterface");
export const createInterface = (client: LanguageClient) => {
if (!client) {
return window.showInformationMessage("Language server not running");
}
const editor = window.activeTextEditor;
if (!editor) {
return window.showInformationMessage("No active editor");
}
if (fs.existsSync(editor.document.uri.fsPath + "i")) {
return window
.showInformationMessage(
"Interface file already exists. Do you want to overwrite it?",
"Yes",
"No"
)
.then((answer) => {
if (answer === "Yes") {
client.sendRequest(createInterfaceRequest, {
uri: editor.document.uri.toString(),
});
}
});
}
client.sendRequest(createInterfaceRequest, {
uri: editor.document.uri.toString(),
});
};