Skip to content

Commit cecf7c4

Browse files
committed
Make findBscExeBinary and findEditorAnalysisBinary async
1 parent 4af5bd7 commit cecf7c4

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

server/src/server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ type clientSentBuildAction = {
247247
title: string;
248248
projectRootPath: string;
249249
};
250-
let openedFile = (fileUri: string, fileContent: string) => {
250+
let openedFile = async (fileUri: string, fileContent: string) => {
251251
let filePath = fileURLToPath(fileUri);
252252

253253
stupidFileContentCache.set(filePath, fileContent);
@@ -270,8 +270,8 @@ let openedFile = (fileUri: string, fileContent: string) => {
270270
namespaceName.kind === "success" ? namespaceName.result : null,
271271
rescriptVersion: utils.findReScriptVersionForProjectRoot(projectRootPath),
272272
bsbWatcherByEditor: null,
273-
bscBinaryLocation: utils.findBscExeBinary(projectRootPath),
274-
editorAnalysisLocation: utils.findEditorAnalysisBinary(projectRootPath),
273+
bscBinaryLocation: await utils.findBscExeBinary(projectRootPath),
274+
editorAnalysisLocation: await utils.findEditorAnalysisBinary(projectRootPath),
275275
hasPromptedToStartBuild: /(\/|\\)node_modules(\/|\\)/.test(
276276
projectRootPath
277277
)
@@ -1036,7 +1036,7 @@ function openCompiledFile(msg: p.RequestMessage): p.Message {
10361036
return response;
10371037
}
10381038

1039-
function onMessage(msg: p.Message) {
1039+
async function onMessage(msg: p.Message) {
10401040
if (p.Message.isNotification(msg)) {
10411041
// notification message, aka the client ends it and doesn't want a reply
10421042
if (!initialized && msg.method !== "exit") {
@@ -1052,7 +1052,7 @@ function onMessage(msg: p.Message) {
10521052
}
10531053
} else if (msg.method === DidOpenTextDocumentNotification.method) {
10541054
let params = msg.params as p.DidOpenTextDocumentParams;
1055-
openedFile(params.textDocument.uri, params.textDocument.text);
1055+
await openedFile(params.textDocument.uri, params.textDocument.text);
10561056
updateDiagnosticSyntax(params.textDocument.uri, params.textDocument.text);
10571057
} else if (msg.method === DidChangeTextDocumentNotification.method) {
10581058
let params = msg.params as p.DidChangeTextDocumentParams;

server/src/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,6 @@ let findPlatformPath = (projectRootPath: p.DocumentUri | null) => {
129129
return platformPath;
130130
};
131131

132-
export let findBscExeBinary = (projectRootPath: p.DocumentUri | null) =>
133-
findBinary(findPlatformPath(projectRootPath), c.bscExeName);
134-
135-
export let findEditorAnalysisBinary = (projectRootPath: p.DocumentUri | null) =>
136-
findBinary(findPlatformPath(projectRootPath), c.editorAnalysisName);
137-
138132
// If ReScript < 12.0.0-alpha.13, then we want `{project_root}/node_modules/rescript/{c.platformDir}/{binary}`.
139133
// Otherwise, we want to dynamically import `{project_root}/node_modules/rescript` and from `binPaths` get the relevant binary.
140134
// We won't know which version is in the project root until we read and parse `{project_root}/node_modules/rescript/package.json`
@@ -187,6 +181,12 @@ let findBinaryAsync = async (
187181
}
188182
}
189183

184+
export let findBscExeBinary = (projectRootPath: p.DocumentUri | null) =>
185+
findBinaryAsync(projectRootPath, "bsc.exe");
186+
187+
export let findEditorAnalysisBinary = (projectRootPath: p.DocumentUri | null) =>
188+
findBinaryAsync(projectRootPath, "rescript-editor-analysis.exe");
189+
190190
type execResult =
191191
| {
192192
kind: "success";

0 commit comments

Comments
 (0)