-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathopen_compiled.ts
38 lines (31 loc) · 1.02 KB
/
open_compiled.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
import * as fs from "fs";
import * as p from "vscode-languageserver-protocol";
import { window, Uri, ViewColumn } from "vscode";
import { LanguageClient, RequestType } from "vscode-languageclient/node";
let openCompiledFileRequest = new RequestType<
p.TextDocumentIdentifier,
p.TextDocumentIdentifier,
void
>("textDocument/openCompiled");
export const openCompiled = (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)) {
return window.showInformationMessage("Compiled file does not exist");
}
client
.sendRequest(openCompiledFileRequest, {
uri: editor.document.uri.toString(),
})
.then((response) => {
const document = Uri.parse(response.uri);
return window.showTextDocument(document, {
viewColumn: ViewColumn.Beside,
});
});
};