Skip to content

Commit f9093ba

Browse files
committed
Register capabilities only if binary exists.
1 parent e2193e4 commit f9093ba

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

server/src/dumpCommand.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ import { exec } from "child_process";
66
import * as tmp from "tmp";
77
import fs from "fs";
88

9+
let binaryPath = path.join(
10+
path.dirname(__dirname),
11+
process.platform,
12+
"bin.exe"
13+
);
14+
15+
export let binaryExists = fs.existsSync(binaryPath);
16+
917
let findExecutable = (uri: string) => {
1018
let filePath = fileURLToPath(uri);
1119
let projectRootPath = utils.findProjectRootOfFile(filePath);
12-
if (projectRootPath == null) {
20+
if (projectRootPath == null || !binaryExists) {
1321
return null;
1422
} else {
15-
let binaryPath = path.join(
16-
path.dirname(__dirname),
17-
process.platform,
18-
"bin.exe"
19-
);
20-
if (fs.existsSync(binaryPath)) {
21-
return { binaryPath, filePath, cwd: projectRootPath };
22-
} else {
23-
return null;
24-
}
23+
return { binaryPath, filePath, cwd: projectRootPath };
2524
}
2625
};
2726

server/src/server.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ import * as chokidar from "chokidar";
2020
import { assert } from "console";
2121
import { fileURLToPath } from "url";
2222
import { ChildProcess } from "child_process";
23-
import { runDumpCommand, runCompletionCommand } from "./dumpCommand";
23+
import {
24+
binaryExists,
25+
runDumpCommand,
26+
runCompletionCommand,
27+
} from "./dumpCommand";
2428

2529
// https://microsoft.github.io/language-server-protocol/specification#initialize
2630
// According to the spec, there could be requests before the 'initialize' request. Link in comment tells how to handle them.
@@ -269,9 +273,11 @@ process.on("message", (msg: m.Message) => {
269273
// TODO: incremental sync?
270274
textDocumentSync: v.TextDocumentSyncKind.Full,
271275
documentFormattingProvider: true,
272-
hoverProvider: true,
273-
definitionProvider: true,
274-
completionProvider: { triggerCharacters: ["."] },
276+
hoverProvider: binaryExists,
277+
definitionProvider: binaryExists,
278+
completionProvider: binaryExists
279+
? { triggerCharacters: ["."] }
280+
: undefined,
275281
},
276282
};
277283
let response: m.ResponseMessage = {

0 commit comments

Comments
 (0)