From 47df0a80b67c22bd87ea6157e06284850ff9221a Mon Sep 17 00:00:00 2001 From: peternhale Date: Tue, 4 Jun 2024 10:58:21 -0600 Subject: [PATCH] feat: add java v 21 support for apex lsp (#5621) * feat: add java v 21 support for apex lsp @W-14486693@ Add support for java 21 * chore: update messages for wrong java version * chore: git ignore tsconfig.tsbuildinfo files --- .gitignore | 3 ++- .../salesforcedx-vscode-apex/src/messages/i18n.ja.ts | 2 +- .../salesforcedx-vscode-apex/src/messages/i18n.ts | 2 +- .../salesforcedx-vscode-apex/src/requirements.ts | 2 +- .../test/jest/languageUtils/requirements.test.ts | 12 ++++++++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 752eb96b55..989143aa3f 100644 --- a/.gitignore +++ b/.gitignore @@ -116,4 +116,5 @@ packages/dbaeumer* .history # Extension build directory -packages/**/extension \ No newline at end of file +packages/**/extension +tsconfig.tsbuildinfo diff --git a/packages/salesforcedx-vscode-apex/src/messages/i18n.ja.ts b/packages/salesforcedx-vscode-apex/src/messages/i18n.ja.ts index 3c441198e3..a0a78c4db8 100644 --- a/packages/salesforcedx-vscode-apex/src/messages/i18n.ja.ts +++ b/packages/salesforcedx-vscode-apex/src/messages/i18n.ja.ts @@ -74,7 +74,7 @@ export const messages = { source_missing_text: '指定されたフォルダ %s は存在しません。Salesforce Apex 拡張機能の設定方法についての詳細は、[Java 設定](%s) を参照してください。', wrong_java_version_text: - 'サポートされていない Java のバージョンが検出されました。拡張機能を実行するには、[Java 11](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html)、または [Java 17](https://www.oracle.com/java/technologies/downloads/#java17) をダウンロードし、インストールしてください。詳細については、[Java バージョンを設定する](%s) を参照してください。', + 'サポートされていない Java のバージョンが検出されました。拡張機能を実行するには、[Java 11](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html)、[Java 17](https://www.oracle.com/java/technologies/downloads/#java17)、または [Java 21](https://www.oracle.com/java/technologies/downloads/#java21) をダウンロードし、インストールしてください。詳細については、[Java バージョンを設定する](%s) を参照してください。', apex_test_suite_build_text: 'SFDX: Apex テストスイートを作成', unable_to_locate_editor: 'ソースファイルに対してのみこのコマンドを実行できます。', diff --git a/packages/salesforcedx-vscode-apex/src/messages/i18n.ts b/packages/salesforcedx-vscode-apex/src/messages/i18n.ts index f93cb8d4f4..705cf7740f 100644 --- a/packages/salesforcedx-vscode-apex/src/messages/i18n.ts +++ b/packages/salesforcedx-vscode-apex/src/messages/i18n.ts @@ -75,7 +75,7 @@ export const messages = { source_missing_text: '%s points to a missing folder. For information on how to setup the Salesforce Apex extension, see [Set Your Java Version](%s).', wrong_java_version_text: - 'An unsupported Java version was detected. Download and install [Java 11](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html) or [Java 17](https://www.oracle.com/java/technologies/downloads/#java17) to run the extensions. For more information, see [Set Your Java Version](%s).', + 'An unsupported Java version was detected. Download and install [Java 11](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html), [Java 17](https://www.oracle.com/java/technologies/downloads/#java17) or [Java 21](https://www.oracle.com/java/technologies/downloads/#java21) to run the extensions. For more information, see [Set Your Java Version](%s).', wrong_java_version_short: 'Unsupported Java version', java_version_check_command_failed: 'Running java command %s failed with error: %s', diff --git a/packages/salesforcedx-vscode-apex/src/requirements.ts b/packages/salesforcedx-vscode-apex/src/requirements.ts index 50811c41c0..cb432ec500 100644 --- a/packages/salesforcedx-vscode-apex/src/requirements.ts +++ b/packages/salesforcedx-vscode-apex/src/requirements.ts @@ -113,7 +113,7 @@ export const checkJavaVersion = async (javaHome: string): Promise => { ) ); } - if (!/java\.version\s*=\s*(?:11|17)/g.test(stderr)) { + if (!/java\.version\s*=\s*(?:11|17|21)/g.test(stderr)) { reject(nls.localize('wrong_java_version_text', SET_JAVA_DOC_LINK)); } else { resolve(true); diff --git a/packages/salesforcedx-vscode-apex/test/jest/languageUtils/requirements.test.ts b/packages/salesforcedx-vscode-apex/test/jest/languageUtils/requirements.test.ts index 3d03bebfe6..ef12470287 100644 --- a/packages/salesforcedx-vscode-apex/test/jest/languageUtils/requirements.test.ts +++ b/packages/salesforcedx-vscode-apex/test/jest/languageUtils/requirements.test.ts @@ -97,6 +97,18 @@ describe('Java Requirements Test', () => { } }); + it('Should support Java 21', async () => { + execFileStub.yields('', '', 'java.version = 21.0.0'); + try { + const result = await checkJavaVersion('~/java_home'); + expect(result).to.equal(true); + } catch (err) { + fail( + `Should not have thrown when the Java version is 21. The error was: ${err}` + ); + } + + }); it('Should not support Java 20', async () => { execFileStub.yields('', '', 'java.version = 20.0.0'); try {