From bcf91c9e90318b760224cbe0ab0678abf89049c2 Mon Sep 17 00:00:00 2001 From: slavek-kucera <53339291+slavek-kucera@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:05:11 +0200 Subject: [PATCH] fix: Auto-select WebAssembly image on platforms without native support (fixes eclipse-che4z/che-che4z-lsp-for-hlasm#283) --- clients/vscode-hlasmplugin/CHANGELOG.md | 1 + clients/vscode-hlasmplugin/src/serverFactory.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/clients/vscode-hlasmplugin/CHANGELOG.md b/clients/vscode-hlasmplugin/CHANGELOG.md index 1c4868769..56484aa65 100644 --- a/clients/vscode-hlasmplugin/CHANGELOG.md +++ b/clients/vscode-hlasmplugin/CHANGELOG.md @@ -11,6 +11,7 @@ - Program to processor group mapping precedence - The language server may crash while accessing content of virtual files - "Diagnostics suppressed" informational message may be incorrectly generated +- Auto-select WebAssembly image on platforms without native support ## [1.9.0](https://github.com/eclipse-che4z/che-che4z-lsp-for-hlasm/compare/1.8.0...1.9.0) (2023-08-03) diff --git a/clients/vscode-hlasmplugin/src/serverFactory.ts b/clients/vscode-hlasmplugin/src/serverFactory.ts index 8eac474d4..0389d5e8b 100644 --- a/clients/vscode-hlasmplugin/src/serverFactory.ts +++ b/clients/vscode-hlasmplugin/src/serverFactory.ts @@ -20,6 +20,13 @@ import { getConfig } from './eventsHandler' export type ServerVariant = "tcp" | "native" | "wasm"; +const supportedNativePlatforms: Readonly<{ [key: string]: string }> = Object.freeze({ + 'win32.x64': 'win32', + 'linux.x64': 'linux', + 'darwin.x64': 'darwin', + 'darwin.arm64': 'darwin', +}); + /** * factory to create server options * also stores port used for DAP @@ -32,7 +39,12 @@ export class ServerFactory { } async create(method: ServerVariant): Promise { - const langServerFolder = process.platform; + const langServerFolder = supportedNativePlatforms[process.platform + '.' + process.arch]; + if (!langServerFolder) { + if (method !== 'wasm') + console.log('Unsupported platform detected, switching to wasm'); + method = 'wasm'; + } if (method === 'tcp') { const lspPort = await this.getPort();