Skip to content

Commit 66d388a

Browse files
authored
OO stuff (#64)
1 parent 535dbfe commit 66d388a

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export default tseslint.config(
2424
"@typescript-eslint/no-unsafe-member-access": "warn",
2525
"@typescript-eslint/dot-notation": "warn",
2626
"@typescript-eslint/no-explicit-any": "warn",
27-
"@typescript-eslint/no-floating-promises": "warn"
2827
}
2928
},
3029
{

src/commands/implementations.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ ${body}
118118
panel.webview.html = html;
119119
}
120120

121-
export function checkAll(getClient: () => LanguageClient) {
121+
export async function checkAll(getClient: () => LanguageClient) {
122122
if (!getClient()) {
123123
return undefined;
124124
}
125125
const file_uri = window.activeTextEditor?.document.uri;
126126
if (getClient() && getClient().isRunning() && file_uri?.scheme === "file") {
127-
getClient().sendRequest("workspace/executeCommand", { "command": "check-all", "arguments": [file_uri.toString()] });
127+
await getClient().sendRequest("workspace/executeCommand", { "command": "check-all", "arguments": [file_uri.toString()] });
128128
}
129129
}
130130

@@ -157,9 +157,9 @@ export function terminal_eval_selection(): boolean {
157157
return true;
158158
}
159159

160-
export function clear_cache(getClient: () => LanguageClient) {
160+
export async function clear_cache(getClient: () => LanguageClient) {
161161
if (getClient()?.isRunning()) {
162-
getClient().sendRequest("workspace/executeCommand", { "command": "clear-cache", "arguments": [] });
162+
await getClient().sendRequest("workspace/executeCommand", { "command": "clear-cache", "arguments": [] });
163163
}
164164
return true;
165165
}

src/commands/registration.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export function register(context: ExtensionContext, imandraxLanguageClient: Iman
77
const getClient = () => { return imandraxLanguageClient.getClient(); };
88

99
const restart_cmd = "imandrax.restart_language_server";
10-
const restart_handler = () => {
11-
imandraxLanguageClient.restart({ extensionUri: context.extensionUri });
10+
const restart_handler = async () => {
11+
await imandraxLanguageClient.restart({ extensionUri: context.extensionUri });
1212
};
1313
context.subscriptions.push(commands.registerCommand(restart_cmd, restart_handler));
1414

1515
const check_all_cmd = "imandrax.check_all";
16-
const check_all_handler = () => { implementations.checkAll(getClient); };
16+
const check_all_handler = async () => { await implementations.checkAll(getClient); };
1717
context.subscriptions.push(commands.registerCommand(check_all_cmd, check_all_handler));
1818

1919
const browse_cmd = "imandrax.browse";
@@ -33,7 +33,7 @@ export function register(context: ExtensionContext, imandraxLanguageClient: Iman
3333
context.subscriptions.push(commands.registerCommand(terminal_eval_selection_cmd, terminal_eval_selection_handler));
3434

3535
const clear_cache_cmd = "imandrax.clear_cache";
36-
const clear_cache_handler = () => { implementations.clear_cache(getClient); };
36+
const clear_cache_handler = async () => { await implementations.clear_cache(getClient); };
3737
context.subscriptions.push(commands.registerCommand(clear_cache_cmd, clear_cache_handler));
3838

3939
const open_vfs_file_cmd = "imandrax.open_vfs_file";
@@ -60,10 +60,10 @@ export function register(context: ExtensionContext, imandraxLanguageClient: Iman
6060
context.subscriptions.push(commands.registerCommand(open_goal_state_cmd, open_goal_state_handler));
6161

6262
const reset_goal_state_cmd = "imandrax.reset_goal_state";
63-
const reset_goal_state_handler = () => {
63+
const reset_goal_state_handler = async () => {
6464
if (getClient()?.isRunning()) {
6565
try {
66-
getClient().sendRequest("workspace/executeCommand", { "command": "reset-goal-state", "arguments": [] });
66+
await getClient().sendRequest("workspace/executeCommand", { "command": "reset-goal-state", "arguments": [] });
6767
}
6868
catch (e) {
6969
console.log("caught something!");

src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as commands from './commands/commands';
22
import * as decorations from './decorations';
33
import * as formatter from './formatter';
4-
import * as imandraXLanguageClientConfiguration from './imandrax_language_client/configuration';
54
import * as imandraxLanguageClient from './imandrax_language_client/imandrax_language_client';
65
import * as installer from './installer';
76
import * as listeners from './listeners';
@@ -21,10 +20,11 @@ import {
2120

2221

2322
export async function activate(context: ExtensionContext) {
24-
const languageClientConfig = imandraXLanguageClientConfiguration.get();
23+
const getConfig = imandraxLanguageClient.configuration.get;
24+
const languageClientConfig = getConfig();
2525

26-
if (imandraXLanguageClientConfiguration.isFoundPath(languageClientConfig)) {
27-
const languageClientWrapper_ = new imandraxLanguageClient.ImandraXLanguageClient();
26+
if (imandraxLanguageClient.configuration.isFoundPath(languageClientConfig)) {
27+
const languageClientWrapper_ = new imandraxLanguageClient.ImandraXLanguageClient(getConfig);
2828
const getClient: () => LanguageClient = () => { return languageClientWrapper_.getClient(); };
2929

3030
formatter.register();

src/imandrax_language_client/imandrax_language_client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as configuration from './configuration';
66
import { ConfigurationChangeEvent, ExtensionContext, ExtensionMode, Uri, window, workspace, WorkspaceConfiguration } from 'vscode';
77
import { Executable, LanguageClient, LanguageClientOptions } from 'vscode-languageclient/node';
88

9+
export * as configuration from './configuration';
910

1011
const MAX_RESTARTS = 10;
1112

@@ -18,6 +19,7 @@ export class ImandraXLanguageClient {
1819
private readonly vfsProvider_: vfsProvider.VFSContentProvider;
1920
private restartCount = 0;
2021
private isInitial = () => { return this.client === undefined; };
22+
private readonly getConfig: () => configuration.ImandraXLanguageClientConfiguration;
2123

2224
getRestartCount(context: ExtensionContext) {
2325
if (context?.extensionMode === ExtensionMode.Test) {
@@ -33,13 +35,14 @@ export class ImandraXLanguageClient {
3335
return this.vfsProvider_;
3436
}
3537

36-
constructor() {
38+
constructor(getConfig:()=>configuration.ImandraXLanguageClientConfiguration) {
39+
this.getConfig = getConfig;
3740
this.vfsProvider_ = new vfsProvider.VFSContentProvider(() => { return this.getClient(); });
3841
}
3942

4043
// Start language server
4144
async start(params: { extensionUri: Uri }): Promise<void> {
42-
const config = configuration.get();
45+
const config = this.getConfig();
4346

4447
if (!configuration.isFoundPath(config)) {
4548
console.log("ImandraX binary not found, cannot start language server.");
@@ -51,7 +54,7 @@ export class ImandraXLanguageClient {
5154
console.log("Starting ImandraX LSP server");
5255
}
5356

54-
const serverOptions : Executable = {
57+
const serverOptions: Executable = {
5558
command: config.binPathAvailability.path,
5659
args: config.serverArgs,
5760
options: { env: config.mergedEnv }

0 commit comments

Comments
 (0)