Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#### :bug: Bug fix

- Fix Code Analyzer binary lookup for ReScript v12+ projects.
- Take namespace into account for incremental cleanup. https://github.com/rescript-lang/rescript-vscode/pull/1164
- Potential race condition in incremental compilation. https://github.com/rescript-lang/rescript-vscode/pull/1167
- Fix extension crash triggered by incremental compilation. https://github.com/rescript-lang/rescript-vscode/pull/1169
Expand Down
28 changes: 22 additions & 6 deletions client/src/commands/code_analysis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as cp from "child_process";
import * as fs from "fs";
import * as path from "path";
import {
window,
Expand Down Expand Up @@ -216,12 +217,27 @@ export const runCodeAnalysisWithReanalyze = (
currentDocument.uri.fsPath,
);

// This little weird lookup is because in the legacy setup reanalyze needs to be
// run from the analysis binary, whereas in the new setup it's run from the tools
// binary.
let binaryPath =
getBinaryPath("rescript-tools.exe", projectRootPath) ??
getBinaryPath("rescript-editor-analysis.exe");
// Try v12+ path first: @rescript/{platform}-{arch}/bin/rescript-tools.exe
// Then fall back to legacy paths via getBinaryPath
let binaryPath: string | null = null;
if (projectRootPath != null) {
const v12Path = path.join(
projectRootPath,
"node_modules",
"@rescript",
`${process.platform}-${process.arch}`,
"bin",
"rescript-tools.exe",
);
if (fs.existsSync(v12Path)) {
binaryPath = v12Path;
}
}
if (binaryPath == null) {
binaryPath =
getBinaryPath("rescript-tools.exe", projectRootPath) ??
getBinaryPath("rescript-editor-analysis.exe", projectRootPath);
}

if (binaryPath === null) {
window.showErrorMessage("Binary executable not found.");
Expand Down