Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Oct 14, 2024
1 parent 6618688 commit 1337420
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ vscode/dist
vscode/build
vscode/tsconfig.tsbuildinfo
vscode/tsbuildinfo
vscode/.metadata
.aider*
.vscode
.vscode
28 changes: 22 additions & 6 deletions vscode/src/client/analyzerClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ChildProcessWithoutNullStreams, exec, spawn } from "child_process";
import * as vscode from "vscode";
import * as os from "os";
import * as fs from "fs";
// import * as rpc from "vscode-jsonrpc/node";
import path from "path";
import { RuleSet } from "../webview/types";
Expand Down Expand Up @@ -37,11 +39,8 @@ export class AnalyzerClient {
return;
}
});
const env = process.env;
delete env.JAVA_HOME;
this.analyzerServer = spawn(this.getAnalyzerPath(), this.getAnalyzerArgs(), {
cwd: this.extContext!.extensionPath,
env: env,
});
this.analyzerServer.stderr.on("data", (data) => {
this.outputChannel.appendLine(`${data.toString()}`);
Expand All @@ -63,7 +62,8 @@ export class AnalyzerClient {

public async runAnalysis(webview: vscode.Webview): Promise<any> {
if (!this.analyzerServer) {
throw new Error("Server not started");
vscode.window.showErrorMessage("Server not started");
return;
}

if (webview) {
Expand Down Expand Up @@ -205,7 +205,23 @@ export class AnalyzerClient {
}

public getAnalyzerPath(): string {
return path.join(this.extContext!.extensionPath, "assets/bin/kai-analyzer");
const platform = os.platform();
const arch = os.arch();

let binaryName = `kai-analyzer.${platform}.${arch}`;
if (platform === "win32") {
binaryName += ".exe";
}

// Full path to the analyzer binary
const analyzerPath = path.join(this.extContext!.extensionPath, "assets", "bin", binaryName);

// Check if the binary exists
if (!fs.existsSync(analyzerPath)) {
vscode.window.showErrorMessage(`Analyzer binary doesn't exist at ${analyzerPath}`);
}

return analyzerPath;
}

public getAnalyzerArgs(): string[] {
Expand All @@ -215,7 +231,7 @@ export class AnalyzerClient {
"-rules-directory",
this.getRules(),
"-lspServerPath",
path.join(this.extContext!.extensionPath, "assets/bin/jdtls/bin/jdtls"),
path.join(this.extContext!.extensionPath, "assets", "bin", "jdtls", "bin", "jdtls"),
"-bundles",
path.join(
this.extContext!.extensionPath,
Expand Down

0 comments on commit 1337420

Please sign in to comment.