From 16055f9bc180f115aa2ba66a33d155aa592b8f9a Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Thu, 30 Nov 2023 11:49:46 -0500 Subject: [PATCH 01/16] Upversion to 1.26.0 Signed-off-by: Roland Grunberg --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ee90b5401..5b8bcab6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "java", - "version": "1.25.0", + "version": "1.26.0", "license": "EPL-2.0", "dependencies": { "@redhat-developer/vscode-extension-proposals": "0.0.22", diff --git a/package.json b/package.json index ddd68693d..625f4eddc 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Red Hat", "icon": "icons/icon128.png", "license": "EPL-2.0", - "version": "1.25.0", + "version": "1.26.0", "publisher": "redhat", "bugs": "https://github.com/redhat-developer/vscode-java/issues", "preview": false, From d244b6491d78e2b82e41419f4d70c4db7935a93c Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Thu, 30 Nov 2023 14:04:29 -0500 Subject: [PATCH 02/16] Ensure all version references are synced correctly. Signed-off-by: Roland Grunberg --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 5b8bcab6a..b210a5d6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "java", - "version": "1.25.0", + "version": "1.26.0", "lockfileVersion": 3, "requires": true, "packages": { From 5e4d93ac128cd211d7cecfc4e9c01f5748e4b9fe Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Fri, 22 Sep 2023 16:18:35 -0400 Subject: [PATCH 03/16] Migrate Jenkins release job to GitHub Actions. - Preserve existing Jenkinsfile as a fallback Signed-off-by: Roland Grunberg --- .github/workflows/release.yml | 193 ++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..f6b6276ee --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,193 @@ +name: release + +on: + schedule: + - cron: '0 8 * * *' + workflow_dispatch: + inputs: + JDT_LS_VERSION: + description: 'The (optional) release version (including qualifier) of JDT-LS to use.' + type: string + publishPreRelease: + description: 'Publish a pre-release ?' + required: true + type: choice + options: + - 'true' + - 'false' + default: 'true' + publishToMarketPlace: + description: 'Publish to VS Code Marketplace ?' + required: true + type: choice + options: + - 'true' + - 'false' + default: 'false' + publishToOVSX: + description: 'Publish to OpenVSX Registry ?' + required: true + type: choice + options: + - 'true' + - 'false' + default: 'false' +jobs: + should-build-change: + runs-on: ubuntu-latest + outputs: + repo-cache-hit: ${{ steps.cache-last-commit.outputs.cache-hit }} + steps: + - uses: actions/checkout@v3 + with: + repository: 'eclipse-jdtls/eclipse.jdt.ls' + fetch-depth: 2 + path: eclipse.jdt.ls + - uses: actions/checkout@v3 + with: + repository: 'redhat-developer/vscode-java' + fetch-depth: 2 + path: vscode-java + - run: | + pushd eclipse.jdt.ls + git rev-parse HEAD >> ../lastCommit + popd + pushd vscode-java + git rev-parse HEAD >> ../lastCommit + - name: Check New Changes + id: cache-last-commit + uses: actions/cache@v2 + with: + path: lastCommit + key: lastCommit-${{ hashFiles('lastCommit') }} + packaging-job: + runs-on: ubuntu-latest + needs: should-build-change + if: ${{ needs.should-build-change.outputs.repo-cache-hit != 'true' || github.event_name != 'schedule' }} + steps: + - name: Checkout JDT-LS + if: "${{ inputs.JDT_LS_VERSION == '' }}" + uses: actions/checkout@v2 + with: + repository: eclipse-jdtls/eclipse.jdt.ls + - name: Cache Maven local repository + uses: actions/cache@v2 + with: + path: | + ~/.m2/repository + ~/.m2/wrapper + !~/.m2/repository/org/eclipse/jdt/ls + key: maven-local-${{ hashFiles('**/pom.xml') }} + - name: Set Up Java + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'adopt' + - name: Build JDT-LS + if: "${{ inputs.JDT_LS_VERSION == '' }}" + run: | + ./mvnw clean verify -B -DskipTests -Pserver-distro + mkdir ../staging + cp org.eclipse.jdt.ls.product/distro/jdt-language-server-*.tar.gz ../staging + - name: Check Out VS Code Java + uses: actions/checkout@v2 + - name: Set Up NodeJS + uses: actions/setup-node@v2 + with: + node-version: '18' + - name: Install NodeJS dependencies + run: npm install -g typescript "@vscode/vsce" "ovsx" + - name: Download JDT-LS Release + if: "${{ inputs.JDT_LS_VERSION != '' }}" + run: | + version=`echo ${{ inputs.JDT_LS_VERSION }} | cut -d- -f1` + curl -LO https://download.eclipse.org/jdtls/milestones/${version}/jdt-language-server-${{ inputs.JDT_LS_VERSION }}.tar.gz + - name: Build vscode-java + run: | + npm install + npm run vscode:prepublish + npm run compile + - name: Test vscode-java + env: + SKIP_COMMANDS_TEST: true + SKIP_CLASSPATH_TEST: true + run: | + $(echo "xvfb-run --auto-servernum") npm run test --silent + continue-on-error: true + - name: Clean tests + run: npx gulp clean_test_folder + - name: Prepare Lombok Support + run: | + npx gulp download_lombok + - name: Prepare Pre-Release + if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }} + run: | + npx gulp prepare_pre_release + echo "publishPreReleaseFlag=--pre-release" >> $GITHUB_ENV + - name: Prepare JDT-LS + run: | + rm -rf ./out + mkdir server/ + if [ -e jdt-language-server-*.tar.gz ]; then + tar -xf jdt-language-server-*.tar.gz -C server/ + else + tar -xf ../staging/jdt-language-server-*.tar.gz -C server/ + fi + echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV + - name: Package vscode-java + run: | + platforms=("win32-x64" "linux-x64" "linux-arm64" "darwin-x64" "darwin-arm64") + for platform in ${platforms[@]}; do + npx gulp download_jre --target ${platform} --javaVersion 17 + vsce package ${{ env.publishPreReleaseFlag }} --target ${platform} -o java-${platform}-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix + done + rm -rf jre/ + vsce package ${{ env.publishPreReleaseFlag }} -o vscode-java-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix + ls -lash *.vsix + - name: Upload VSIX Artifacts + uses: actions/upload-artifact@v2 + with: + name: vscode-java + path: | + java-*-${{ env.EXT_VERSION }}-${{github.run_number}}.vsix + vscode-java-${{ env.EXT_VERSION }}-${{github.run_number}}.vsix + if-no-files-found: error + - name: Publish to GH Release Tab + if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }} + uses: "marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "v${{ env.EXT_VERSION }}" + title: "${{ env.EXT_VERSION }}" + draft: true + files: | + java-*-${{ env.EXT_VERSION }}-${{github.run_number}}.vsix + vscode-java-${{ env.EXT_VERSION }}-${{ github.run_number }}.vsix + release-job: + environment: ${{ (inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true') && 'release' || 'pre-release' }} + runs-on: ubuntu-latest + needs: packaging-job + steps: + - name: Set Up NodeJS + uses: actions/setup-node@v2 + with: + node-version: '18' + - name: Install dependencies + run: | + npm install -g typescript "@vscode/vsce" "ovsx" + - name: Download VSIX & JDT-LS + uses: actions/download-artifact@v3 + - name: Publish to VS Code Marketplace + if: ${{ github.event_name == 'schedule' || inputs.publishToMarketPlace == 'true' || inputs.publishPreRelease == 'true' }} + run: | + for platformVsix in vscode-java/java-*-*-${GITHUB_RUN_NUMBER}.vsix; do + vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath ${platformVsix} + done + vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath vscode-java/vscode-java-*-${GITHUB_RUN_NUMBER}.vsix + - name: Publish to OpenVSX Registry + if: ${{ github.event_name == 'schedule' || inputs.publishToOVSX == 'true' || inputs.publishPreRelease == 'true' }} + run: | + for platformVsix in vscode-java/java-*-*-${GITHUB_RUN_NUMBER}.vsix; do + ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath ${platformVsix} + done + ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath vscode-java/vscode-java-*-${GITHUB_RUN_NUMBER}.vsix From d186e1216311723b285d0506be4ada06b35e6284 Mon Sep 17 00:00:00 2001 From: Per-Steinar Karlsen Date: Tue, 5 Dec 2023 07:52:58 +0100 Subject: [PATCH 04/16] Improved grammar for kotlin based on official documentation (#3407) Signed-off-by: Per-Steinar Karlsen Co-authored-by: Per-Steinar Karlsen --- .../kotlin/kotlin.tmLanguage.json | 150 ++++++++++++++++-- 1 file changed, 140 insertions(+), 10 deletions(-) diff --git a/language-support/kotlin/kotlin.tmLanguage.json b/language-support/kotlin/kotlin.tmLanguage.json index eaa053b90..53b07a1b1 100644 --- a/language-support/kotlin/kotlin.tmLanguage.json +++ b/language-support/kotlin/kotlin.tmLanguage.json @@ -1,7 +1,7 @@ { "information_for_contributors": [ - "This file has been copied from https://github.com/eclipse/buildship/blob/b848d9a08283b68860671a73ceec3c99bdab27c2/org.eclipse.buildship.kotlindsl.provider/kotlin.tmLanguage.json" - ], + "This file has been copied from https://github.com/eclipse/buildship/blob/b848d9a08283b68860671a73ceec3c99bdab27c2/org.eclipse.buildship.kotlindsl.provider/kotlin.tmLanguage.json" + ], "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "Kotlin", "scopeName": "source.kotlin", @@ -21,10 +21,13 @@ ], "repository": { "import": { - "begin": "\\b(import)\\b\\s*", + "begin": "\\b(import)\\b\\s?([\\w+.]*\\w+)?\\s*", "beginCaptures": { "1": { "name": "storage.type.import.kotlin" + }, + "2": { + "name": "storage.modifier.import.kotlin" } }, "end": ";|$", @@ -91,6 +94,15 @@ { "include": "#variable-declaration" }, + { + "include": "#constant-declaration" + }, + { + "include": "#variable" + }, + { + "include": "#object" + }, { "include": "#type-constraint" }, @@ -100,6 +112,9 @@ { "include": "#function-call" }, + { + "include": "#property.reference" + }, { "include": "#method-reference" }, @@ -141,6 +156,18 @@ }, { "include": "#null-literal" + }, + { + "match": ",", + "name": "punctuation.separator.delimiter.kotlin" + }, + { + "match": "\\.", + "name": "punctuation.separator.period.kotlin" + }, + { + "match": "\\?\\.", + "name": "punctuation.accessor.optional.kotlin" } ] }, @@ -234,6 +261,9 @@ }, { "include": "#control-keywords" + }, + { + "include": "#map-keywords" } ] }, @@ -257,6 +287,10 @@ "match": "\\b(if|else|while|do|when|try|throw|break|continue|return|for)\\b", "name": "keyword.control.kotlin" }, + "map-keywords": { + "match": "\\b(to)\\b", + "name": "keyword.map.kotlin" + }, "annotation-simple": { "match": "(?<([^<>]|\\g)+>)?\\s*(?:(\\w+)\\.)?(\\b\\w+\\b|`[^`]+`)", - "captures": { + "begin": "\\b(fun)\\b\\s*(?<([^<>]|\\g)+>)?\\s*(?:(\\w+)\\.)?(\\b\\w+\\b|`[^`]+`)\\(", + "beginCaptures": { "1": { "name": "storage.type.function.kotlin" }, @@ -359,10 +393,41 @@ "5": { "name": "entity.name.function.declaration.kotlin" } + }, + "end": "\\)", + "endCaptures": { + "1": { + "name": "keyword.operator.assignment.type.kotlin" + } + }, + "patterns": [ + { + "include": "#parameter-declaration" + } + ] + }, + "parameter-declaration": { + "match": "\\b(\\w+)\\s*(:)\\s*(\\w+)(\\?)?(,)?", + "captures": { + "1": { + "name": "variable.parameter.kotlin" + }, + "2": { + "name": "keyword.operator.assignment.type.kotlin" + }, + "3": { + "name": "entity.name.type.kotlin" + }, + "4": { + "name": "keyword.operator.optional" + }, + "5": { + "name": "punctuation.separator.delimiter.kotlin" + } } }, "variable-declaration": { - "match": "\\b(val|var)\\b\\s*(?<([^<>]|\\g)+>)?", + "match": "\\b(var)\\b\\s*(?<([^<>]|\\g)+>)?", "captures": { "1": { "name": "storage.type.variable.kotlin" @@ -376,11 +441,52 @@ } } }, + "constant-declaration": { + "match": "\\b(val)\\b\\s*(?<([^<>]|\\g)+>)?", + "captures": { + "1": { + "name": "storage.type.variable.readonly.kotlin" + }, + "2": { + "patterns": [ + { + "include": "#type-parameter" + } + ] + } + } + }, + "variable" : { + "match": "\\b(\\w+)(?=\\s*[:=])", + "captures": { + "1": { + "name": "variable.other.definition.kotlin" + } + } + }, + "object" : { + "match": "\\b(\\w+)(?=\\.)", + "captures": { + "1": { + "name": "variable.other.object.kotlin" + } + } + }, "type-parameter": { "patterns": [ { - "match": "\\b\\w+\\b", - "name": "entity.name.type.kotlin" + "match": "(:)?\\s*(\\b\\w+\\b)(\\?)?", + "captures": { + "1": { + "name": "keyword.operator.assignment.kotlin" + }, + "2": { + "name": "entity.name.type.kotlin" + }, + "3": { + "name": "keyword.operator.optional" + } + } }, { "match": "\\b(in|out)\\b", @@ -401,12 +507,18 @@ } }, "function-call": { - "match": "\\??\\.?(\\b\\w+\\b|`[^`]+`)\\s*(?<([^<>]|\\g)+>)?\\s*(?=[({])", + "match": "(?:(\\?\\.)|(\\.))?(\\b\\w+\\b|`[^`]+`)\\s*(?<([^<>]|\\g)+>)?\\s*(?=[({])", "captures": { "1": { - "name": "entity.name.function.call.kotlin" + "name": "punctuation.accessor.optional.kotlin" }, "2": { + "name": "punctuation.separator.period.kotlin" + }, + "3": { + "name": "entity.name.function.call.kotlin" + }, + "4": { "patterns": [ { "include": "#type-parameter" @@ -415,6 +527,20 @@ } } }, + "property.reference": { + "match": "(?:(\\?\\.)|(\\.))(\\w+)\\b", + "captures": { + "1": { + "name": "punctuation.accessor.optional.kotlin" + }, + "2": { + "name": "punctuation.separator.period.kotlin" + }, + "3": { + "name": "variable.other.property.kotlin" + } + } + }, "method-reference": { "match": "\\??::(\\b\\w+\\b|`[^`]+`)", "captures": { @@ -537,6 +663,10 @@ "match": "(===?|\\!==?|<=|>=|<|>)", "name": "keyword.operator.comparison.kotlin" }, + { + "match": "(\\?:)", + "name": "keyword.operator.elvis.kotlin" + }, { "match": "([+*/%-]=)", "name": "keyword.operator.assignment.arithmetic.kotlin" From c2f5a6a165a3a3f32577dce03982952b1b99ca6f Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Tue, 5 Dec 2023 00:10:28 -0800 Subject: [PATCH 05/16] Fix the typo: blob -> glob (#3413) Signed-off-by: Sheng Chen --- src/extension.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 8f519e796..6afeaf57e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -516,9 +516,9 @@ async function workspaceContainsBuildFiles(): Promise { } // Nothing found in negated exclusion pattern, do a normal search then. - const inclusionBlob: string = convertToGlob(inclusionPatterns); - const exclusionBlob: string = getExclusionGlob(); - if (inclusionBlob && (await workspace.findFiles(inclusionBlob, exclusionBlob, 1 /* maxResults */)).length > 0) { + const inclusionGlob: string = convertToGlob(inclusionPatterns); + const exclusionGlob: string = getExclusionGlob(); + if (inclusionGlob && (await workspace.findFiles(inclusionGlob, exclusionGlob, 1 /* maxResults */)).length > 0) { return true; } From f09b712f5d6d6339e765f58c8dfab3f78a378183 Mon Sep 17 00:00:00 2001 From: Hope Hadfield Date: Mon, 4 Dec 2023 15:41:08 -0500 Subject: [PATCH 06/16] Fix escape characters within textblock Signed-off-by: Hope Hadfield --- language-support/java/java.tmLanguage.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/language-support/java/java.tmLanguage.json b/language-support/java/java.tmLanguage.json index e8147d683..2bdf9bf0e 100644 --- a/language-support/java/java.tmLanguage.json +++ b/language-support/java/java.tmLanguage.json @@ -1596,11 +1596,7 @@ "name": "string.quoted.triple.java", "patterns": [ { - "match": "\\\\\"\"\"", - "name": "constant.character.escape.java" - }, - { - "match": "\\\\.", + "match": "(\\\\\"\"\")(?!\")|(\\\\.)", "name": "constant.character.escape.java" } ] From fd9e005d06206b0fa6f6f54aeec961a49e686057 Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Wed, 6 Dec 2023 11:57:42 -0500 Subject: [PATCH 07/16] Changelog for 1.25.1 - Bump down from 1.26.0 to 1.25.1 for service release Signed-off-by: Roland Grunberg --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47116562d..75132d46a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 1.25.1 (December 7th, 2023) + * performance - Avoid unnecessary (Maven) project updates. See [#3411](https://github.com/redhat-developer/vscode-java/issues/3411). + * bug fix - Out of sync editor content may report false compilation errors. See [JLS#2955](https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/2955). + * bug fix - Improved support for textmate definition for Kotlin DSL. See [#3403](https://github.com/redhat-developer/vscode-java/issues/3403). + * bug fix - No completion suggestions for package references when `matchCase` is set to `firstLetter`. See [JLS#2925](https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/2925). + * bug fix - Closing Text Blocks immediately after an escaped character produces incorrect syntax highlight. See [#3384](https://github.com/redhat-developer/vscode-java/issues/3384). + * bug fix - Fix the typo: blob -> glob. See [#3413](https://github.com/redhat-developer/vscode-java/pull/3413). + ## 1.25.0 (November 30th, 2023) * enhancement - Provide support for Java 21. See [#3292](https://github.com/redhat-developer/vscode-java/issues/3292). * enhancement - Import projects by configurations. See [#3356](https://github.com/redhat-developer/vscode-java/pull/3356). diff --git a/package-lock.json b/package-lock.json index b210a5d6b..8edc46d4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "java", - "version": "1.26.0", + "version": "1.25.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "java", - "version": "1.26.0", + "version": "1.25.1", "license": "EPL-2.0", "dependencies": { "@redhat-developer/vscode-extension-proposals": "0.0.22", diff --git a/package.json b/package.json index 625f4eddc..80846dfc4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Red Hat", "icon": "icons/icon128.png", "license": "EPL-2.0", - "version": "1.26.0", + "version": "1.25.1", "publisher": "redhat", "bugs": "https://github.com/redhat-developer/vscode-java/issues", "preview": false, From fa70956be46d17f1b891dc96d5514fe4d7fa971d Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Thu, 7 Dec 2023 10:23:14 -0500 Subject: [PATCH 08/16] Upversion to 1.26.0 Signed-off-by: Roland Grunberg --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8edc46d4b..b210a5d6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "java", - "version": "1.25.1", + "version": "1.26.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "java", - "version": "1.25.1", + "version": "1.26.0", "license": "EPL-2.0", "dependencies": { "@redhat-developer/vscode-extension-proposals": "0.0.22", diff --git a/package.json b/package.json index 80846dfc4..625f4eddc 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Red Hat", "icon": "icons/icon128.png", "license": "EPL-2.0", - "version": "1.25.1", + "version": "1.26.0", "publisher": "redhat", "bugs": "https://github.com/redhat-developer/vscode-java/issues", "preview": false, From 65a64315a6703eb28ae4b70b5d4b025568c52191 Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Thu, 7 Dec 2023 16:24:52 -0800 Subject: [PATCH 09/16] Make the server status as a normal status bar item (#3419) Signed-off-by: Sheng Chen --- src/extension.ts | 2 - src/languageStatusItemFactory.ts | 72 -------------------- src/serverStatusBarProvider.ts | 111 ++++++++----------------------- 3 files changed, 28 insertions(+), 157 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 6afeaf57e..e8a94e011 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -129,8 +129,6 @@ export async function activate(context: ExtensionContext): Promise cleanJavaWorkspaceStorage(); - serverStatusBarProvider.initialize(); - return requirements.resolveRequirements(context).catch(error => { // show error window.showErrorMessage(error.message, error.label).then((selection) => { diff --git a/src/languageStatusItemFactory.ts b/src/languageStatusItemFactory.ts index e882ee8c9..0ddf89398 100644 --- a/src/languageStatusItemFactory.ts +++ b/src/languageStatusItemFactory.ts @@ -3,7 +3,6 @@ import * as path from "path"; import * as vscode from "vscode"; import { Commands } from "./commands"; -import { StatusIcon } from "./serverStatusBarProvider"; const languageServerDocumentSelector = [ { scheme: 'file', language: 'java' }, @@ -47,77 +46,6 @@ export namespace StatusCommands { }; } -export namespace ServerStatusItemFactory { - export function create(): any { - if (supportsLanguageStatus()) { - const item = vscode.languages.createLanguageStatusItem("JavaServerStatusItem", languageServerDocumentSelector); - item.name = "Java Language Server Status"; - return item; - } - return undefined; - } - - export function showLightWeightStatus(item: any): void { - item.severity = vscode.LanguageStatusSeverity?.Warning; - item.text = StatusIcon.lightWeight; - item.detail = "Lightweight Mode"; - item.command = StatusCommands.switchToStandardCommand; - } - - export function showNotImportedStatus(item: any): void { - item.severity = vscode.LanguageStatusSeverity?.Warning; - item.text = "No projects are imported"; - item.command = StatusCommands.startStandardServerCommand; - } - - export function showStandardStatus(item: any): void { - item.severity = vscode.LanguageStatusSeverity?.Information; - item.command = StatusCommands.showServerStatusCommand; - } - - export function setBusy(item: any): void { - if (item.busy === true) { - return; - } - item.text = "Building"; - item.busy = true; - } - - export function setError(item: any): void { - item.busy = false; - item.severity = vscode.LanguageStatusSeverity?.Error; - item.command = { - title: "Open logs", - command: Commands.OPEN_LOGS - }; - item.text = StatusIcon.error; - item.detail = "Errors occurred in initializing language server"; - } - - export function setWarning(item: any): void { - item.busy = false; - item.severity = vscode.LanguageStatusSeverity?.Error; - item.command = { - title: "Show PROBLEMS Panel", - command: "workbench.panel.markers.view.focus", - tooltip: "Errors occurred in project configurations, click to show the PROBLEMS panel" - }; - item.text = StatusIcon.warning; - item.detail = "Project Configuration Error"; - } - - export function setReady(item: any): void { - if (item.text === StatusIcon.ready) { - return; - } - item.busy = false; - item.severity = vscode.LanguageStatusSeverity?.Information; - item.command = StatusCommands.showServerStatusCommand; - item.text = StatusIcon.ready; - item.detail = ""; - } -} - export namespace RuntimeStatusItemFactory { export function create(text: string, vmInstallPath: string): any { if (supportsLanguageStatus()) { diff --git a/src/serverStatusBarProvider.ts b/src/serverStatusBarProvider.ts index 12c4fa216..4bff57ed8 100644 --- a/src/serverStatusBarProvider.ts +++ b/src/serverStatusBarProvider.ts @@ -1,123 +1,68 @@ 'use strict'; -import { StatusBarItem, window, StatusBarAlignment, version } from "vscode"; +import { StatusBarItem, window, StatusBarAlignment } from "vscode"; import { Commands } from "./commands"; import { Disposable } from "vscode-languageclient"; -import * as semver from "semver"; -import { ServerStatusItemFactory, StatusCommands, supportsLanguageStatus } from "./languageStatusItemFactory"; +import { StatusCommands } from "./languageStatusItemFactory"; class ServerStatusBarProvider implements Disposable { private statusBarItem: StatusBarItem; - private languageStatusItem: any; - // Adopt new API for status bar item, meanwhile keep the compatibility with Theia. - // See: https://github.com/redhat-developer/vscode-java/issues/1982 - private isAdvancedStatusBarItem: boolean; constructor() { - this.isAdvancedStatusBarItem = semver.gte(version, "1.57.0"); - } - - public initialize(): void { - if (supportsLanguageStatus()) { - this.languageStatusItem = ServerStatusItemFactory.create(); - } else { - if (this.isAdvancedStatusBarItem) { - this.statusBarItem = (window.createStatusBarItem as any)("java.serverStatus", StatusBarAlignment.Right, Number.MIN_VALUE); - } else { - this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, Number.MIN_VALUE); - } - } + this.statusBarItem = window.createStatusBarItem("java.serverStatus", StatusBarAlignment.Right, Number.MIN_VALUE); } public showLightWeightStatus(): void { - if (supportsLanguageStatus()) { - ServerStatusItemFactory.showLightWeightStatus(this.languageStatusItem); - } else { - if (this.isAdvancedStatusBarItem) { - (this.statusBarItem as any).name = "Java Server Mode"; - } - this.statusBarItem.text = StatusIcon.lightWeight; - this.statusBarItem.command = StatusCommands.switchToStandardCommand; - this.statusBarItem.tooltip = "Java language server is running in LightWeight mode, click to switch to Standard mode"; - this.statusBarItem.show(); - } + this.statusBarItem.name = "Java Server Mode"; + this.statusBarItem.text = StatusIcon.lightWeight; + this.statusBarItem.command = StatusCommands.switchToStandardCommand; + this.statusBarItem.tooltip = "Java language server is running in LightWeight mode, click to switch to Standard mode"; + this.statusBarItem.show(); } public showNotImportedStatus(): void { - if (supportsLanguageStatus()) { - ServerStatusItemFactory.showNotImportedStatus(this.languageStatusItem); - } else { - if (this.isAdvancedStatusBarItem) { - (this.statusBarItem as any).name = "No projects are imported"; - } - this.statusBarItem.text = StatusIcon.notImported; - this.statusBarItem.command = StatusCommands.startStandardServerCommand; - this.statusBarItem.tooltip = "No projects are imported, click to load projects"; - this.statusBarItem.show(); - } + this.statusBarItem.name = "No projects are imported"; + this.statusBarItem.text = StatusIcon.notImported; + this.statusBarItem.command = StatusCommands.startStandardServerCommand; + this.statusBarItem.tooltip = "No projects are imported, click to load projects"; + this.statusBarItem.show(); } public showStandardStatus(): void { - if (supportsLanguageStatus()) { - ServerStatusItemFactory.showStandardStatus(this.languageStatusItem); - ServerStatusItemFactory.setBusy(this.languageStatusItem); - } else { - if (this.isAdvancedStatusBarItem) { - (this.statusBarItem as any).name = "Java Server Status"; - } - this.statusBarItem.text = StatusIcon.busy; - this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; - this.statusBarItem.tooltip = ""; - this.statusBarItem.show(); - } + this.statusBarItem.name = "Java Server Status"; + this.statusBarItem.text = StatusIcon.busy; + this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; + this.statusBarItem.tooltip = ""; + this.statusBarItem.show(); } public setBusy(): void { - if (supportsLanguageStatus()) { - ServerStatusItemFactory.setBusy(this.languageStatusItem); - } else { - this.statusBarItem.text = StatusIcon.busy; - } + this.statusBarItem.text = StatusIcon.busy; } public setError(): void { - if (supportsLanguageStatus()) { - ServerStatusItemFactory.setError(this.languageStatusItem); - } else { - this.statusBarItem.text = StatusIcon.error; - this.statusBarItem.command = Commands.OPEN_LOGS; - } + this.statusBarItem.text = StatusIcon.error; + this.statusBarItem.command = Commands.OPEN_LOGS; } public setWarning(): void { - if (supportsLanguageStatus()) { - ServerStatusItemFactory.setWarning(this.languageStatusItem); - } else { - this.statusBarItem.text = StatusIcon.warning; - this.statusBarItem.command = "workbench.panel.markers.view.focus"; - this.statusBarItem.tooltip = "Errors occurred in project configurations, click to show the PROBLEMS panel"; - } + this.statusBarItem.text = StatusIcon.warning; + this.statusBarItem.command = "workbench.panel.markers.view.focus"; + this.statusBarItem.tooltip = "Errors occurred in project configurations, click to show the PROBLEMS panel"; } public setReady(): void { - if (supportsLanguageStatus()) { - ServerStatusItemFactory.setReady(this.languageStatusItem); - } else { - this.statusBarItem.text = StatusIcon.ready; - this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; - this.statusBarItem.tooltip = "ServiceReady"; - } + this.statusBarItem.text = StatusIcon.ready; + this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; + this.statusBarItem.tooltip = "ServiceReady"; } public updateTooltip(tooltip: string): void { - if (!supportsLanguageStatus()) { - this.statusBarItem.tooltip = tooltip; - } + this.statusBarItem.tooltip = tooltip; } public dispose(): void { this.statusBarItem?.dispose(); - this.languageStatusItem?.dispose(); } } From 7ef38c61b2351dee4cda0811b0c0f26f965a59f8 Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Fri, 8 Dec 2023 10:53:49 +0800 Subject: [PATCH 10/16] Remove the compatibility check for createLanguageStatusItem() api Signed-off-by: Sheng Chen --- src/extension.ts | 8 +-- src/languageStatusItemFactory.ts | 50 ++++++----------- src/lombokSupport.ts | 24 ++++---- src/runtimeStatusBarProvider.ts | 94 ++++++++++---------------------- 4 files changed, 60 insertions(+), 116 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index e8a94e011..5246d3b37 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,7 +5,7 @@ import * as fs from 'fs'; import * as fse from 'fs-extra'; import * as os from 'os'; import * as path from 'path'; -import { CodeActionContext, commands, ConfigurationTarget, Diagnostic, env, EventEmitter, ExtensionContext, extensions, IndentAction, InputBoxOptions, languages, RelativePattern, TextDocument, UIKind, Uri, ViewColumn, window, workspace, WorkspaceConfiguration, version } from 'vscode'; +import { CodeActionContext, commands, ConfigurationTarget, Diagnostic, env, EventEmitter, ExtensionContext, extensions, IndentAction, InputBoxOptions, languages, RelativePattern, TextDocument, UIKind, Uri, ViewColumn, window, workspace, WorkspaceConfiguration } from 'vscode'; import { CancellationToken, CodeActionParams, CodeActionRequest, Command, CompletionRequest, DidChangeConfigurationNotification, ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn } from 'vscode-languageclient'; import { LanguageClient } from 'vscode-languageclient/node'; import { apiManager } from './apiManager'; @@ -22,7 +22,7 @@ import { collectJavaExtensions, getBundlesToReload, isContributedPartUpdated } f import { registerClientProviders } from './providerDispatcher'; import { initialize as initializeRecommendation } from './recommendation'; import * as requirements from './requirements'; -import { runtimeStatusBarProvider } from './runtimeStatusBarProvider'; +import { languageStatusBarProvider } from './runtimeStatusBarProvider'; import { serverStatusBarProvider } from './serverStatusBarProvider'; import { ACTIVE_BUILD_TOOL_STATE, cleanWorkspaceFileName, getJavaServerMode, handleTextDocumentChanges, getImportMode, onConfigurationChange, ServerMode, ImportMode } from './settings'; import { snippetCompletionProvider } from './snippetCompletionProvider'; @@ -399,7 +399,7 @@ export async function activate(context: ExtensionContext): Promise context.subscriptions.push(snippetCompletionProvider.initialize()); context.subscriptions.push(serverStatusBarProvider); - context.subscriptions.push(runtimeStatusBarProvider); + context.subscriptions.push(languageStatusBarProvider); const classEditorProviderRegistration = window.registerCustomEditorProvider(JavaClassEditorProvider.viewType, new JavaClassEditorProvider(context)); context.subscriptions.push(classEditorProviderRegistration); @@ -410,7 +410,7 @@ export async function activate(context: ExtensionContext): Promise if (event === ServerMode.standard) { syntaxClient.stop(); fileEventHandler.setServerStatus(true); - runtimeStatusBarProvider.initialize(context); + languageStatusBarProvider.initialize(context); } commands.executeCommand('setContext', 'java:serverMode', event); }); diff --git a/src/languageStatusItemFactory.ts b/src/languageStatusItemFactory.ts index 0ddf89398..d647bf6d2 100644 --- a/src/languageStatusItemFactory.ts +++ b/src/languageStatusItemFactory.ts @@ -13,10 +13,6 @@ const languageServerDocumentSelector = [ { pattern: '**/{build,settings}.gradle.kts'} ]; -export function supportsLanguageStatus(): boolean { - return !!vscode.languages.createLanguageStatusItem; -} - export namespace StatusCommands { export const switchToStandardCommand = { title: "Load Projects", @@ -25,12 +21,6 @@ export namespace StatusCommands { tooltip: "LightWeight mode only provides limited features, please load projects to get full feature set" }; - export const showServerStatusCommand = { - title: "Show Build Status", - command: Commands.SHOW_SERVER_TASK_STATUS, - tooltip: "Show Build Status" - }; - export const configureJavaRuntimeCommand = { title: "Configure Java Runtime", command: "workbench.action.openSettings", @@ -47,19 +37,16 @@ export namespace StatusCommands { } export namespace RuntimeStatusItemFactory { - export function create(text: string, vmInstallPath: string): any { - if (supportsLanguageStatus()) { - const item = vscode.languages.createLanguageStatusItem("javaRuntimeStatusItem", languageServerDocumentSelector); - item.severity = vscode.LanguageStatusSeverity?.Information; - item.name = "Java Runtime"; - item.text = text; - item.command = StatusCommands.configureJavaRuntimeCommand; - if (vmInstallPath) { - item.command.tooltip = `Language Level: ${text} <${vmInstallPath}>`; - } - return item; + export function create(text: string, vmInstallPath: string): vscode.LanguageStatusItem { + const item = vscode.languages.createLanguageStatusItem("javaRuntimeStatusItem", languageServerDocumentSelector); + item.severity = vscode.LanguageStatusSeverity?.Information; + item.name = "Java Runtime"; + item.text = text; + item.command = StatusCommands.configureJavaRuntimeCommand; + if (vmInstallPath) { + item.command.tooltip = `Language Level: ${text} <${vmInstallPath}>`; } - return undefined; + return item; } export function update(item: any, text: string, vmInstallPath: string): void { @@ -69,17 +56,14 @@ export namespace RuntimeStatusItemFactory { } export namespace BuildFileStatusItemFactory { - export function create(buildFilePath: string): any { - if (supportsLanguageStatus()) { - const fileName = path.basename(buildFilePath); - const item = vscode.languages.createLanguageStatusItem("javaBuildFileStatusItem", languageServerDocumentSelector); - item.severity = vscode.LanguageStatusSeverity?.Information; - item.name = "Java Build File"; - item.text = fileName; - item.command = getOpenBuildFileCommand(buildFilePath); - return item; - } - return undefined; + export function create(buildFilePath: string): vscode.LanguageStatusItem { + const fileName = path.basename(buildFilePath); + const item = vscode.languages.createLanguageStatusItem("javaBuildFileStatusItem", languageServerDocumentSelector); + item.severity = vscode.LanguageStatusSeverity?.Information; + item.name = "Java Build File"; + item.text = fileName; + item.command = getOpenBuildFileCommand(buildFilePath); + return item; } export function update(item: any, buildFilePath: string): void { diff --git a/src/lombokSupport.ts b/src/lombokSupport.ts index bfdd77d4e..bd23144ef 100644 --- a/src/lombokSupport.ts +++ b/src/lombokSupport.ts @@ -7,8 +7,7 @@ import * as vscode from "vscode"; import { ExtensionContext, window, commands } from "vscode"; import { Commands } from "./commands"; import { apiManager } from "./apiManager"; -import { supportsLanguageStatus } from "./languageStatusItemFactory"; -import { runtimeStatusBarProvider } from './runtimeStatusBarProvider'; +import { languageStatusBarProvider } from './runtimeStatusBarProvider'; import { logger } from './log'; import { getAllJavaProjects } from "./utils"; @@ -157,11 +156,11 @@ export async function checkLombokDependency(context: ExtensionContext) { registerLombokConfigureCommand(context); isLombokCommandInitialized = true; } - runtimeStatusBarProvider.initializeLombokStatusBar(); + languageStatusBarProvider.initializeLombokStatusBar(); isLombokStatusBarInitialized = true; } if (isLombokStatusBarInitialized && !projectLombokPath) { - runtimeStatusBarProvider.destroyLombokStatusBar(); + languageStatusBarProvider.destroyLombokStatusBar(); isLombokStatusBarInitialized = false; cleanupLombokCache(context); } @@ -245,16 +244,13 @@ export function registerLombokConfigureCommand(context: ExtensionContext) { } export namespace LombokVersionItemFactory { - export function create(text: string): any { - if (supportsLanguageStatus()) { - const item = vscode.languages.createLanguageStatusItem("javaLombokVersionItem", languageServerDocumentSelector); - item.severity = vscode.LanguageStatusSeverity?.Information; - item.name = "Lombok Version"; - item.text = text; - item.command = getLombokChangeCommand(); - return item; - } - return undefined; + export function create(text: string): vscode.LanguageStatusItem { + const item = vscode.languages.createLanguageStatusItem("javaLombokVersionItem", languageServerDocumentSelector); + item.severity = vscode.LanguageStatusSeverity?.Information; + item.name = "Lombok Version"; + item.text = text; + item.command = getLombokChangeCommand(); + return item; } export function update(item: any, text: string): void { diff --git a/src/runtimeStatusBarProvider.ts b/src/runtimeStatusBarProvider.ts index ae86d9112..08fa38962 100644 --- a/src/runtimeStatusBarProvider.ts +++ b/src/runtimeStatusBarProvider.ts @@ -1,35 +1,29 @@ 'use strict'; import * as fse from "fs-extra"; -import { StatusBarItem, window, StatusBarAlignment, TextEditor, Uri, commands, workspace, version, languages, Command, ExtensionContext } from "vscode"; +import { window, TextEditor, Uri, commands, workspace, ExtensionContext, LanguageStatusItem } from "vscode"; import { Commands } from "./commands"; import { Disposable } from "vscode-languageclient"; import * as path from "path"; import { apiManager } from "./apiManager"; -import * as semver from "semver"; import { ACTIVE_BUILD_TOOL_STATE } from "./settings"; -import { BuildFileStatusItemFactory, RuntimeStatusItemFactory, StatusCommands, supportsLanguageStatus } from "./languageStatusItemFactory"; +import { BuildFileStatusItemFactory, RuntimeStatusItemFactory } from "./languageStatusItemFactory"; import { getAllJavaProjects, getJavaConfiguration, hasBuildToolConflicts } from "./utils"; import { LombokVersionItemFactory, getLombokVersion, isLombokImported } from "./lombokSupport"; -class RuntimeStatusBarProvider implements Disposable { - private statusBarItem: StatusBarItem; - private runtimeStatusItem: any; - private buildFileStatusItem: any; - private lombokVersionItem: any; +class LanguageStatusBarProvider implements Disposable { + private runtimeStatusItem: LanguageStatusItem; + private buildFileStatusItem: LanguageStatusItem; + private lombokVersionItem: LanguageStatusItem; private javaProjects: Map; private fileProjectMapping: Map; private storagePath: string | undefined; private disposables: Disposable[]; - // Adopt new API for status bar item, meanwhile keep the compatibility with Theia. - // See: https://github.com/redhat-developer/vscode-java/issues/1982 - private isAdvancedStatusBarItem: boolean; constructor() { this.javaProjects = new Map(); this.fileProjectMapping = new Map(); this.disposables = []; - this.isAdvancedStatusBarItem = semver.gte(version, "1.57.0"); } public async initialize(context: ExtensionContext): Promise { @@ -39,15 +33,6 @@ class RuntimeStatusBarProvider implements Disposable { this.storagePath = Uri.file(path.join(storagePath, "..", "..")).fsPath; } - if (!supportsLanguageStatus()) { - if (this.isAdvancedStatusBarItem) { - this.statusBarItem = (window.createStatusBarItem as any)("java.runtimeStatus", StatusBarAlignment.Right, 0); - (this.statusBarItem as any).name = "Java Runtime Configuration"; - } else { - this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, 0); - } - } - let projectUriStrings: string[]; try { projectUriStrings = await getAllJavaProjects(false); @@ -59,10 +44,6 @@ class RuntimeStatusBarProvider implements Disposable { this.javaProjects.set(Uri.parse(uri).fsPath, undefined); } - if (!supportsLanguageStatus()) { - this.statusBarItem.command = StatusCommands.configureJavaRuntimeCommand; - } - this.disposables.push(window.onDidChangeActiveTextEditor((textEditor) => { this.updateItem(context, textEditor); })); @@ -111,7 +92,6 @@ class RuntimeStatusBarProvider implements Disposable { } public dispose(): void { - this.statusBarItem?.dispose(); this.runtimeStatusItem?.dispose(); this.buildFileStatusItem?.dispose(); this.lombokVersionItem?.dispose(); @@ -176,63 +156,47 @@ class RuntimeStatusBarProvider implements Disposable { } private async updateItem(context: ExtensionContext, textEditor: TextEditor): Promise { - if (!textEditor || path.extname(textEditor.document.fileName) !== ".java" && !supportsLanguageStatus()) { - this.statusBarItem?.hide(); + if (!textEditor || path.extname(textEditor.document.fileName) !== ".java") { return; } const uri: Uri = textEditor.document.uri; const projectPath: string = this.findOwnerProject(uri); if (!projectPath) { - if (supportsLanguageStatus()) { - this.hideRuntimeStatusItem(); - this.hideBuildFileStatusItem(); - this.hideLombokVersionItem(); - } else { - this.statusBarItem?.hide(); - } + this.hideRuntimeStatusItem(); + this.hideBuildFileStatusItem(); + this.hideLombokVersionItem(); return; } const projectInfo: IProjectInfo = await this.getProjectInfo(projectPath); if (!projectInfo) { - if (supportsLanguageStatus()) { - this.hideRuntimeStatusItem(); - this.hideBuildFileStatusItem(); - this.hideLombokVersionItem(); - } else { - this.statusBarItem?.hide(); - } + this.hideRuntimeStatusItem(); + this.hideBuildFileStatusItem(); + this.hideLombokVersionItem(); return; } const text = this.getJavaRuntimeFromVersion(projectInfo.sourceLevel); - if (supportsLanguageStatus()) { - const buildFilePath = await this.getBuildFilePath(context, projectPath); - if (!this.runtimeStatusItem) { - this.runtimeStatusItem = RuntimeStatusItemFactory.create(text, projectInfo.vmInstallPath); - if (buildFilePath) { - this.buildFileStatusItem = BuildFileStatusItemFactory.create(buildFilePath); - } - } else { - RuntimeStatusItemFactory.update(this.runtimeStatusItem, text, projectInfo.vmInstallPath); - if (buildFilePath) { - BuildFileStatusItemFactory.update(this.buildFileStatusItem, buildFilePath); - } + const buildFilePath = await this.getBuildFilePath(context, projectPath); + if (!this.runtimeStatusItem) { + this.runtimeStatusItem = RuntimeStatusItemFactory.create(text, projectInfo.vmInstallPath); + if (buildFilePath) { + this.buildFileStatusItem = BuildFileStatusItemFactory.create(buildFilePath); + } + } else { + RuntimeStatusItemFactory.update(this.runtimeStatusItem, text, projectInfo.vmInstallPath); + if (buildFilePath) { + BuildFileStatusItemFactory.update(this.buildFileStatusItem, buildFilePath); } + } + + if (isLombokImported()) { if (!this.lombokVersionItem) { - if (isLombokImported()) { - this.lombokVersionItem = LombokVersionItemFactory.create(getLombokVersion()); - } + this.lombokVersionItem = LombokVersionItemFactory.create(getLombokVersion()); } else { - if (isLombokImported()) { - LombokVersionItemFactory.update(this.lombokVersionItem, getLombokVersion()); - } + LombokVersionItemFactory.update(this.lombokVersionItem, getLombokVersion()); } - } else { - this.statusBarItem.text = text; - this.statusBarItem.tooltip = projectInfo.vmInstallPath ? `Language Level: ${this.statusBarItem.text} <${projectInfo.vmInstallPath}>` : "Configure Java Runtime"; - this.statusBarItem.show(); } } @@ -302,4 +266,4 @@ interface IProjectInfo { const SOURCE_LEVEL_KEY = "org.eclipse.jdt.core.compiler.source"; const VM_INSTALL_PATH = "org.eclipse.jdt.ls.core.vm.location"; -export const runtimeStatusBarProvider: RuntimeStatusBarProvider = new RuntimeStatusBarProvider(); +export const languageStatusBarProvider: LanguageStatusBarProvider = new LanguageStatusBarProvider(); From 7bd5ded251f3906ebeddf2654943e768a3a9ede1 Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Wed, 13 Dec 2023 19:04:15 -0800 Subject: [PATCH 11/16] Remember the choice when asking project selection (#3428) - Remember the choice when asking project selection - Update @vscode/test-electron to fix macos ci Signed-off-by: Sheng Chen --- package-lock.json | 207 ++++++++------------------------------ package.json | 2 +- src/buildFilesSelector.ts | 2 + src/settings.ts | 8 +- 4 files changed, 50 insertions(+), 169 deletions(-) diff --git a/package-lock.json b/package-lock.json index b210a5d6b..14d8eca41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "@types/winston": "^2.4.4", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", - "@vscode/test-electron": "^2.1.5", + "@vscode/test-electron": "^2.3.8", "css-loader": "^6.7.3", "eslint": "^8.13.0", "eslint-webpack-plugin": "^3.2.0", @@ -1081,18 +1081,18 @@ "integrity": "sha512-3lgSTWhAzzWN/EPURoY4ZDBEA80OPmnaknNujA3qnI4Iu7AONWd9xF3iE4L+4prIe8E3TUnLQ4pxoaFTEEZNwg==" }, "node_modules/@vscode/test-electron": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.1.5.tgz", - "integrity": "sha512-O/ioqFpV+RvKbRykX2ItYPnbcZ4Hk5V0rY4uhQjQTLhGL9WZUvS7exzuYQCCI+ilSqJpctvxq2llTfGXf9UnnA==", + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.8.tgz", + "integrity": "sha512-b4aZZsBKtMGdDljAsOPObnAi7+VWIaYl3ylCz1jTs+oV6BZ4TNHcVNC3xUn0azPeszBmwSBDQYfFESIaUQnrOg==", "dev": true, "dependencies": { "http-proxy-agent": "^4.0.1", "https-proxy-agent": "^5.0.0", - "rimraf": "^3.0.2", - "unzipper": "^0.10.11" + "jszip": "^3.10.1", + "semver": "^7.5.2" }, "engines": { - "node": ">=8.9.3" + "node": ">=16" } }, "node_modules/@vscode/test-electron/node_modules/agent-base": { @@ -1157,21 +1157,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/@vscode/test-electron/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@vscode/webview-ui-toolkit": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@vscode/webview-ui-toolkit/-/webview-ui-toolkit-1.2.2.tgz", @@ -1981,28 +1966,6 @@ "node": ">=0.10.0" } }, - "node_modules/big-integer": { - "version": "1.6.51", - "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", - "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==", - "dev": true, - "engines": { - "node": ">=0.6" - } - }, - "node_modules/binary": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", - "integrity": "sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==", - "dev": true, - "dependencies": { - "buffers": "~0.1.1", - "chainsaw": "~0.1.0" - }, - "engines": { - "node": "*" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -2031,12 +1994,6 @@ "safe-buffer": "^5.1.1" } }, - "node_modules/bluebird": { - "version": "3.4.7", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", - "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==", - "dev": true - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -2169,24 +2126,6 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "node_modules/buffer-indexof-polyfill": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz", - "integrity": "sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==", - "dev": true, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/buffers": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", - "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==", - "dev": true, - "engines": { - "node": ">=0.2.0" - } - }, "node_modules/cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -2260,18 +2199,6 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, - "node_modules/chainsaw": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", - "integrity": "sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==", - "dev": true, - "dependencies": { - "traverse": ">=0.3.0 <0.4" - }, - "engines": { - "node": "*" - } - }, "node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -4703,21 +4630,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/fstream": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", - "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - }, - "engines": { - "node": ">=0.6" - } - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -5518,6 +5430,12 @@ "node": ">= 4" } }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "dev": true + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -6037,6 +5955,18 @@ "node": ">=0.6.0" } }, + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "dev": true, + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, "node_modules/just-debounce": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.1.0.tgz", @@ -6128,6 +6058,15 @@ "node": ">= 0.8.0" } }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dev": true, + "dependencies": { + "immediate": "~3.0.5" + } + }, "node_modules/liftoff": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-3.1.0.tgz", @@ -6147,12 +6086,6 @@ "node": ">= 0.8" } }, - "node_modules/listenercount": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", - "integrity": "sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==", - "dev": true - }, "node_modules/load-json-file": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", @@ -6680,18 +6613,6 @@ "node": ">=0.10.0" } }, - "node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dev": true, - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/mocha": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", @@ -7498,6 +7419,12 @@ "node": ">=6" } }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -8372,18 +8299,6 @@ "node": ">=0.10.0" } }, - "node_modules/rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -9330,15 +9245,6 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, - "node_modules/traverse": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/triple-beam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", @@ -9730,39 +9636,6 @@ "node": ">=0.10.0" } }, - "node_modules/unzipper": { - "version": "0.10.11", - "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.11.tgz", - "integrity": "sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw==", - "dev": true, - "dependencies": { - "big-integer": "^1.6.17", - "binary": "~0.3.0", - "bluebird": "~3.4.1", - "buffer-indexof-polyfill": "~1.0.0", - "duplexer2": "~0.1.4", - "fstream": "^1.0.12", - "graceful-fs": "^4.2.2", - "listenercount": "~1.0.1", - "readable-stream": "~2.3.6", - "setimmediate": "~1.0.4" - } - }, - "node_modules/unzipper/node_modules/duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", - "dev": true, - "dependencies": { - "readable-stream": "^2.0.2" - } - }, - "node_modules/unzipper/node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "dev": true - }, "node_modules/upath": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", diff --git a/package.json b/package.json index 625f4eddc..fa55079f1 100644 --- a/package.json +++ b/package.json @@ -1678,7 +1678,7 @@ "@types/vscode": "^1.77.0", "@types/winreg": "^1.2.30", "@types/winston": "^2.4.4", - "@vscode/test-electron": "^2.1.5", + "@vscode/test-electron": "^2.3.8", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", "css-loader": "^6.7.3", diff --git a/src/buildFilesSelector.ts b/src/buildFilesSelector.ts index 8a5f2695f..e654e872f 100644 --- a/src/buildFilesSelector.ts +++ b/src/buildFilesSelector.ts @@ -5,6 +5,7 @@ import { IBuildTool, getContributedBuildTools } from "./plugin"; export const PICKED_BUILD_FILES = "java.pickedBuildFiles"; export const BUILD_TOOL_FOR_CONFLICTS = "java.buildToolForConflicts"; +export const IMPORT_METHOD = "java.importMethod"; export class BuildFileSelector { /** * The build tools that are contributed/supported by extensions. @@ -295,4 +296,5 @@ interface IBuildFilePicker extends QuickPickItem { export function cleanupProjectPickerCache(context: ExtensionContext) { context.workspaceState.update(PICKED_BUILD_FILES, undefined); context.workspaceState.update(BUILD_TOOL_FOR_CONFLICTS, undefined); + context.workspaceState.update(IMPORT_METHOD, undefined); } diff --git a/src/settings.ts b/src/settings.ts index 49db09f0b..e7b06c78f 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -8,7 +8,7 @@ import { cleanupLombokCache } from './lombokSupport'; import { ensureExists, getJavaConfiguration } from './utils'; import { apiManager } from './apiManager'; import { isActive, setActive, smartSemicolonDetection } from './smartSemicolonDetection'; -import { BuildFileSelector, PICKED_BUILD_FILES } from './buildFilesSelector'; +import { BuildFileSelector, IMPORT_METHOD, PICKED_BUILD_FILES } from './buildFilesSelector'; const DEFAULT_HIDDEN_FILES: string[] = ['**/.classpath', '**/.project', '**/.settings', '**/.factorypath']; const IS_WORKSPACE_JDK_ALLOWED = "java.ls.isJdkAllowed"; @@ -370,6 +370,11 @@ export function handleTextDocumentChanges(document: TextDocument, changes: reado export async function getImportMode(context: ExtensionContext, selector: BuildFileSelector): Promise { const mode = getJavaConfiguration().get("import.projectSelection"); if (mode === "manual") { + // use automatic mode if user has selected "Import All" before. + if (context.workspaceState.get(IMPORT_METHOD) === "Import All") { + return ImportMode.automatic; + } + // if no selectable build files, use automatic mode const hasBuildFiles = await selector.hasBuildFiles(); if (!hasBuildFiles) { @@ -386,6 +391,7 @@ export async function getImportMode(context: ExtensionContext, selector: BuildFi { modal: true }, "Import All", "Let Me Select..."); if (answer === "Import All") { + context.workspaceState.update(IMPORT_METHOD, "Import All"); return ImportMode.automatic; } else if (answer === "Let Me Select...") { return ImportMode.manual; From 72a6b03b6abb418e7d5afb74750f3e0370013fb7 Mon Sep 17 00:00:00 2001 From: Hope Hadfield Date: Wed, 1 Nov 2023 13:28:36 -0400 Subject: [PATCH 12/16] Support for pasting a java file in the file explorer Signed-off-by: Hope Hadfield --- package.json | 15 ++++++++ package.nls.json | 3 +- package.nls.ko.json | 3 +- package.nls.zh-cn.json | 3 +- package.nls.zh-tw.json | 3 +- src/commands.ts | 9 +++++ src/extension.ts | 11 +++++- src/pasteAction.ts | 34 +++++++++++++++++-- test/lightweight-mode-suite/extension.test.ts | 1 + test/standard-mode-suite/extension.test.ts | 2 ++ 10 files changed, 77 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index fa55079f1..f8d057cd8 100644 --- a/package.json +++ b/package.json @@ -1487,6 +1487,11 @@ "command": "java.server.restart", "title": "%java.server.restart%", "category": "Java" + }, + { + "command": "java.action.filesExplorerPasteAction", + "title": "%java.action.filesExplorerPasteAction%", + "category": "Java" } ], "keybindings": [ @@ -1504,6 +1509,12 @@ "key": "ctrl+shift+v", "mac": "cmd+shift+v", "when": "javaLSReady && editorLangId == java" + }, + { + "command": "java.action.filesExplorerPasteAction", + "key": "ctrl+shift+v", + "mac": "cmd+shift+v", + "when": "explorerViewletFocus && config.editor.pasteAs.enabled" } ], "menus": { @@ -1622,6 +1633,10 @@ { "command": "java.server.restart", "when": "javaLSReady" + }, + { + "command": "java.action.filesExplorerPasteAction", + "when": "false" } ], "view/title": [ diff --git a/package.nls.json b/package.nls.json index e01775313..ca4690b3b 100644 --- a/package.nls.json +++ b/package.nls.json @@ -25,5 +25,6 @@ "java.project.createModuleInfo.command": "Create module-info.java", "java.clean.sharedIndexes": "Clean Shared Indexes", "java.server.restart": "Restart Java Language Server", - "java.edit.smartSemicolonDetection": "Java Smart Semicolon Detection" + "java.edit.smartSemicolonDetection": "Java Smart Semicolon Detection", + "java.action.filesExplorerPasteAction": "Paste clipboard text into a file" } diff --git a/package.nls.ko.json b/package.nls.ko.json index 359ee31b1..2e7214d92 100644 --- a/package.nls.ko.json +++ b/package.nls.ko.json @@ -22,5 +22,6 @@ "java.action.showSupertypeHierarchy": "Supertype 계층 구조 표시", "java.action.showSubtypeHierarchy": "Subtype 계층 구조 표시", "java.action.changeBaseType": "이 유형을 기준으로", - "java.project.createModuleInfo.command": "module-info.java 생성" + "java.project.createModuleInfo.command": "module-info.java 생성", + "java.action.filesExplorerPasteAction": "클립보드 텍스트를 파일에 붙여넣기" } diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json index 771247f40..ebe40f3e8 100644 --- a/package.nls.zh-cn.json +++ b/package.nls.zh-cn.json @@ -23,5 +23,6 @@ "java.action.showSubtypeHierarchy": "显示子类层次结构", "java.action.changeBaseType": "基于此类型", "java.project.createModuleInfo.command": "创建 module-info.java", - "java.clean.sharedIndexes": "清理共享的索引文件" + "java.clean.sharedIndexes": "清理共享的索引文件", + "java.action.filesExplorerPasteAction": "将剪贴板文本粘贴到文件中" } diff --git a/package.nls.zh-tw.json b/package.nls.zh-tw.json index c2e2031ae..43ca820ce 100644 --- a/package.nls.zh-tw.json +++ b/package.nls.zh-tw.json @@ -22,5 +22,6 @@ "java.action.showSupertypeHierarchy": "顯示父類別階層結構", "java.action.showSubtypeHierarchy": "顯示子類別階層結構", "java.action.changeBaseType": "以此型別為基礎", - "java.project.createModuleInfo.command": "創建 module-info.java" + "java.project.createModuleInfo.command": "創建 module-info.java", + "java.action.filesExplorerPasteAction": "將剪貼簿文字貼到文件中" } \ No newline at end of file diff --git a/src/commands.ts b/src/commands.ts index 0654ec363..5ad0a8085 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -191,6 +191,10 @@ export namespace Commands { * Custom paste action (triggers auto-import) */ export const CLIPBOARD_ONPASTE = 'java.action.clipboardPasteAction'; + /** + * Custom paste action in files explorer + */ + export const FILESEXPLORER_ONPASTE = 'java.action.filesExplorerPasteAction'; /** * Choose type to import. */ @@ -341,4 +345,9 @@ export namespace Commands { */ export const SMARTSEMICOLON_DETECTION = "java.edit.smartSemicolonDetection"; + /** + * Determine if pasted text is a java file and resolve packages + */ + export const RESOLVE_PASTED_TEXT = "java.project.resolveText"; + } diff --git a/src/extension.ts b/src/extension.ts index 5246d3b37..30cf1b506 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -37,6 +37,7 @@ import { TelemetryService } from '@redhat-developer/vscode-redhat-telemetry/lib' import { activationProgressNotification } from "./serverTaskPresenter"; import { loadSupportedJreNames } from './jdkUtils'; import { BuildFileSelector, PICKED_BUILD_FILES, cleanupProjectPickerCache } from './buildFilesSelector'; +import { pasteFile } from './pasteAction'; const syntaxClient: SyntaxLanguageClient = new SyntaxLanguageClient(); const standardClient: StandardLanguageClient = new StandardLanguageClient(); @@ -93,6 +94,14 @@ function getHeapDumpFolderFromSettings(): string { export async function activate(context: ExtensionContext): Promise { await loadSupportedJreNames(context); + context.subscriptions.push(commands.registerCommand(Commands.FILESEXPLORER_ONPASTE, async () => { + const originalClipboard = await env.clipboard.readText(); + // Hack in order to get path to selected folder if applicable (see https://github.com/microsoft/vscode/issues/3553#issuecomment-1098562676) + await commands.executeCommand('copyFilePath'); + const folder = await env.clipboard.readText(); + await env.clipboard.writeText(originalClipboard); + pasteFile(folder); + })); context.subscriptions.push(markdownPreviewProvider); context.subscriptions.push(commands.registerCommand(Commands.TEMPLATE_VARIABLES, async () => { markdownPreviewProvider.show(context.asAbsolutePath(path.join('document', `${Commands.TEMPLATE_VARIABLES}.md`)), 'Predefined Variables', "", context); @@ -650,7 +659,7 @@ function enableJavadocSymbols() { }); } -function getTempWorkspace() { +export function getTempWorkspace() { return path.resolve(os.tmpdir(), `vscodesws_${makeRandomHexString(5)}`); } diff --git a/src/pasteAction.ts b/src/pasteAction.ts index c500f0f3e..4a3f83adf 100644 --- a/src/pasteAction.ts +++ b/src/pasteAction.ts @@ -1,9 +1,11 @@ 'use strict'; -import { commands, env, ExtensionContext, Range, TextEditor, window } from 'vscode'; +import { TextEncoder } from 'util'; +import { commands, env, ExtensionContext, Range, TextEditor, Uri, window, workspace } from 'vscode'; import { LanguageClient } from 'vscode-languageclient/node'; - +import { apiManager } from './apiManager'; import { Commands } from './commands'; +import fs = require('fs'); export function registerCommands(languageClient: LanguageClient, context: ExtensionContext) { context.subscriptions.push(commands.registerCommand(Commands.CLIPBOARD_ONPASTE, () => { @@ -48,4 +50,32 @@ export async function registerOrganizeImportsOnPasteCommand(): Promise { } } }); +} + +let serverReady = false; + +export async function pasteFile(folder: fs.PathLike): Promise { + const clipboardText: string = await env.clipboard.readText(); + let filePath = folder.toString(); + fs.stat(folder, async (err, stats) => { + // If given path to selected folder is invalid (no folder is selected) + if (filePath === clipboardText || stats.isFile() || (filePath === "." && workspace.workspaceFolders !== undefined)) { + filePath = workspace.workspaceFolders[0].uri.fsPath; + } + if (!serverReady) { + await apiManager.getApiInstance().serverReady().then( async () => { + serverReady = true; + }); + } + const fileString: string = await commands.executeCommand(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.RESOLVE_PASTED_TEXT, filePath, clipboardText); + const fileUri = fileString !== null ? Uri.file(fileString) : null; + if (fileUri !== null){ + try { + await workspace.fs.writeFile(fileUri, new TextEncoder().encode(clipboardText)); + window.showTextDocument(fileUri, { preview: false }); + } catch (error: unknown) { + // Do nothing (file does not have write permissions) + } + } + }); } \ No newline at end of file diff --git a/test/lightweight-mode-suite/extension.test.ts b/test/lightweight-mode-suite/extension.test.ts index 495e90624..b3424da6c 100644 --- a/test/lightweight-mode-suite/extension.test.ts +++ b/test/lightweight-mode-suite/extension.test.ts @@ -25,6 +25,7 @@ suite('Java Language Extension - LightWeight', () => { Commands.OPEN_FILE, Commands.CLEAN_SHARED_INDEXES, Commands.RESTART_LANGUAGE_SERVER, + Commands.FILESEXPLORER_ONPASTE ].sort(); const foundJavaCommands = commands.filter((value) => { return JAVA_COMMANDS.indexOf(value)>=0 || value.startsWith('java.'); diff --git a/test/standard-mode-suite/extension.test.ts b/test/standard-mode-suite/extension.test.ts index 3fd5828b7..c364990e8 100644 --- a/test/standard-mode-suite/extension.test.ts +++ b/test/standard-mode-suite/extension.test.ts @@ -118,6 +118,8 @@ suite('Java Language Extension - Standard', () => { Commands.UPDATE_SOURCE_ATTACHMENT_CMD, Commands.SMARTSEMICOLON_DETECTION, Commands.RESOLVE_SOURCE_ATTACHMENT, + Commands.FILESEXPLORER_ONPASTE, + Commands.RESOLVE_PASTED_TEXT, ].sort(); const foundJavaCommands = commands.filter((value) => { return JAVA_COMMANDS.indexOf(value)>=0 || value.startsWith('java.'); From 1cb8d0c77fb2a0da1381520bac65e36826a40c84 Mon Sep 17 00:00:00 2001 From: Hope Hadfield Date: Thu, 14 Dec 2023 10:47:55 -0500 Subject: [PATCH 13/16] Change scope of 'java.import.gradle.home' to machine-overridable Signed-off-by: Hope Hadfield --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f8d057cd8..2ce350485 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "java.home", "java.jdt.ls.vmargs", "java.configuration.runtimes", - "java.import.gradle.java.home" + "java.import.gradle.java.home", + "java.import.gradle.home" ] }, "virtualWorkspaces": false @@ -641,7 +642,7 @@ "type": "string", "default": null, "description": "Use Gradle from the specified local installation directory or GRADLE_HOME if the Gradle wrapper is missing or disabled and no 'java.import.gradle.version' is specified.", - "scope": "window", + "scope": "machine-overridable", "order": 40 }, "java.import.gradle.java.home": { From eaeedf791546fed4eaa9312b6252faa951ce1b5e Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Nov 2023 09:27:40 +0100 Subject: [PATCH 14/16] Add SQL block highlighting support --- language-support/sql/inline-sql.json | 46 ++++++++++++++++++++++++++++ package.json | 10 ++++++ 2 files changed, 56 insertions(+) create mode 100644 language-support/sql/inline-sql.json diff --git a/language-support/sql/inline-sql.json b/language-support/sql/inline-sql.json new file mode 100644 index 000000000..9d13e384f --- /dev/null +++ b/language-support/sql/inline-sql.json @@ -0,0 +1,46 @@ +{ + "injectionSelector": "L:source.java -comment -string", + "patterns": [ + { + "contentName": "meta.embedded.block.sql", + "begin": "(?i)((/\\*\\s*(language=sql)\\s*\\*/)|((//\\s*(language=sql)\\s*)))", + "beginCaptures": { + "1": { + "name": "comment.block" + } + }, + "end": "(?<=\")", + "patterns": [ + { + "begin": "\\s*(\"\"\")$", + "beginCaptures": { + "0": { "name": "string.quoted.triple.java" } + }, + "end": "\\s*(\"\"\")", + "endCaptures": { + "0": { "name": "string.quoted.triple.java" } + }, + "patterns": [ + { "include": "source.sql" }, + { "include": "source.plpgsql.postgres" } + ] + }, + { + "begin": "\\s*(\")", + "beginCaptures": { + "0": { "name": "string.quoted.double.java" } + }, + "end": "\\s*(\")", + "endCaptures": { + "0": { "name": "string.quoted.double.java" } + }, + "patterns": [ + { "include": "source.sql" }, + { "include": "source.plpgsql.postgres" } + ] + } + ] + } + ], + "scopeName": "inline.sql" +} diff --git a/package.json b/package.json index 2ce350485..c9901d81f 100644 --- a/package.json +++ b/package.json @@ -212,6 +212,16 @@ "language": "gradle-kotlin-dsl", "scopeName": "source.kotlin", "path": "./language-support/kotlin/kotlin.tmLanguage.json" + }, + { + "injectTo": [ + "source.java" + ], + "scopeName": "inline.sql", + "path": "./language-support/sql/inline-sql.json", + "embeddedLanguages": { + "meta.embedded.block.sql": "sql" + } } ], "jsonValidation": [ From b8fd15872fabe5e5b22c73730dd47021f601c40a Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Thu, 21 Dec 2023 15:53:39 +0800 Subject: [PATCH 15/16] Reduce delegate command calls when classpath changes Signed-off-by: Sheng Chen --- src/lombokSupport.ts | 6 +++--- src/standardLanguageClient.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lombokSupport.ts b/src/lombokSupport.ts index bd23144ef..f40885e48 100644 --- a/src/lombokSupport.ts +++ b/src/lombokSupport.ts @@ -4,7 +4,7 @@ import * as fse from "fs-extra"; import * as path from "path"; import * as semver from 'semver'; import * as vscode from "vscode"; -import { ExtensionContext, window, commands } from "vscode"; +import { ExtensionContext, window, commands, Uri } from "vscode"; import { Commands } from "./commands"; import { apiManager } from "./apiManager"; import { languageStatusBarProvider } from './runtimeStatusBarProvider'; @@ -117,7 +117,7 @@ export function addLombokParam(context: ExtensionContext, params: string[]) { updateActiveLombokPath(lombokJarPath); } -export async function checkLombokDependency(context: ExtensionContext) { +export async function checkLombokDependency(context: ExtensionContext, projectUri?: Uri) { if (!isLombokSupportEnabled()) { return; } @@ -126,7 +126,7 @@ export async function checkLombokDependency(context: ExtensionContext) { let currentLombokVersion: string = undefined; let previousLombokVersion: string = undefined; let currentLombokClasspath: string = undefined; - const projectUris: string[] = await getAllJavaProjects(); + const projectUris: string[] = projectUri ? [projectUri.toString()] : await getAllJavaProjects(); for (const projectUri of projectUris) { const classpathResult = await apiManager.getApiInstance().getClasspaths(projectUri, {scope: 'test'}); for (const classpath of classpathResult.classpaths) { diff --git a/src/standardLanguageClient.ts b/src/standardLanguageClient.ts index b04fa8802..b98c184e7 100644 --- a/src/standardLanguageClient.ts +++ b/src/standardLanguageClient.ts @@ -143,8 +143,8 @@ export class StandardLanguageClient { showImportFinishNotification(context); } checkLombokDependency(context); - apiManager.getApiInstance().onDidClasspathUpdate((e: Uri) => { - checkLombokDependency(context); + apiManager.getApiInstance().onDidClasspathUpdate((projectUri: Uri) => { + checkLombokDependency(context, projectUri); }); // Disable the client-side snippet provider since LS is ready. snippetCompletionProvider.dispose(); From 392a255188f4b72c6e9004ca7982e06c7dd9669e Mon Sep 17 00:00:00 2001 From: Snjezana Peco Date: Tue, 19 Dec 2023 18:24:18 +0100 Subject: [PATCH 16/16] Add java.compile.nullAnalysis.nonnullbydefault property --- README.md | 3 +++ package.json | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 502544db8..0e54caa4d 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,9 @@ The following settings are supported: * `java.edit.smartSemicolonDetection.enabled`: Defines the `smart semicolon` detection. Defaults to `false`. * `java.configuration.detectJdksAtStart`: Automatically detect JDKs installed on local machine at startup. If you have specified the same JDK version in `java.configuration.runtimes`, the extension will use that version first. Defaults to `true`. +New in 1.26.0 +* `java.compile.nullAnalysis.nonnullbydefault`: Specify the NonNullByDefault annotation types to be used for null analysis. If more than one annotation is specified, then the topmost annotation will be used first if it exists in your project dependencies. This setting will be ignored if `java.compile.nullAnalysis.mode` is set to `disabled`. + Semantic Highlighting =============== [Semantic Highlighting](https://github.com/redhat-developer/vscode-java/wiki/Semantic-Highlighting) fixes numerous syntax highlighting issues with the default Java Textmate grammar. However, you might experience a few minor issues, particularly a delay when it kicks in, as it needs to be computed by the Java Language server, when opening a new file or when typing. Semantic highlighting can be disabled for all languages using the `editor.semanticHighlighting.enabled` setting, or for Java only using [language-specific editor settings](https://code.visualstudio.com/docs/getstarted/settings#_languagespecific-editor-settings). diff --git a/package.json b/package.json index c9901d81f..03a31b16d 100644 --- a/package.json +++ b/package.json @@ -772,6 +772,16 @@ "markdownDescription": "Specify the Nullable annotation types to be used for null analysis. If more than one annotation is specified, then the topmost annotation will be used first if it exists in project dependencies. This setting will be ignored if `java.compile.nullAnalysis.mode` is set to `disabled`", "scope": "window" }, + "java.compile.nullAnalysis.nonnullbydefault": { + "type": "array", + "default": [ + "javax.annotation.ParametersAreNonnullByDefault", + "org.eclipse.jdt.annotation.NonNullByDefault", + "org.springframework.lang.NonNullApi" + ], + "markdownDescription": "Specify the NonNullByDefault annotation types to be used for null analysis. If more than one annotation is specified, then the topmost annotation will be used first if it exists in project dependencies. This setting will be ignored if `java.compile.nullAnalysis.mode` is set to `disabled`", + "scope": "window" + }, "java.compile.nullAnalysis.mode": { "type": "string", "enum": [