From 6c40f3df69a61c07fc5cef6257c76ee14bb07635 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Tue, 23 Jan 2024 14:42:06 -0800 Subject: [PATCH] Support JetBrains IDEs 2024.1 (#5960) * Bump JetBrains IDEs to 2024.1 * Apply formatting comments * Include copyright headers in sdkcompat files * Apply review comments * Do not reference empty jsr library in CLion 2024.1 build --- WORKSPACE | 82 ++++++++- base/BUILD | 1 + .../blaze/clwb/run/GoogleTestUtilAdapter.java | 2 +- common/actions/BUILD | 1 + common/settings/BUILD | 1 + common/util/BUILD | 1 + cpp/sdkcompat/BUILD | 1 + cpp/sdkcompat/v241/BUILD | 19 +++ .../OCWorkspaceModifiableModelDisposer.java | 29 ++++ .../idea/blaze/cpp/SourceFileFinder.java | 2 +- intellij_platform_sdk/BUILD | 42 ++++- intellij_platform_sdk/BUILD.clion241 | 112 ++++++++++++ intellij_platform_sdk/BUILD.idea241 | 132 ++++++++++++++ intellij_platform_sdk/BUILD.ue241 | 161 ++++++++++++++++++ intellij_platform_sdk/build_defs.bzl | 31 +++- java/BUILD | 1 + kotlin/BUILD | 1 + sdkcompat/BUILD | 3 + sdkcompat/v241/BUILD | 65 +++++++ .../CMakeNotificationProviderWrapper.java | 48 ++++++ .../cpp/CidrOwnModuleDetectorWrapper.java | 21 +++ .../editor/markup/UIControllerCreator.java | 71 ++++++++ .../repo/AbstractRepositoryManagerCompat.java | 32 ++++ .../idea/sdkcompat/general/BaseSdkCompat.java | 127 ++++++++++++++ .../general/EditorNotificationCompat.java | 27 +++ ...itorNotificationProviderWrapperCompat.java | 63 +++++++ .../google/idea/sdkcompat/go/GoSdkCompat.java | 26 +++ .../java/AttachSourcesProviderAdapter.java | 52 ++++++ .../javascript/JSModuleResolutionWrapper.java | 35 ++++ .../javascript/JSModuleTargetWrapper.java | 35 ++++ .../javascript/TypeScriptConfigAdapter.java | 62 +++++++ .../TypeScriptConfigServiceAdapter.java | 27 +++ .../idea/sdkcompat/kotlin/KotlinCompat.java | 145 ++++++++++++++++ .../sdkcompat/logging/HandlerWrapper.java | 37 ++++ .../sdkcompat/logging/LogRecordWrapper.java | 65 +++++++ .../idea/sdkcompat/logging/LoggerWrapper.java | 33 ++++ .../psi/impl/imports/FileReferenceCompat.java | 49 ++++++ ...legatingRenamePsiElementProcessorBase.java | 61 +++++++ .../JavaSafeDeleteProcessorCompat.java | 40 +++++ .../idea/sdkcompat/scala/ScalaCompat.java | 38 +++++ .../sdkcompat/ui/icons/IconManagerCompat.java | 33 ++++ ...eIntegrationRecordsConfirmationOption.java | 52 ++++++ .../vcs/changes/ChangeListAdapterCompat.java | 34 ++++ .../vcs/changes/FakeRevisionCompat.java | 28 +++ .../changes/ui/ChangesListViewCreator.java | 29 ++++ .../impl/VcsBaseContentProviderDelegator.java | 39 +++++ testing/BUILD | 14 ++ .../com/google/idea/java/JavaSdkCompat.java | 46 +++++ .../idea/sdkcompat/BaseSdkTestCompat.java | 61 +++++++ .../roots/ex/ProjectRootManagerExWrapper.java | 36 ++++ .../idea/testing/TestRunnerUtilCompat.java | 27 +++ .../testing/java/BaseJavaSdkTestCompat.java | 33 ++++ third_party/devkit/BUILD | 2 + third_party/go/BUILD | 2 + third_party/javascript/BUILD | 4 + third_party/python/BUILD | 6 + third_party/scala/BUILD | 2 + 57 files changed, 2220 insertions(+), 9 deletions(-) create mode 100644 cpp/sdkcompat/v241/BUILD create mode 100644 cpp/sdkcompat/v241/com/google/idea/blaze/cpp/qsync/OCWorkspaceModifiableModelDisposer.java create mode 100644 intellij_platform_sdk/BUILD.clion241 create mode 100644 intellij_platform_sdk/BUILD.idea241 create mode 100644 intellij_platform_sdk/BUILD.ue241 create mode 100644 sdkcompat/v241/BUILD create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/clion/CMakeNotificationProviderWrapper.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/cpp/CidrOwnModuleDetectorWrapper.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/editor/markup/UIControllerCreator.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/fig/repo/AbstractRepositoryManagerCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/general/BaseSdkCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/general/EditorNotificationCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/general/PluginAdvertiserEditorNotificationProviderWrapperCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/go/GoSdkCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/java/AttachSourcesProviderAdapter.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleResolutionWrapper.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleTargetWrapper.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigAdapter.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigServiceAdapter.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/kotlin/KotlinCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/logging/HandlerWrapper.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/logging/LogRecordWrapper.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/logging/LoggerWrapper.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/psi/impl/imports/FileReferenceCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/refactoring/rename/DelegatingRenamePsiElementProcessorBase.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/refactoring/safedelete/JavaSafeDeleteProcessorCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/scala/ScalaCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/ui/icons/IconManagerCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/vcs/RemoveIntegrationRecordsConfirmationOption.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ChangeListAdapterCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/FakeRevisionCompat.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ui/ChangesListViewCreator.java create mode 100644 sdkcompat/v241/com/google/idea/sdkcompat/vcs/impl/VcsBaseContentProviderDelegator.java create mode 100644 testing/testcompat/v241/com/google/idea/java/JavaSdkCompat.java create mode 100644 testing/testcompat/v241/com/google/idea/sdkcompat/BaseSdkTestCompat.java create mode 100644 testing/testcompat/v241/com/google/idea/sdkcompat/roots/ex/ProjectRootManagerExWrapper.java create mode 100644 testing/testcompat/v241/com/google/idea/testing/TestRunnerUtilCompat.java create mode 100644 testing/testcompat/v241/com/google/idea/testing/java/BaseJavaSdkTestCompat.java diff --git a/WORKSPACE b/WORKSPACE index 89c778464c9..bb1d38bdd59 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -83,6 +83,18 @@ http_archive( url = IC_233_URL, ) +# The plugin api for intellij_ce_2024_1. This is required to build IJwB and run integration tests. +IC_241_SHA = "b1deacab7964751e135b462b65c1348e98640f0a6094363643e2eacf874b5812" + +IC_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIC/241.8102.112-EAP-SNAPSHOT/ideaIC-241.8102.112-EAP-SNAPSHOT.zip" + +http_archive( + name = "intellij_ce_2024_1", + build_file = "@//intellij_platform_sdk:BUILD.idea241", + sha256 = IC_241_SHA, + url = IC_241_URL, +) + # The plugin api for IntelliJ UE 2021.2. This is required to run UE-specific # integration tests. http_archive( @@ -159,6 +171,17 @@ http_archive( url = IU_233_URL, ) +IU_241_SHA = "a89ca40374d7495e1b31df14f14fd0479b4948800b6a3cb082bc392fddf04ae3" + +IU_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIU/241.8102.112-EAP-SNAPSHOT/ideaIU-241.8102.112-EAP-SNAPSHOT.zip" + +http_archive( + name = "intellij_ue_2024_1", + build_file = "@//intellij_platform_sdk:BUILD.ue241", + sha256 = IU_241_SHA, + url = IU_241_URL, +) + # The plugin api for clion_2021_2. This is required to build CLwB, and run integration tests. http_archive( name = "clion_2021_2", @@ -234,6 +257,17 @@ http_archive( url = CLION_233_URL, ) +CLION_241_SHA = "099e05aa25233814f45fc14a0d3831d23dd23f6ec215c39b51ba364c5051446d" + +CLION_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/clion/clion/241.8102.118-EAP-SNAPSHOT/clion-241.8102.118-EAP-SNAPSHOT.zip" + +http_archive( + name = "clion_2024_1", + build_file = "@//intellij_platform_sdk:BUILD.clion241", + sha256 = CLION_241_SHA, + url = CLION_241_URL, +) + DEVKIT_BUILD_FILE = """ java_import( name = "devkit", @@ -253,6 +287,17 @@ http_archive( url = DEVKIT_233_URL, ) +DEVKIT_241_SHA = "afd94744e647117eae959a41c7410269259ab5d0411a64148759b046093b0139" + +DEVKIT_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/DevKit/241.8102.119/DevKit-241.8102.119.zip" + +http_archive( + name = "devkit_2024_1", + build_file_content = DEVKIT_BUILD_FILE, + sha256 = DEVKIT_241_SHA, + url = DEVKIT_241_URL, +) + _PYTHON_CE_BUILD_FILE = """ java_import( name = "python", @@ -360,6 +405,17 @@ http_archive( url = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/232.9921.47/PythonCore-232.9921.47.zip", ) +PYTHON_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/241.8102.112/PythonCore-241.8102.112.zip" + +PYTHON_PLUGIN_241_SHA = "cc20c45dec7defe17346b5da06cf508c19b5f2517fc5187cde4a2ebb97bc2712" + +http_archive( + name = "python_2024_1", + build_file_content = _PYTHON_CE_BUILD_FILE, + sha256 = PYTHON_PLUGIN_241_SHA, + url = PYTHON_PLUGIN_241_URL, +) + _GO_BUILD_FILE = """ java_import( name = "go", @@ -447,6 +503,17 @@ http_archive( url = GO_PLUGIN_233_URL, ) +GO_PLUGIN_241_SHA = "fd759b4947622f931ebefdd6a20d9dc611196ba44203827fd8e80f3cfd707bff" + +GO_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.jetbrains.plugins.go/241.8102.112/org.jetbrains.plugins.go-241.8102.112.zip" + +http_archive( + name = "go_2024_1", + build_file_content = _GO_BUILD_FILE_223, + sha256 = GO_PLUGIN_241_SHA, + url = GO_PLUGIN_241_URL, +) + _SCALA_BUILD_FILE = """ java_import( name = "scala", @@ -526,6 +593,17 @@ http_archive( url = SCALA_PLUGIN_233_URL, ) +SCALA_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.intellij.scala/2024.1.1/org.intellij.scala-2024.1.1.zip" + +SCALA_PLUGIN_241_SHA = "412f3be2ec29a9603eb8b6015d0aecff26cb477c80da312e2c66729b9ec68469" + +http_archive( + name = "scala_2024_1", + build_file_content = _SCALA_BUILD_FILE, + sha256 = SCALA_PLUGIN_241_SHA, + url = SCALA_PLUGIN_241_URL, +) + # The plugin api for android_studio_2022_2 android_studio. This is required to build ASwB and run integration tests http_archive( name = "android_studio_2022_2", @@ -664,8 +742,8 @@ jvm_maven_import_external( jvm_maven_import_external( name = "error_prone_annotations", - artifact = "com.google.errorprone:error_prone_annotations:2.13.1", - artifact_sha256 = "f5ee2aac2ee6443789e1dee0f96e3c35d9f3c78891f54ed83f3cf918a1cde6d1", + artifact = "com.google.errorprone:error_prone_annotations:2.24.1", + artifact_sha256 = "19fe2f7155d20ea093168527999da98108103ee546d1e8b726bc4b27c31a3c30", licenses = ["notice"], # Apache 2.0 server_urls = ["https://repo1.maven.org/maven2"], ) diff --git a/base/BUILD b/base/BUILD index c8b88c16510..36d64743aea 100644 --- a/base/BUILD +++ b/base/BUILD @@ -458,6 +458,7 @@ java_library( "//third_party/auto_value", "//third_party/bazel/src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto", "@com_google_guava_guava//jar", + "@error_prone_annotations//jar", "@junit//jar", ], ) diff --git a/clwb/src/com/google/idea/blaze/clwb/run/GoogleTestUtilAdapter.java b/clwb/src/com/google/idea/blaze/clwb/run/GoogleTestUtilAdapter.java index 0c23edb2d14..5bd93adb75e 100644 --- a/clwb/src/com/google/idea/blaze/clwb/run/GoogleTestUtilAdapter.java +++ b/clwb/src/com/google/idea/blaze/clwb/run/GoogleTestUtilAdapter.java @@ -32,7 +32,7 @@ static PsiElement findGoogleTestSymbol(Project project) { throw new IllegalStateException("More than 1 extension for " + EP_NAME.getName() + " is not supported"); } - GoogleTestUtilAdapter adapter = EP_NAME.getPoint().extensions().findFirst().orElse(null); + GoogleTestUtilAdapter adapter = EP_NAME.getPoint().getExtensionList().stream().findFirst().orElse(null); if (adapter != null) { return adapter.findGoogleTestSymbol(project, testScopeElement -> true); } diff --git a/common/actions/BUILD b/common/actions/BUILD index a4b5fd8330d..eb662a3180c 100644 --- a/common/actions/BUILD +++ b/common/actions/BUILD @@ -13,5 +13,6 @@ java_library( "//intellij_platform_sdk:jsr305", "//intellij_platform_sdk:plugin_api", "//sdkcompat", + "@error_prone_annotations//jar", ], ) diff --git a/common/settings/BUILD b/common/settings/BUILD index fef6f42fc02..0b2ccc3ae98 100644 --- a/common/settings/BUILD +++ b/common/settings/BUILD @@ -13,5 +13,6 @@ java_library( "//intellij_platform_sdk:jsr305", "//intellij_platform_sdk:plugin_api", "//third_party/auto_value", + "@error_prone_annotations//jar", ], ) diff --git a/common/util/BUILD b/common/util/BUILD index aeb44a05e68..7c6c1e97111 100644 --- a/common/util/BUILD +++ b/common/util/BUILD @@ -42,6 +42,7 @@ java_library( deps = [ "//intellij_platform_sdk:jsr305", # unuseddeps: keep for @Nullable "//intellij_platform_sdk:plugin_api", + "@error_prone_annotations//jar", ], ) diff --git a/cpp/sdkcompat/BUILD b/cpp/sdkcompat/BUILD index c5510817477..0f851876966 100644 --- a/cpp/sdkcompat/BUILD +++ b/cpp/sdkcompat/BUILD @@ -13,6 +13,7 @@ java_library( "clion-2023.1": ["//cpp/sdkcompat/v231"], "clion-2023.2": ["//cpp/sdkcompat/v232"], "clion-2023.3": ["//cpp/sdkcompat/v233"], + "clion-2024.1": ["//cpp/sdkcompat/v241"], }), visibility = ["//cpp:__pkg__"], deps = ["//intellij_platform_sdk:plugin_api"], diff --git a/cpp/sdkcompat/v241/BUILD b/cpp/sdkcompat/v241/BUILD new file mode 100644 index 00000000000..a8df8acebaf --- /dev/null +++ b/cpp/sdkcompat/v241/BUILD @@ -0,0 +1,19 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filegroup( + name = "v241", + srcs = glob(["**/*.java"]), + visibility = ["//cpp/sdkcompat:__pkg__"], +) diff --git a/cpp/sdkcompat/v241/com/google/idea/blaze/cpp/qsync/OCWorkspaceModifiableModelDisposer.java b/cpp/sdkcompat/v241/com/google/idea/blaze/cpp/qsync/OCWorkspaceModifiableModelDisposer.java new file mode 100644 index 00000000000..2a493b7886c --- /dev/null +++ b/cpp/sdkcompat/v241/com/google/idea/blaze/cpp/qsync/OCWorkspaceModifiableModelDisposer.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.blaze.cpp.qsync; + +import com.intellij.openapi.util.Disposer; +import com.jetbrains.cidr.lang.workspace.OCWorkspace; + +/** SDK compat class for {@link OCWorkspace.ModifiableModel} */ +public class OCWorkspaceModifiableModelDisposer { + + private OCWorkspaceModifiableModelDisposer() {} + + public static void dispose(OCWorkspace.ModifiableModel modifiableModel) { + Disposer.dispose(modifiableModel); + } +} diff --git a/cpp/src/com/google/idea/blaze/cpp/SourceFileFinder.java b/cpp/src/com/google/idea/blaze/cpp/SourceFileFinder.java index a1e23593672..15382506736 100644 --- a/cpp/src/com/google/idea/blaze/cpp/SourceFileFinder.java +++ b/cpp/src/com/google/idea/blaze/cpp/SourceFileFinder.java @@ -32,7 +32,7 @@ static VirtualFile findAndGetSourceFileForHeaderFile(Project project, VirtualFil throw new IllegalStateException("More than 1 extension for " + EP_NAME.getName() + " is not supported"); } - SourceFileFinder finder = EP_NAME.getPoint().extensions().findFirst().orElse(null); + SourceFileFinder finder = EP_NAME.getPoint().getExtensionList().stream().findFirst().orElse(null); if (finder != null) { return finder.getSourceFileForHeaderFile(project, headerFile); } diff --git a/intellij_platform_sdk/BUILD b/intellij_platform_sdk/BUILD index f667887d1d9..a14f7cd0bc3 100644 --- a/intellij_platform_sdk/BUILD +++ b/intellij_platform_sdk/BUILD @@ -220,6 +220,19 @@ config_setting( }, ) +config_setting( + name = "intellij-2024.1", + values = {"define": "ij_product=intellij-2024.1"}, +) + +config_setting( + name = "intellij-2024.1-mac", + values = { + "define": "ij_product=intellij-2024.1", + "cpu": "darwin_x86_64", + }, +) + config_setting( name = "intellij-2023.3-mac", values = { @@ -325,6 +338,18 @@ config_setting( }, ) +config_setting( + name = "intellij-ue-2024.1", + values = {"define": "ij_product=intellij-ue-2024.1"}, +) + +config_setting( + name = "intellij-ue-2024.1-mac", + values = { + "define": "ij_product=intellij-ue-2024.1", + "cpu": "darwin_x86_64", + }, +) config_setting( name = "intellij-ue-2023.1-mac", @@ -613,6 +638,19 @@ config_setting( }, ) +config_setting( + name = "clion-2024.1", + values = {"define": "ij_product=clion-2024.1"}, +) + +config_setting( + name = "clion-2024.1-mac", + values = { + "define": "ij_product=clion-2024.1", + "cpu": "darwin_x86_64", + }, +) + config_setting( name = "clion-2023.3-mac", values = { @@ -621,7 +659,6 @@ config_setting( }, ) - config_setting( name = "intellij-cc-oldest-stable", values = { @@ -763,6 +800,7 @@ java_library( "clion-2022.1": ["@jsr305_annotations//jar"], "clion-2022.2": ["@jsr305_annotations//jar"], "clion-2022.3": ["@jsr305_annotations//jar"], + "clion-2024.1": [], "intellij-2021.3": ["@jsr305_annotations//jar"], "intellij-2022.1": ["@jsr305_annotations//jar"], "intellij-2022.2": ["@jsr305_annotations//jar"], @@ -770,6 +808,7 @@ java_library( "intellij-2023.1": ["@jsr305_annotations//jar"], "intellij-2023.2": ["@jsr305_annotations//jar"], "intellij-2023.3": ["@jsr305_annotations//jar"], + "intellij-2024.1": ["@jsr305_annotations//jar"], "intellij-ue-2021.3": ["@jsr305_annotations//jar"], "intellij-ue-2022.1": ["@jsr305_annotations//jar"], "intellij-ue-2022.2": ["@jsr305_annotations//jar"], @@ -777,6 +816,7 @@ java_library( "intellij-ue-2023.1": ["@jsr305_annotations//jar"], "intellij-ue-2023.2": ["@jsr305_annotations//jar"], "intellij-ue-2023.3": ["@jsr305_annotations//jar"], + "intellij-ue-2024.1": ["@jsr305_annotations//jar"], "android-studio-2022.2": ["@jsr305_annotations//jar"], "android-studio-2022.3": ["@jsr305_annotations//jar"], "android-studio-2023.1": ["@jsr305_annotations//jar"], diff --git a/intellij_platform_sdk/BUILD.clion241 b/intellij_platform_sdk/BUILD.clion241 new file mode 100644 index 00000000000..9f6f8183abb --- /dev/null +++ b/intellij_platform_sdk/BUILD.clion241 @@ -0,0 +1,112 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Description: +# +# Plugin source jars for CLion, accessed remotely. + +load("@//intellij_platform_sdk:build_defs.bzl", "no_mockito_extensions") + +package(default_visibility = ["//visibility:public"]) + +java_import( + name = "sdk", + jars = glob( + ["lib/*.jar"], + exclude = [ + # mockito-extensions needs to be removed from this jar. + "lib/testFramework.jar", + ], + ), + tags = ["intellij-provided-by-sdk"], + exports = [":jars_without_mockito_extensions"], + deps = ["@error_prone_annotations//jar"], +) + +no_mockito_extensions( + name = "jars_without_mockito_extensions", + jars = ["lib/testFramework.jar"], +) + +java_import( + name = "guava", + jars = glob([ + "lib/lib.jar", + "lib/lib-client.jar", + ]), +) + +java_import( + name = "clion_plugins", + jars = glob([ + "plugins/c-plugin/lib/*.jar", + "plugins/cidr-base-plugin/lib/*.jar", + "plugins/cidr-debugger-plugin/lib/*.jar", + "plugins/clion/lib/*.jar", + "plugins/clion-test-google/lib/*.jar", + "plugins/clion-test-catch/lib/*.jar", + "plugins/clion-test-boost/lib/*.jar", + "plugins/nativeDebug-plugin/lib/*.jar", + "plugins/clion-ide/lib/clion-ide.jar", # For CMakeNotificationProvider + "plugins/clion-test-google-plugin/lib/clion-test-google-plugin.jar", # for com.jetbrains.cidr.execution.testing.google + ]), +) + +java_import( + name = "hg4idea", + jars = glob(["plugins/hg4idea/lib/hg4idea.jar"]), +) + +java_import( + name = "javascript", + jars = glob(["plugins/javascript-impl/lib/*.jar"]), +) + +java_import( + name = "css", + jars = glob(["plugins/css-impl/lib/*.jar"]), +) + +java_import( + name = "tslint", + jars = glob(["plugins/tslint/lib/*.jar"]), +) + +java_import( + name = "terminal", + jars = glob(["plugins/terminal/lib/terminal.jar"]), +) + +java_import( + name = "python", + jars = glob(["plugins/python-ce/lib/*.jar"]), +) + +filegroup( + name = "python_helpers", + srcs = glob(["plugins/python-ce/helpers/**/*"]), +) + +# The plugins required by CLwB. Presumably there will be some, when we write +# some integration tests. +java_import( + name = "bundled_plugins", + jars = [], + tags = ["intellij-provided-by-sdk"], +) + +filegroup( + name = "application_info_json", + srcs = ["product-info.json"], +) diff --git a/intellij_platform_sdk/BUILD.idea241 b/intellij_platform_sdk/BUILD.idea241 new file mode 100644 index 00000000000..bf5e1a29dca --- /dev/null +++ b/intellij_platform_sdk/BUILD.idea241 @@ -0,0 +1,132 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Description: +# +# Plugin source jars for IntelliJ CE, accessed remotely. + +load("@//intellij_platform_sdk:build_defs.bzl", "no_mockito_extensions") + +package(default_visibility = ["//visibility:public"]) + +java_import( + name = "sdk", + jars = glob( + ["lib/*.jar"], + exclude = [ + # mockito-extensions needs to be removed from this jar. + "lib/testFramework.jar", + ], + ), + tags = ["intellij-provided-by-sdk"], + exports = [":jars_without_mockito_extensions"], + deps = ["@error_prone_annotations//jar"], +) + +no_mockito_extensions( + name = "jars_without_mockito_extensions", + jars = ["lib/testFramework.jar"], +) + +java_import( + name = "guava", + jars = ["lib/lib.jar", "lib/lib-client.jar"], +) + +java_library(name = "jsr305") # not bundled + +java_import( + name = "java", + jars = glob(["plugins/java/lib/*.jar"]) + ["plugins/java/lib/resources/jdkAnnotations.jar"], +) + +java_import( + name = "platform_images", + jars = glob(["plugins/platform-images/lib/*.jar"]), +) + +#api232 +java_import( + name = "devkit", + jars = [], +) + +java_import( + name = "coverage", + jars = glob(["plugins/coverage/lib/*.jar"]), +) + +java_import( + name = "hg4idea", + jars = glob(["plugins/hg4idea/lib/hg4idea.jar"]), +) + +java_import( + name = "intellilang", + jars = [], +) + +java_import( + name = "kotlin", + jars = glob(["plugins/Kotlin/lib/*.jar"]), +) + +filegroup( + name = "kotlinc_version", + srcs = ["plugins/Kotlin/kotlinc/build.txt"], +) + +java_import( + name = "junit", + jars = glob(["plugins/junit/lib/*.jar"]), +) + +java_import( + name = "terminal", + jars = glob(["plugins/terminal/lib/terminal.jar"]), +) + +java_import( + name = "shared_indexes", + jars = [ + "plugins/indexing-shared/lib/indexing-shared.jar", + ], +) + +java_import( + name = "git4idea", + jars = glob(["plugins/vcs-git/lib/*.jar"]), +) + +java_import( + name = "cwm", + jars = glob(["plugins/cwm-plugin/lib/*.jar"]), +) + +# The plugins required by IJwB. We need to include them +# when running integration tests. +java_import( + name = "bundled_plugins", + jars = glob([ + "plugins/java-i18n/lib/*.jar", + "plugins/junit/lib/*.jar", + "plugins/properties/lib/*.jar", + ]), + tags = ["intellij-provided-by-sdk"], +) + +filegroup( + name = "application_info_json", + srcs = ["product-info.json"], +) diff --git a/intellij_platform_sdk/BUILD.ue241 b/intellij_platform_sdk/BUILD.ue241 new file mode 100644 index 00000000000..38656d36e50 --- /dev/null +++ b/intellij_platform_sdk/BUILD.ue241 @@ -0,0 +1,161 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Description: +# +# Plugin source jars for IntelliJ UE, accessed remotely. + +load("@//intellij_platform_sdk:build_defs.bzl", "no_mockito_extensions") + +package(default_visibility = ["//visibility:public"]) + +java_import( + name = "sdk", + jars = glob( + ["lib/*.jar"], + exclude = [ + # mockito-extensions needs to be removed from this jar. + "lib/testFramework.jar", + ], + ), + tags = ["intellij-provided-by-sdk"], + exports = [":jars_without_mockito_extensions"], + deps = ["@error_prone_annotations//jar"], +) + +no_mockito_extensions( + name = "jars_without_mockito_extensions", + jars = ["lib/testFramework.jar"], +) + +java_import( + name = "guava", + jars = ["lib/lib.jar", "lib/lib-client.jar"], +) + +java_library(name = "jsr305") # not bundled + +java_import( + name = "java", + jars = glob(["plugins/java/lib/*.jar"]) + ["plugins/java/lib/resources/jdkAnnotations.jar"], +) + +java_import( + name = "platform_images", + jars = glob(["plugins/platform-images/lib/*.jar"]), +) + +java_import( + name = "coverage", + jars = glob(["plugins/coverage/lib/*.jar"]), +) + +#api232 +java_import( + name = "devkit", + jars = [], +) + +java_import( + name = "hg4idea", + jars = glob(["plugins/hg4idea/lib/hg4idea.jar"]), +) + +java_import( + name = "javascript", + jars = glob(["plugins/javascript-impl/lib/*.jar"]), +) + +java_import( + name = "css", + jars = glob([ + "plugins/css-impl/lib/*.jar", + "plugins/platform-images/lib/*.jar", + ]), +) + +java_import( + name = "tslint", + jars = glob(["plugins/tslint/lib/*.jar"]), +) + +java_import( + name = "angular", + jars = glob(["plugins/AngularJS/lib/*.jar"]), +) + +java_import( + name = "intellilang", + jars = glob(["plugins/IntelliLang/lib/*.jar"]), +) + +java_import( + name = "kotlin", + jars = glob(["plugins/Kotlin/lib/*.jar"]), +) + +filegroup( + name = "kotlinc_version", + srcs = ["plugins/Kotlin/kotlinc/build.txt"], +) + +java_import( + name = "junit", + jars = glob(["plugins/junit/lib/*.jar"]), +) + +java_import( + name = "terminal", + jars = glob(["plugins/terminal/lib/terminal.jar"]), +) + +java_import( + name = "protoeditor", + jars = glob(["plugins/protoeditor/lib/*.jar"]), +) + +java_import( + name = "shared_indexes", + jars = [ + "plugins/indexing-shared/lib/indexing-shared.jar", + "plugins/indexing-shared-ultimate/lib/indexing-shared-ultimate.jar", + ], +) + +java_import( + name = "git4idea", + jars = glob(["plugins/vcs-git/lib/*.jar"]), +) + +java_import( + name = "cwm", + jars = glob(["plugins/cwm-plugin/lib/*.jar"]), +) + +# The plugins required by IJwB. We need to include them +# when running integration tests. +java_import( + name = "bundled_plugins", + jars = glob([ + "plugins/java-i18n/lib/*.jar", + "plugins/junit/lib/*.jar", + "plugins/properties/lib/*.jar", + ]), + tags = ["intellij-provided-by-sdk"], +) + +filegroup( + name = "application_info_json", + srcs = ["product-info.json"], +) diff --git a/intellij_platform_sdk/build_defs.bzl b/intellij_platform_sdk/build_defs.bzl index 7f898e1c790..1358a57788d 100644 --- a/intellij_platform_sdk/build_defs.bzl +++ b/intellij_platform_sdk/build_defs.bzl @@ -26,16 +26,16 @@ INDIRECT_IJ_PRODUCTS = { # -oss-stable and -oss-beta respectively. "intellij-oss-oldest-stable": "intellij-2023.2", "intellij-oss-latest-stable": "intellij-2023.3", - "intellij-oss-under-dev": "intellij-2023.3", + "intellij-oss-under-dev": "intellij-2024.1", "intellij-ue-oss-oldest-stable": "intellij-ue-2023.2", "intellij-ue-oss-latest-stable": "intellij-ue-2023.3", - "intellij-ue-oss-under-dev": "intellij-ue-2023.3", + "intellij-ue-oss-under-dev": "intellij-ue-2024.1", "android-studio-oss-oldest-stable": "android-studio-2022.3", "android-studio-oss-latest-stable": "android-studio-2023.1", "android-studio-oss-under-dev": "android-studio-2023.1", "clion-oss-oldest-stable": "clion-2023.2", "clion-oss-latest-stable": "clion-2023.3", - "clion-oss-under-dev": "clion-2023.3", + "clion-oss-under-dev": "clion-2024.1", # Indirect ij_product mapping for Cloud Code Plugin OSS "intellij-cc-oldest-stable": "intellij-2022.3", "intellij-cc-latest-stable": "intellij-2022.3", @@ -160,6 +160,14 @@ DIRECT_IJ_PRODUCTS = { ide = "intellij", directory = "intellij_ce_2023_3", ), + "intellij-2024.1": struct( + ide = "intellij", + directory = "intellij_ce_2024_1", + ), + "intellij-2024.1-mac": struct( + ide = "intellij", + directory = "intellij_ce_2024_1", + ), "intellij-ue-2021.3": struct( ide = "intellij-ue", directory = "intellij_ue_2021_3", @@ -216,6 +224,14 @@ DIRECT_IJ_PRODUCTS = { ide = "intellij-ue", directory = "intellij_ue_2023_3", ), + "intellij-ue-2024.1": struct( + ide = "intellij-ue", + directory = "intellij_ue_2024_1", + ), + "intellij-ue-2024.1-mac": struct( + ide = "intellij-ue", + directory = "intellij_ue_2024_1", + ), "android-studio-2022.3": struct( ide = "android-studio", archive = "android_studio_with_blaze_2022_3", @@ -287,7 +303,14 @@ DIRECT_IJ_PRODUCTS = { ide = "clion", directory = "clion_2023_3", ), - + "clion-2024.1": struct( + ide = "clion", + directory = "clion_2024_1", + ), + "clion-2024.1-mac": struct( + ide = "clion", + directory = "clion_2024_1", + ), } def select_for_plugin_api(params): diff --git a/java/BUILD b/java/BUILD index ae1d5822d61..1c2aa0b5eb2 100644 --- a/java/BUILD +++ b/java/BUILD @@ -57,6 +57,7 @@ java_library( "//sdkcompat", "//shared", "//third_party/auto_value", + "@error_prone_annotations//jar", ], ) diff --git a/kotlin/BUILD b/kotlin/BUILD index ec868686085..ccbb83206c3 100644 --- a/kotlin/BUILD +++ b/kotlin/BUILD @@ -37,6 +37,7 @@ java_library( "//proto:proto_deps", "//sdkcompat", "//shared", + "@error_prone_annotations//jar", ], ) diff --git a/sdkcompat/BUILD b/sdkcompat/BUILD index cf49f4a1690..fb60934cab7 100644 --- a/sdkcompat/BUILD +++ b/sdkcompat/BUILD @@ -33,6 +33,8 @@ java_library( "intellij-ue-2023.2": ["//sdkcompat/v232"], "intellij-2023.3": ["//sdkcompat/v233"], "intellij-ue-2023.3": ["//sdkcompat/v233"], + "intellij-2024.1": ["//sdkcompat/v241"], + "intellij-ue-2024.1": ["//sdkcompat/v241"], "clion-2021.3": ["//sdkcompat/v213"], "clion-2022.1": ["//sdkcompat/v221"], "clion-2022.2": ["//sdkcompat/v222"], @@ -40,5 +42,6 @@ java_library( "clion-2023.1": ["//sdkcompat/v231"], "clion-2023.2": ["//sdkcompat/v232"], "clion-2023.3": ["//sdkcompat/v233"], + "clion-2024.1": ["//sdkcompat/v241"], }), ) diff --git a/sdkcompat/v241/BUILD b/sdkcompat/v241/BUILD new file mode 100644 index 00000000000..325684d9761 --- /dev/null +++ b/sdkcompat/v241/BUILD @@ -0,0 +1,65 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Description: Indirections for SDK changes to the underlying platform library. + +load("//intellij_platform_sdk:build_defs.bzl", "select_for_ide") + +licenses(["notice"]) + +java_library( + name = "v241", + srcs = ["com/google/idea/sdkcompat/refactoring/rename/DelegatingRenamePsiElementProcessorBase.java"] + glob([ + "com/google/idea/sdkcompat/editor/**", + "com/google/idea/sdkcompat/general/**", + "com/google/idea/sdkcompat/fig/**", + "com/google/idea/sdkcompat/logging/**", + "com/google/idea/sdkcompat/platform/**", + "com/google/idea/sdkcompat/psi/**", + "com/google/idea/sdkcompat/python/**", + "com/google/idea/sdkcompat/ui/icons/**", + ]) + select_for_ide( + android_studio = glob([ + "com/google/idea/sdkcompat/cpp/**", + "com/google/idea/sdkcompat/java/**", + "com/google/idea/sdkcompat/kotlin/**", + "com/google/idea/sdkcompat/vcs/**", + ]) + ["com/google/idea/sdkcompat/refactoring/safedelete/JavaSafeDeleteProcessorCompat.java"], + clion = glob([ + "com/google/idea/sdkcompat/cpp/**", + "com/google/idea/sdkcompat/clion/**", # For classes incompatible with Android Studio + "com/google/idea/sdkcompat/javascript/**", #api223 + ]), + intellij = glob([ + "com/google/idea/sdkcompat/java/**", + "com/google/idea/sdkcompat/scala/**", + "com/google/idea/sdkcompat/kotlin/**", + ]) + ["com/google/idea/sdkcompat/refactoring/safedelete/JavaSafeDeleteProcessorCompat.java"], + intellij_ue = glob([ + "com/google/idea/sdkcompat/java/**", + "com/google/idea/sdkcompat/scala/**", + "com/google/idea/sdkcompat/kotlin/**", + "com/google/idea/sdkcompat/javascript/**", #api223 + "com/google/idea/sdkcompat/go/**", #api231 + ]) + ["com/google/idea/sdkcompat/refactoring/safedelete/JavaSafeDeleteProcessorCompat.java"], + ), + visibility = ["//sdkcompat:__pkg__"], + deps = [ + "//intellij_platform_sdk:jsr305", # unuseddeps: keep + "//intellij_platform_sdk:plugin_api", + "//third_party/go", #api231 + "//third_party/javascript", #api223 + "//third_party/scala", + ], +) diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/clion/CMakeNotificationProviderWrapper.java b/sdkcompat/v241/com/google/idea/sdkcompat/clion/CMakeNotificationProviderWrapper.java new file mode 100644 index 00000000000..f809e20d00c --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/clion/CMakeNotificationProviderWrapper.java @@ -0,0 +1,48 @@ +/* + * Copyright 2023 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.clion; + + +import com.intellij.openapi.fileEditor.FileEditor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.jetbrains.cidr.cpp.cmake.workspace.CMakeNotificationProvider; + +import java.util.function.Function; +import javax.annotation.Nullable; +import javax.swing.*; + +// #api223 +public class CMakeNotificationProviderWrapper { + CMakeNotificationProvider value; + + public CMakeNotificationProviderWrapper(){ + this.value = new CMakeNotificationProvider(); + } + + @Nullable + public JComponent createNotificationPanel(VirtualFile virtualFile, FileEditor fileEditor, Project project) { + Function notificationProducer = + this.value.collectNotificationData(project, virtualFile); + + if (notificationProducer != null) { + return notificationProducer.apply(fileEditor); + } + + return null; + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/cpp/CidrOwnModuleDetectorWrapper.java b/sdkcompat/v241/com/google/idea/sdkcompat/cpp/CidrOwnModuleDetectorWrapper.java new file mode 100644 index 00000000000..d9f6a409ecd --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/cpp/CidrOwnModuleDetectorWrapper.java @@ -0,0 +1,21 @@ +/* + * Copyright 2016 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.cpp; + +import com.jetbrains.cidr.project.workspace.CidrOwnModuleDetector; + +/** #api231 */ +public interface CidrOwnModuleDetectorWrapper extends CidrOwnModuleDetector {} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/editor/markup/UIControllerCreator.java b/sdkcompat/v241/com/google/idea/sdkcompat/editor/markup/UIControllerCreator.java new file mode 100644 index 00000000000..6607c1a0910 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/editor/markup/UIControllerCreator.java @@ -0,0 +1,71 @@ +/* + * Copyright 2023 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.editor.markup; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.editor.markup.InspectionsLevel; +import com.intellij.openapi.editor.markup.LanguageHighlightLevel; +import com.intellij.openapi.editor.markup.UIController; +import com.intellij.util.ui.GridBag; +import java.awt.Container; +import java.util.ArrayList; +import java.util.List; + +/** A compat class help to create UIController instance for different sdk */ +public final class UIControllerCreator { + public static UIController create() { + return new UIController() { + @Override + public void toggleProblemsView() {} + + @Override + public void setHighLightLevel(LanguageHighlightLevel level) {} + + @Override + public void onClosePopup() {} + + @Override + public List getHighlightLevels() { + return new ArrayList<>(); + } + + @Override + public List getAvailableLevels() { + return new ArrayList<>(); + } + + @Override + public List getActions() { + return new ArrayList<>(); + } + + @Override + public void fillHectorPanels(Container container, GridBag bag) {} + + @Override + public boolean canClosePopup() { + return true; + } + + @Override + public boolean isToolbarEnabled() { + return true; + } + }; + } + + private UIControllerCreator() {} +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/fig/repo/AbstractRepositoryManagerCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/fig/repo/AbstractRepositoryManagerCompat.java new file mode 100644 index 00000000000..1583ba9c27f --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/fig/repo/AbstractRepositoryManagerCompat.java @@ -0,0 +1,32 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.fig.repo; + +import com.intellij.dvcs.repo.AbstractRepositoryManager; +import com.intellij.dvcs.repo.Repository; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.AbstractVcs; +import com.intellij.openapi.vcs.VcsKey; + +/** Compat class for AbstractRepositoryManager constructor changes. */ +public abstract class AbstractRepositoryManagerCompat + extends AbstractRepositoryManager { + protected AbstractRepositoryManagerCompat( + AbstractVcs abstractVcs, Project project, VcsKey vcsKey, String repoDirName) { + super(project, vcsKey, repoDirName); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/general/BaseSdkCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/general/BaseSdkCompat.java new file mode 100644 index 00000000000..ee2f9c63cb5 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/general/BaseSdkCompat.java @@ -0,0 +1,127 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.general; + +import com.intellij.ide.impl.OpenProjectTask; +import com.intellij.ide.impl.ProjectUtil; +import com.intellij.openapi.extensions.ExtensionPoint; +import com.intellij.openapi.fileChooser.ex.FileLookup; +import com.intellij.openapi.fileChooser.ex.LocalFsFinder; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.refactoring.rename.RenamePsiElementProcessor; +import com.intellij.refactoring.rename.RenamePsiElementProcessorBase; +import com.intellij.ui.EditorNotificationProvider; +import com.intellij.util.Restarter; +import com.intellij.util.indexing.diagnostic.dto.JsonDuration; +import com.intellij.util.indexing.diagnostic.dto.JsonFileProviderIndexStatistics; +import com.intellij.util.indexing.roots.kind.LibraryOrigin; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.function.Predicate; +import javax.annotation.Nullable; + +/** Provides SDK compatibility shims for base plugin API classes, available to all IDEs. */ +public final class BaseSdkCompat { + private BaseSdkCompat() {} + + /** #api213: inline this method */ + @Nullable + public static String getIdeRestarterPath() { + Path startFilePath = Restarter.getIdeStarter(); + return startFilePath == null ? null : startFilePath.toString(); + } + + /** #api213: inline into IndexingLogger */ + public static JsonDuration getTotalIndexingTime( + JsonFileProviderIndexStatistics providerStatisticInput) { + return providerStatisticInput.getTotalIndexingVisibleTime(); + } + + /** #api213: inline this method. */ + public static String getLibraryNameFromLibraryOrigin(LibraryOrigin libraryOrigin) { + // TODO(b/230430213): adapt getLibraryNameFromLibraryOrigin to work in 221 + return ""; + } + + /** #api213: Inline into KytheRenameProcessor. */ + public static RenamePsiElementProcessor[] renamePsiElementProcessorsList() { + ArrayList result = new ArrayList<>(); + for (RenamePsiElementProcessorBase processor : + RenamePsiElementProcessor.EP_NAME.getExtensions()) { + if (processor instanceof RenamePsiElementProcessor) { + result.add((RenamePsiElementProcessor) processor); + } + } + return result.toArray(new RenamePsiElementProcessor[0]); + } + + /** #api213: Inline into WorkspaceFileTextField . */ + public static LocalFsFinder.VfsFile getVfsFile(VirtualFile file) { + return new LocalFsFinder.VfsFile(file); + } + + /** #api213: Inline into WorkspaceFileTextField . */ + public static FileLookup.LookupFile getIoFile(Path path) { + return new LocalFsFinder.IoFile(path); + } + + /** #api213: Inline into BlazeProjectCreator. */ + public static OpenProjectTask createOpenProjectTask(Project project) { + return OpenProjectTask.build().withProject(project); + } + + + /** #api213 interface is different in 221, inline when 213 support is dropped*/ + public static Project openProject(VirtualFile projectSubdirectory, Project projectToClose, boolean forceOpenInNewFrame) { + OpenProjectTask options = OpenProjectTask.build().withForceOpenInNewFrame(forceOpenInNewFrame).withProjectToClose(projectToClose); + return ProjectUtil.openProject(Paths.get(projectSubdirectory.getPath()),options); + } + + /* #api213: Inline into usages. */ + public static void registerEditorNotificationProvider( + Project project, EditorNotificationProvider provider) { + EditorNotificationProvider.EP_NAME.getPoint(project).registerExtension(provider); + } + + /* #api213: Inline into usages. */ + public static void unregisterEditorNotificationProvider( + Project project, Class providerClass) { + EditorNotificationProvider.EP_NAME.getPoint(project).unregisterExtension(providerClass); + } + + /* #api213: Inline into usages. */ + public static void unregisterEditorNotificationProviders( + Project project, Predicate filter) { + unregisterExtensions(EditorNotificationProvider.EP_NAME.getPoint(project), filter); + } + + private static void unregisterExtensions( + ExtensionPoint extensionPoint, Predicate filter) { + for (T extension : extensionPoint.getExtensions()) { + if (filter.test(extension)) { + extensionPoint.unregisterExtension(extension); + } + } + } + + public static String getX11WindowManagerName() { + // TODO(b/266782325): Investigate if i3 still crashes for system notifications. + return ""; + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/general/EditorNotificationCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/general/EditorNotificationCompat.java new file mode 100644 index 00000000000..62bca03b9f6 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/general/EditorNotificationCompat.java @@ -0,0 +1,27 @@ +/* + * Copyright 2022 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.general; + +import com.intellij.openapi.extensions.ExtensionPoint; +import com.intellij.openapi.project.Project; +import com.intellij.ui.EditorNotificationProvider; + +public class EditorNotificationCompat { + /** #api213, inline once api213 support is dropped */ + public static ExtensionPoint getEp(Project project) { + return EditorNotificationProvider.EP_NAME.getPoint(project); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/general/PluginAdvertiserEditorNotificationProviderWrapperCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/general/PluginAdvertiserEditorNotificationProviderWrapperCompat.java new file mode 100644 index 00000000000..73dc664e750 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/general/PluginAdvertiserEditorNotificationProviderWrapperCompat.java @@ -0,0 +1,63 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.general; + +import com.intellij.openapi.extensions.ExtensionPoint; +import com.intellij.openapi.fileEditor.FileEditor; +import com.intellij.openapi.fileTypes.PlainTextLikeFileType; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginAdvertiserEditorNotificationProvider; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.EditorNotificationProvider; +import java.util.function.Function; +import javax.swing.JComponent; + +/** + * #api213: remove this class and make EditorNotificationProvider a direct parent of + * PluginAdvertiserEditorNotificationProviderWrapper. Inline the functionality of this class in + * PluginAdvertiserEditorNotificationProviderWrapper + */ +public abstract class PluginAdvertiserEditorNotificationProviderWrapperCompat + implements EditorNotificationProvider { + + // #api213: change to private when inline to PluginAdvertiserEditorNotificationProviderWrapper + protected final PluginAdvertiserEditorNotificationProvider + pluginAdvertiserEditorNotificationProvider; + + public PluginAdvertiserEditorNotificationProviderWrapperCompat( + PluginAdvertiserEditorNotificationProvider pluginAdvertiserEditorNotificationProvider) { + + this.pluginAdvertiserEditorNotificationProvider = pluginAdvertiserEditorNotificationProvider; + } + + @Override + public Function collectNotificationData( + Project project, VirtualFile file) { + boolean alreadySupported = !(file.getFileType() instanceof PlainTextLikeFileType); + if (alreadySupported) { + return EditorNotificationProvider.CONST_NULL; + } + return pluginAdvertiserEditorNotificationProvider.collectNotificationData(project, file); + } + + public static void reregisterExtension( + Project project, PluginAdvertiserEditorNotificationProviderWrapperCompat replacement) { + ExtensionPoint ep = + EditorNotificationProvider.EP_NAME.getPoint(project); + ep.unregisterExtension(PluginAdvertiserEditorNotificationProvider.class); + ep.registerExtension(replacement, project); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/go/GoSdkCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/go/GoSdkCompat.java new file mode 100644 index 00000000000..c075ad5979e --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/go/GoSdkCompat.java @@ -0,0 +1,26 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.go; + +import com.goide.execution.application.GoApplicationRunningState; + +public class GoSdkCompat { + /* api231 */ + public static void prepareState(GoApplicationRunningState state) { + state.prepareStateInBGT(); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/java/AttachSourcesProviderAdapter.java b/sdkcompat/v241/com/google/idea/sdkcompat/java/AttachSourcesProviderAdapter.java new file mode 100644 index 00000000000..02a2a8d3785 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/java/AttachSourcesProviderAdapter.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.java; + +import com.intellij.codeInsight.AttachSourcesProvider; +import com.intellij.openapi.roots.LibraryOrderEntry; +import com.intellij.openapi.util.ActionCallback; +import com.intellij.psi.PsiFile; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.List; + +/** + * #api222 interface is different in 223, inline when 222 support is dropped + * */ +public abstract class AttachSourcesProviderAdapter + implements AttachSourcesProvider { + + public abstract Collection getAdapterActions( + List orderEntries, final PsiFile psiFile); + + + @NotNull + @Override + public Collection getActions( + List orderEntries, final PsiFile psiFile) { + return getAdapterActions(orderEntries, psiFile); + } + + public static abstract class AttachSourcesActionAdapter implements AttachSourcesAction { + public abstract ActionCallback adapterPerform(List orderEntriesContainingFile); + + + public ActionCallback perform(List orderEntriesContainingFile) { + return adapterPerform(orderEntriesContainingFile); + } + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleResolutionWrapper.java b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleResolutionWrapper.java new file mode 100644 index 00000000000..e7ea6377ed0 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleResolutionWrapper.java @@ -0,0 +1,35 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.javascript; + +import com.intellij.lang.javascript.config.JSModuleResolution; + +public enum JSModuleResolutionWrapper { + NODE(JSModuleResolution.NODE), + NODENEXT(JSModuleResolution.NODENEXT), + CLASSIC(JSModuleResolution.CLASSIC), + UNKNOWN(JSModuleResolution.UNKNOWN); + + private final JSModuleResolution value; + + JSModuleResolutionWrapper(JSModuleResolution value){ + this.value = value; + } + + public JSModuleResolution value() { + return value; + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleTargetWrapper.java b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleTargetWrapper.java new file mode 100644 index 00000000000..0a8873667e2 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/JSModuleTargetWrapper.java @@ -0,0 +1,35 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.javascript; + +import com.intellij.lang.javascript.config.JSModuleTarget; + +public enum JSModuleTargetWrapper { + COMMON_JS(JSModuleTarget.COMMON_JS), + OTHER(JSModuleTarget.OTHER), + NODENEXT(JSModuleTarget.NODENEXT), + UNKNOWN(JSModuleTarget.UNKNOWN); + + private final JSModuleTarget value; + + public JSModuleTarget value() { + return value; + } + + JSModuleTargetWrapper(JSModuleTarget value) { + this.value = value; + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigAdapter.java b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigAdapter.java new file mode 100644 index 00000000000..d89ae1bcb0e --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigAdapter.java @@ -0,0 +1,62 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.javascript; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.NotNullLazyValue; +import com.intellij.lang.javascript.config.JSFileImports; +import com.intellij.lang.javascript.config.JSFileImportsImpl; +import com.intellij.lang.javascript.config.JSModuleResolution; +import com.intellij.lang.javascript.config.JSModuleTarget; +import com.intellij.lang.typescript.tsconfig.TypeScriptConfig; +import org.jetbrains.annotations.NotNull; + +public abstract class TypeScriptConfigAdapter implements TypeScriptConfig { + + public abstract JSModuleTargetWrapper getAdapterModule(); + + public abstract JSModuleResolutionWrapper getAdapterResolution(); + + public abstract JSModuleResolutionWrapper getAdapterEffectiveResolution(); + + + @Override + public @NotNull JSModuleResolution getResolution() { + return getAdapterResolution().value(); + } + + @Override + public JSModuleResolution getEffectiveResolution() { + return getAdapterEffectiveResolution().value(); + } + + @Override + public @NotNull JSModuleTarget getModule() { + return getAdapterModule().value(); + } + NotNullLazyValue importStructure; + + //todo do it in constructor + public void initImportsStructure(Project project) { + this.importStructure = NotNullLazyValue.createValue(() -> new JSFileImportsImpl(project, this)); + } + + @Override + public JSFileImports getConfigImportResolveStructure() { + return importStructure.getValue(); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigServiceAdapter.java b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigServiceAdapter.java new file mode 100644 index 00000000000..8ec2e70f5d5 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/javascript/TypeScriptConfigServiceAdapter.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.javascript; + +import com.intellij.lang.typescript.tsconfig.TypeScriptConfigService; +import com.intellij.openapi.vfs.VirtualFile; + +import java.util.List; + +public abstract class TypeScriptConfigServiceAdapter implements TypeScriptConfigService { + + public abstract TypeScriptConfigService getImpl(); +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/kotlin/KotlinCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/kotlin/KotlinCompat.java new file mode 100644 index 00000000000..30adc11a2ba --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/kotlin/KotlinCompat.java @@ -0,0 +1,145 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.kotlin; + +import com.intellij.openapi.application.Application; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.DependencyScope; +import com.intellij.openapi.roots.ExternalLibraryDescriptor; +import com.intellij.psi.PsiElement; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import kotlin.Unit; +import kotlin.jvm.functions.Function0; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.cli.common.arguments.Freezable; +import org.jetbrains.kotlin.cli.common.arguments.FreezableKt; +import org.jetbrains.kotlin.config.ApiVersion; +import org.jetbrains.kotlin.config.LanguageFeature; +import org.jetbrains.kotlin.config.LanguageFeature.State; +import org.jetbrains.kotlin.idea.base.projectStructure.ModuleSourceRootGroup; +import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinStatus; +import org.jetbrains.kotlin.idea.configuration.KotlinJavaModuleConfigurator; +import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator; +import org.jetbrains.kotlin.idea.configuration.NotificationMessageCollector; +import org.jetbrains.kotlin.idea.projectConfiguration.LibraryJarDescriptor; +import org.jetbrains.kotlin.platform.TargetPlatform; +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms; + +/** Provides SDK compatibility shims for Kotlin classes, available to IntelliJ CE & UE. */ +public class KotlinCompat { + private KotlinCompat() {} + + /** #api213 inline in BlazeKotlinSyncPlugin using FreezableKt.unfrozen() */ + public static Freezable unfreezeSettings(T settings) { + return FreezableKt.unfrozen(settings); + } + + /* #api213: inline in {@link BlazeKotlinSyncPlugin}*/ + public static void configureModule(Project project, Module module) { + KotlinJavaModuleConfigurator configurator = + KotlinJavaModuleConfigurator.Companion.getInstance(); + NotificationMessageCollector collector = + new NotificationMessageCollector(project, "Configuring Kotlin", "Configuring Kotlin"); + Application application = ApplicationManager.getApplication(); + + application.invokeAndWait( + () -> { + configurator.getOrCreateKotlinLibrary(project, collector); + }); + + List> writeActions = new ArrayList<>(); + application.runReadAction( + () -> { + configurator.configureModule(module, collector, writeActions); + }); + + if (ApplicationManager.getApplication().isUnitTestMode()) { + // do not invoke it later since serviceContainer may be disposed before it get completed + application.invokeAndWait( + () -> { + writeActions.stream().forEach(Function0::invoke); + }); + } else { + application.invokeLater( + () -> { + writeActions.stream().forEach(Function0::invoke); + }); + } + } + + /** A Kotlin project configurator base.. */ + public abstract static class KotlinProjectConfiguratorBase implements KotlinProjectConfigurator { + + @NotNull + @Override + public String getName() { + return "Bazel"; + } + + @NotNull + @Override + public String getPresentableText() { + return "Bazel"; + } + + @NotNull + @Override + public TargetPlatform getTargetPlatform() { + return JvmPlatforms.INSTANCE.getUnspecifiedJvmPlatform(); + } + + @Override + public void addLibraryDependency( + @NotNull Module module, + @NotNull PsiElement psiElement, + @NotNull ExternalLibraryDescriptor externalLibraryDescriptor, + @NotNull LibraryJarDescriptor libraryJarDescriptor, + @NotNull DependencyScope dependencyScope) {} + + @Override + public void changeGeneralFeatureConfiguration( + @NotNull Module module, + @NotNull LanguageFeature languageFeature, + @NotNull State state, + boolean b) {} + + @Override + public void configure(@NotNull Project project, @NotNull Collection collection) {} + + @NotNull + @Override + public ConfigureKotlinStatus getStatus(@NotNull ModuleSourceRootGroup moduleSourceRootGroup) { + return getStatus(moduleSourceRootGroup.getBaseModule()); + } + + @NotNull + public abstract ConfigureKotlinStatus getStatus(@NotNull Module module); + + @Override + public void updateLanguageVersion( + @NotNull Module module, + @Nullable String s, + @Nullable String s1, + @NotNull ApiVersion apiVersion, + boolean b) {} + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/logging/HandlerWrapper.java b/sdkcompat/v241/com/google/idea/sdkcompat/logging/HandlerWrapper.java new file mode 100644 index 00000000000..0799ad29bae --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/logging/HandlerWrapper.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.logging; + +import java.util.logging.Handler; +import java.util.logging.LogRecord; + +/** #api213: Use {@link Handler} directly instead of {@link HandlerWrapper} everywhere */ +public abstract class HandlerWrapper extends Handler { + + @Override + public void close() {} + + @Override + public void flush() {} + + @Override + public void publish(LogRecord logRecord) { + this.publish(new LogRecordWrapper(logRecord)); + } + + public abstract void publish(LogRecordWrapper logRecord); +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/logging/LogRecordWrapper.java b/sdkcompat/v241/com/google/idea/sdkcompat/logging/LogRecordWrapper.java new file mode 100644 index 00000000000..ceaa41c1534 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/logging/LogRecordWrapper.java @@ -0,0 +1,65 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.logging; + +import java.util.logging.Level; +import java.util.logging.LogRecord; +import org.jetbrains.annotations.VisibleForTesting; + +/** #api213: Use {@link LogRecord} directly everywhere instead of {@link LogRecordWrapper} */ +public class LogRecordWrapper { + + private final LogRecord logRecord; + + LogRecordWrapper(LogRecord logRecord) { + this.logRecord = logRecord; + } + + @VisibleForTesting + public LogRecordWrapper(Level level, String message, Throwable throwable) { + logRecord = new LogRecord(level, message); + logRecord.setThrown(throwable); + } + + public String getLoggerName() { + return logRecord.getLoggerName(); + } + + public Level getLevel() { + return logRecord.getLevel(); + } + + public String getMessage() { + return logRecord.getMessage(); + } + + public Throwable getThrown() { + return logRecord.getThrown(); + } + + public long getMillis() { + return logRecord.getMillis(); + } + + public String getSourceClassName() { + return logRecord.getSourceClassName(); + } + + public String getSourceMethodName() { + return logRecord.getSourceMethodName(); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/logging/LoggerWrapper.java b/sdkcompat/v241/com/google/idea/sdkcompat/logging/LoggerWrapper.java new file mode 100644 index 00000000000..ac751116337 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/logging/LoggerWrapper.java @@ -0,0 +1,33 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.logging; + +import java.util.logging.Logger; + +/** #api213: Use {@code Logger.getGlobal()} directly into calling classes */ +public class LoggerWrapper { + + private LoggerWrapper() {} + + public static void addHandler(HandlerWrapper handler) { + Logger.getGlobal().addHandler(handler); + } + + public static void removeHandler(HandlerWrapper handler) { + Logger.getGlobal().removeHandler(handler); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/psi/impl/imports/FileReferenceCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/psi/impl/imports/FileReferenceCompat.java new file mode 100644 index 00000000000..24312cdca2a --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/psi/impl/imports/FileReferenceCompat.java @@ -0,0 +1,49 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.psi.impl.imports; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiFileSystemItem; +import com.intellij.psi.ResolveResult; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; +import java.util.Collection; + +/** Compat class for FileReference. */ +public abstract class FileReferenceCompat extends FileReference { + public FileReferenceCompat( + FileReferenceSet fileReferenceSet, TextRange range, int index, String text) { + super(fileReferenceSet, range, index, text); + } + + @Override + protected void innerResolveInContext( + String text, + PsiFileSystemItem context, + Collection result, + boolean caseSensitive) { + if (doInnerResolveInContext(text, context, result, caseSensitive)) { + super.innerResolveInContext(text, context, result, caseSensitive); + } + } + + protected abstract boolean doInnerResolveInContext( + String text, + PsiFileSystemItem context, + Collection result, + boolean caseSensitive); +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/refactoring/rename/DelegatingRenamePsiElementProcessorBase.java b/sdkcompat/v241/com/google/idea/sdkcompat/refactoring/rename/DelegatingRenamePsiElementProcessorBase.java new file mode 100644 index 00000000000..309203d2af1 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/refactoring/rename/DelegatingRenamePsiElementProcessorBase.java @@ -0,0 +1,61 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.refactoring.rename; + +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.util.Pass; +import com.intellij.psi.PsiElement; +import com.intellij.refactoring.rename.RenamePsiElementProcessor; +import javax.annotation.Nullable; + +/** Compat content for DelegatingRenamePsiElementProcessor. */ +public abstract class DelegatingRenamePsiElementProcessorBase extends RenamePsiElementProcessor { + private volatile RenamePsiElementProcessor baseProcessor; + + @Override + public boolean isInplaceRenameSupported() { + return baseProcessor != null + ? baseProcessor.isInplaceRenameSupported() + : super.isInplaceRenameSupported(); + } + + @Override + public boolean forcesShowPreview() { + return baseProcessor != null ? baseProcessor.forcesShowPreview() : super.forcesShowPreview(); + } + + @Nullable + protected abstract RenamePsiElementProcessor getDelegate(PsiElement element); + + @Nullable + protected RenamePsiElementProcessor getDelegateAndStoreState(PsiElement element) { + RenamePsiElementProcessor delegate = getDelegate(element); + baseProcessor = delegate; + return delegate; + } + + @Override + public void substituteElementToRename( + PsiElement element, Editor editor, Pass renameCallback) { + RenamePsiElementProcessor processor = getDelegateAndStoreState(element); + if (processor != null) { + processor.substituteElementToRename(element, editor, renameCallback); + } else { + super.substituteElementToRename(element, editor, renameCallback); + } + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/refactoring/safedelete/JavaSafeDeleteProcessorCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/refactoring/safedelete/JavaSafeDeleteProcessorCompat.java new file mode 100644 index 00000000000..2e7b9a8ab82 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/refactoring/safedelete/JavaSafeDeleteProcessorCompat.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.refactoring.safedelete; + +import com.intellij.psi.PsiElement; +import com.intellij.refactoring.safeDelete.JavaSafeDeleteProcessor; +import com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo; +import com.intellij.usageView.UsageInfo; +import java.util.List; + +/** Compat class for JavaSafeDeleteProcessor. */ +public abstract class JavaSafeDeleteProcessorCompat extends JavaSafeDeleteProcessor { + + @Override + public NonCodeUsageSearchInfo findUsages( + PsiElement element, PsiElement[] allElementsToDelete, List result) { + NonCodeUsageSearchInfo superResult = super.findUsages(element, allElementsToDelete, result); + return doFindUsages(element, allElementsToDelete, result, superResult); + } + + protected abstract NonCodeUsageSearchInfo doFindUsages( + PsiElement element, + PsiElement[] allElementsToDelete, + List result, + NonCodeUsageSearchInfo superResult); +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/scala/ScalaCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/scala/ScalaCompat.java new file mode 100644 index 00000000000..86205a3000f --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/scala/ScalaCompat.java @@ -0,0 +1,38 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.scala; + +import com.intellij.psi.PsiMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.ScObject; +import org.jetbrains.plugins.scala.util.ScalaMainMethodUtil; +import scala.Option; + +/** Provides SDK compatibility shims for Scala classes, available to IntelliJ CE & UE. */ +public class ScalaCompat { + private ScalaCompat() {} + + /** #api213: Inline the call. Method location and signature changed in 2021.2 */ + public static Option findMainMethod(@NotNull ScObject obj) { + return ScalaMainMethodUtil.findScala2MainMethod(obj); + } + + /** #api213: Inline the call. Method location and signature changed in 2021.2 */ + public static boolean hasMainMethod(@NotNull ScObject obj) { + return ScalaMainMethodUtil.hasScala2MainMethod(obj); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/ui/icons/IconManagerCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/ui/icons/IconManagerCompat.java new file mode 100644 index 00000000000..1d8afe8e0c4 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/ui/icons/IconManagerCompat.java @@ -0,0 +1,33 @@ +/* + * Copyright 2023 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.ui.icons; + +import com.intellij.ui.IconManager; +import com.intellij.ui.icons.CoreIconManager; + +/** Compat class for IconManager. */ +public class IconManagerCompat { + + private IconManagerCompat() {} + + public static void activateCoreIconManager() throws Throwable { + IconManager.Companion.activate(new CoreIconManager()); + } + + public static void deactivate() { + IconManager.Companion.deactivate(); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/vcs/RemoveIntegrationRecordsConfirmationOption.java b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/RemoveIntegrationRecordsConfirmationOption.java new file mode 100644 index 00000000000..1845f919166 --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/RemoveIntegrationRecordsConfirmationOption.java @@ -0,0 +1,52 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.vcs; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.AbstractVcs; +import com.intellij.openapi.vcs.VcsShowConfirmationOption; +import com.intellij.openapi.vcs.VcsShowConfirmationOption.Value; + +/** Helper to show a confirmation dialog for whether to remove integration records. */ +public class RemoveIntegrationRecordsConfirmationOption implements VcsShowConfirmationOption { + + private Value value = Value.SHOW_CONFIRMATION; + + public RemoveIntegrationRecordsConfirmationOption(Project unusedProject, AbstractVcs unusedVcs) {} + + @Override + public Value getValue() { + // TODO(b/266785029): Read the value from storage. Maybe via the PiperVcs instance? + return value; + } + + @Override + public void setValue(Value value) { + this.value = value; + if (value.equals(Value.DO_NOTHING_SILENTLY)) { + // This happens if the user checks "don't ask again", but clicks No or cancels. + // We don't want to persist that, since the action would just become useless. + return; + } + // TODO(b/266785029): Store the value into storage. Maybe via the PiperVcs instance? + } + + @Override + public boolean isPersistent() { + return true; + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ChangeListAdapterCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ChangeListAdapterCompat.java new file mode 100644 index 00000000000..9a48be5234c --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ChangeListAdapterCompat.java @@ -0,0 +1,34 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.vcs.changes; + +import com.intellij.openapi.vcs.changes.Change; +import com.intellij.openapi.vcs.changes.ChangeList; +import com.intellij.openapi.vcs.changes.ChangeListAdapter; +import java.util.Collection; + +/** Compat class for ChangeListAdapter. */ +public abstract class ChangeListAdapterCompat extends ChangeListAdapter { + @Override + public void changesMoved( + Collection changes, ChangeList fromList, ChangeList toList) { + doChangesMoved(changes, fromList, toList); + } + + protected abstract void doChangesMoved( + Collection changes, ChangeList fromList, ChangeList toList); +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/FakeRevisionCompat.java b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/FakeRevisionCompat.java new file mode 100644 index 00000000000..488b0d071af --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/FakeRevisionCompat.java @@ -0,0 +1,28 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.vcs.changes; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.changes.FakeRevision; + +/** Compat class for FakeRevision constructor changes. */ +public class FakeRevisionCompat extends FakeRevision { + public FakeRevisionCompat(Project project, FilePath file) { + super(project, file); + } +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ui/ChangesListViewCreator.java b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ui/ChangesListViewCreator.java new file mode 100644 index 00000000000..a96e661b15b --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/changes/ui/ChangesListViewCreator.java @@ -0,0 +1,29 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.vcs.changes.ui; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.changes.ui.ChangesListView; + +/** Compat class to initialize ChangesListView. */ +public final class ChangesListViewCreator { + public static ChangesListView create(Project project, boolean showCheckboxes) { + return new ChangesListView(project, showCheckboxes) {}; + } + + private ChangesListViewCreator() {} +} diff --git a/sdkcompat/v241/com/google/idea/sdkcompat/vcs/impl/VcsBaseContentProviderDelegator.java b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/impl/VcsBaseContentProviderDelegator.java new file mode 100644 index 00000000000..4d97a49debf --- /dev/null +++ b/sdkcompat/v241/com/google/idea/sdkcompat/vcs/impl/VcsBaseContentProviderDelegator.java @@ -0,0 +1,39 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.idea.sdkcompat.vcs.impl; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.impl.LineStatusTrackerBaseContentUtil; +import com.intellij.openapi.vcs.impl.VcsBaseContentProvider; +import com.intellij.openapi.vfs.VirtualFile; + +/** Compat class that provide VcsBaseContentProvider delegator. */ +public class VcsBaseContentProviderDelegator { + private final Project project; + + public VcsBaseContentProviderDelegator(Project project) { + this.project = project; + } + + public boolean isSupported(VirtualFile file) { + return LineStatusTrackerBaseContentUtil.isSupported(project, file); + } + + public VcsBaseContentProvider.BaseContent getBaseRevision(VirtualFile file) { + return LineStatusTrackerBaseContentUtil.getBaseRevision(project, file); + } +} diff --git a/testing/BUILD b/testing/BUILD index b161427158e..775edd6c21d 100644 --- a/testing/BUILD +++ b/testing/BUILD @@ -75,6 +75,10 @@ java_library( "testcompat/v233/com/google/idea/sdkcompat/**/*.java", "testcompat/v233/com/google/idea/testing/*.java", ]), + "clion-2024.1": glob([ + "testcompat/v241/com/google/idea/sdkcompat/**/*.java", + "testcompat/v241/com/google/idea/testing/*.java", + ]), "intellij-2021.3": glob([ "testcompat/v213/com/google/idea/sdkcompat/**/*.java", "testcompat/v213/com/google/idea/testing/java/*.java", @@ -141,6 +145,16 @@ java_library( "testcompat/v233/com/google/idea/testing/**/*.java", "testcompat/v233/com/google/idea/java/**/*.java", ]), + "intellij-2024.1": glob([ + "testcompat/v241/com/google/idea/sdkcompat/**/*.java", + "testcompat/v241/com/google/idea/testing/**/*.java", + "testcompat/v241/com/google/idea/java/**/*.java", + ]), + "intellij-ue-2024.1": glob([ + "testcompat/v241/com/google/idea/sdkcompat/**/*.java", + "testcompat/v241/com/google/idea/testing/**/*.java", + "testcompat/v241/com/google/idea/java/**/*.java", + ]), "default": [], }), deps = [ diff --git a/testing/testcompat/v241/com/google/idea/java/JavaSdkCompat.java b/testing/testcompat/v241/com/google/idea/java/JavaSdkCompat.java new file mode 100644 index 00000000000..58c61d733c5 --- /dev/null +++ b/testing/testcompat/v241/com/google/idea/java/JavaSdkCompat.java @@ -0,0 +1,46 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.java; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl; +import com.intellij.openapi.projectRoots.impl.UnknownSdkType; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.testFramework.IdeaTestUtil; + +/** + * Provides SDK compatibility shims for base plugin API classes, available to all IDEs during + * test-time. + */ +public final class JavaSdkCompat { + private JavaSdkCompat() {} + + /** #api233 to inline */ + public static Sdk getUniqueMockJdk(LanguageLevel languageLevel) { + var jdk = IdeaTestUtil.getMockJdk(languageLevel.toJavaVersion()); + var modificator = jdk.getSdkModificator(); + modificator.setHomePath(jdk.getHomePath() + "." + jdk.hashCode()); + modificator.setName(jdk.getName() + "." + jdk.hashCode()); + ApplicationManager.getApplication().runWriteAction(modificator::commitChanges); + return jdk; + } + + /** #api233 to inline */ + public static Sdk getNonJavaMockSdk() { + return new ProjectJdkImpl("", UnknownSdkType.getInstance(""), "", ""); + } +} diff --git a/testing/testcompat/v241/com/google/idea/sdkcompat/BaseSdkTestCompat.java b/testing/testcompat/v241/com/google/idea/sdkcompat/BaseSdkTestCompat.java new file mode 100644 index 00000000000..90f0a1cece9 --- /dev/null +++ b/testing/testcompat/v241/com/google/idea/sdkcompat/BaseSdkTestCompat.java @@ -0,0 +1,61 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat; + +import com.intellij.lang.annotation.Annotation; +import com.intellij.lang.annotation.Annotator; +import com.intellij.openapi.components.ComponentManager; +import com.intellij.psi.PsiElement; +import com.intellij.serviceContainer.ComponentManagerImpl; +import com.intellij.testFramework.fixtures.CodeInsightTestUtil; +import com.intellij.testFramework.fixtures.IdeaProjectTestFixture; +import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory; +import com.intellij.testFramework.fixtures.TestFixtureBuilder; +import com.intellij.testFramework.UITestUtil; +import com.intellij.ui.IconManager; +import com.intellij.ui.icons.CoreIconManager; + +import javax.swing.*; +import java.util.List; + +/** + * Provides SDK compatibility shims for base plugin API classes, available to all IDEs during + * test-time. + */ +public final class BaseSdkTestCompat { + private BaseSdkTestCompat() {} + + /** #api212: inline into test cases */ + public static List testAnnotator(Annotator annotator, PsiElement... elements) { + return CodeInsightTestUtil.testAnnotator(annotator, elements); + } + + /** #api223: inline into ServiceHelper */ + public static void unregisterComponent(ComponentManager componentManager, Class componentKey) { + ((ComponentManagerImpl) componentManager).unregisterComponent(componentKey); + } + + /** #api213: inline into tests */ + public static TestFixtureBuilder createLightFixtureBuilder( + IdeaTestFixtureFactory factory, String projectName) { + return factory.createLightFixtureBuilder(projectName); + } + + /** #api222 */ + public static void replaceIdeEventQueueSafely() { + UITestUtil.replaceIdeEventQueueSafely(); + } +} diff --git a/testing/testcompat/v241/com/google/idea/sdkcompat/roots/ex/ProjectRootManagerExWrapper.java b/testing/testcompat/v241/com/google/idea/sdkcompat/roots/ex/ProjectRootManagerExWrapper.java new file mode 100644 index 00000000000..6e30ba5d06d --- /dev/null +++ b/testing/testcompat/v241/com/google/idea/sdkcompat/roots/ex/ProjectRootManagerExWrapper.java @@ -0,0 +1,36 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.sdkcompat.roots.ex; + +import com.intellij.openapi.project.RootsChangeRescanningInfo; +import com.intellij.openapi.roots.ex.ProjectRootManagerEx; +import org.jetbrains.annotations.NotNull; + +/** Shim for #api222 compat */ +public abstract class ProjectRootManagerExWrapper extends ProjectRootManagerEx { + @Override + public void makeRootsChange( + @NotNull Runnable runnable, @NotNull RootsChangeRescanningInfo rootsChangeRescanningInfo) {} + + @Override + public @NotNull AutoCloseable withRootsChange( + @NotNull RootsChangeRescanningInfo rootsChangeRescanningInfo) { + return new AutoCloseable() { + @Override + public void close() throws Exception {} + }; + } +} diff --git a/testing/testcompat/v241/com/google/idea/testing/TestRunnerUtilCompat.java b/testing/testcompat/v241/com/google/idea/testing/TestRunnerUtilCompat.java new file mode 100644 index 00000000000..f96d5c39a9b --- /dev/null +++ b/testing/testcompat/v241/com/google/idea/testing/TestRunnerUtilCompat.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.testing; + +import com.intellij.testFramework.UITestUtil; + +/** Compat class for TestRunnerUtil. */ +public class TestRunnerUtilCompat { + private TestRunnerUtilCompat() {} + + public static void replaceIdeEventQueueSafely() { + UITestUtil.replaceIdeEventQueueSafely(); + } +} diff --git a/testing/testcompat/v241/com/google/idea/testing/java/BaseJavaSdkTestCompat.java b/testing/testcompat/v241/com/google/idea/testing/java/BaseJavaSdkTestCompat.java new file mode 100644 index 00000000000..41ccf6aa3ca --- /dev/null +++ b/testing/testcompat/v241/com/google/idea/testing/java/BaseJavaSdkTestCompat.java @@ -0,0 +1,33 @@ +/* + * Copyright 2022 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.testing.java; + +import com.intellij.testFramework.fixtures.IdeaProjectTestFixture; +import com.intellij.testFramework.fixtures.JavaTestFixtureFactory; +import com.intellij.testFramework.fixtures.TestFixtureBuilder; + +/** + * Provides SDK compatibility shims for base plugin API classes, available to IDEs working with Java + * code during test-time. + */ +public class BaseJavaSdkTestCompat { + + /** #api213: inline into tests */ + public static TestFixtureBuilder createLightFixtureBuilder( + JavaTestFixtureFactory factory, String projectName) { + return factory.createLightFixtureBuilder(projectName); + } +} diff --git a/third_party/devkit/BUILD b/third_party/devkit/BUILD index 01beb245809..6002a741dcb 100644 --- a/third_party/devkit/BUILD +++ b/third_party/devkit/BUILD @@ -6,6 +6,8 @@ java_library( exports = select_for_plugin_api({ "intellij-2023.3": ["@devkit_2023_3//:devkit"], "intellij-ue-2023.3": ["@devkit_2023_3//:devkit"], + "intellij-2024.1": ["@devkit_2024_1//:devkit"], + "intellij-ue-2024.1": ["@devkit_2024_1//:devkit"], "default": [], }), ) diff --git a/third_party/go/BUILD b/third_party/go/BUILD index 292314a6601..3ba4bbbbc32 100644 --- a/third_party/go/BUILD +++ b/third_party/go/BUILD @@ -22,6 +22,8 @@ java_library( "intellij-ue-2023.2": ["@go_2023_2//:go"], "intellij-2023.3": ["@go_2023_3//:go"], "intellij-ue-2023.3": ["@go_2023_3//:go"], + "intellij-2024.1": ["@go_2024_1//:go"], + "intellij-ue-2024.1": ["@go_2024_1//:go"], "default": [], }), ) diff --git a/third_party/javascript/BUILD b/third_party/javascript/BUILD index ec21d0a6ddb..7034d2b412e 100644 --- a/third_party/javascript/BUILD +++ b/third_party/javascript/BUILD @@ -16,6 +16,7 @@ java_library( "intellij-ue-2023.1": ["@intellij_ue_2023_1//:javascript"], "intellij-ue-2023.2": ["@intellij_ue_2023_2//:javascript"], "intellij-ue-2023.3": ["@intellij_ue_2023_3//:javascript"], + "intellij-ue-2024.1": ["@intellij_ue_2024_1//:javascript"], "clion-2021.3": ["@clion_2021_3//:javascript"], "clion-2022.1": ["@clion_2022_1//:javascript"], "clion-2022.2": ["@clion_2022_2//:javascript"], @@ -23,6 +24,7 @@ java_library( "clion-2023.1": ["@clion_2023_1//:javascript"], "clion-2023.2": ["@clion_2023_2//:javascript"], "clion-2023.3": ["@clion_2023_3//:javascript"], + "clion-2024.1": ["@clion_2024_1//:javascript"], "default": [], }), ) @@ -39,6 +41,7 @@ java_library( "intellij-ue-2023.1": ["@intellij_ue_2023_1//:css"], "intellij-ue-2023.2": ["@intellij_ue_2023_2//:css"], "intellij-ue-2023.3": ["@intellij_ue_2023_3//:css"], + "intellij-ue-2024.1": ["@intellij_ue_2024_1//:css"], "clion-2021.3": ["@clion_2021_3//:css"], "clion-2022.1": ["@clion_2022_1//:css"], "clion-2022.2": ["@clion_2022_2//:css"], @@ -46,6 +49,7 @@ java_library( "clion-2023.1": ["@clion_2023_1//:css"], "clion-2023.2": ["@clion_2023_2//:css"], "clion-2023.3": ["@clion_2023_3//:css"], + "clion-2024.1": ["@clion_2024_1//:css"], "default": [], }), ) diff --git a/third_party/python/BUILD b/third_party/python/BUILD index 563db53fad9..2debb0ebef4 100644 --- a/third_party/python/BUILD +++ b/third_party/python/BUILD @@ -22,6 +22,8 @@ java_library( "intellij-ue-2023.2": ["@python_2023_2//:python"], "intellij-2023.3": ["@python_2023_3//:python"], "intellij-ue-2023.3": ["@python_2023_3//:python"], + "intellij-2024.1": ["@python_2024_1//:python"], + "intellij-ue-2024.1": ["@python_2024_1//:python"], "clion-2021.3": ["@clion_2021_3//:python"], "clion-2022.1": ["@clion_2022_1//:python"], "clion-2022.2": ["@clion_2022_2//:python"], @@ -29,6 +31,7 @@ java_library( "clion-2023.1": ["@clion_2023_1//:python"], "clion-2023.2": ["@clion_2023_2//:python"], "clion-2023.3": ["@clion_2023_3//:python"], + "clion-2024.1": ["@clion_2024_1//:python"], "android-studio-2022.2": ["@python_2022_2//:python"], "android-studio-2022.3": ["@python_2022_3//:python"], "android-studio-2023.1": ["@python_2023_1//:python"], @@ -53,6 +56,8 @@ filegroup( "intellij-ue-2023.2": ["@python_2023_2//:python_helpers"], "intellij-2023.3": ["@python_2023_3//:python_helpers"], "intellij-ue-2023.3": ["@python_2023_3//:python_helpers"], + "intellij-2024.1": ["@python_2024_1//:python_helpers"], + "intellij-ue-2024.1": ["@python_2024_1//:python_helpers"], "clion-2021.3": ["@clion_2021_3//:python_helpers"], "clion-2022.1": ["@clion_2022_1//:python_helpers"], "clion-2022.2": ["@clion_2022_2//:python_helpers"], @@ -60,6 +65,7 @@ filegroup( "clion-2023.1": ["@clion_2023_1//:python_helpers"], "clion-2023.2": ["@clion_2023_2//:python_helpers"], "clion-2023.3": ["@clion_2023_3//:python_helpers"], + "clion-2024.1": ["@clion_2024_1//:python_helpers"], "android-studio-2022.2": ["@python_2022_2//:python_helpers"], "android-studio-2022.3": ["@python_2022_3//:python_helpers"], "android-studio-2023.1": ["@python_2023_1//:python_helpers"], diff --git a/third_party/scala/BUILD b/third_party/scala/BUILD index c9bc75a5e6a..21a4825b16c 100644 --- a/third_party/scala/BUILD +++ b/third_party/scala/BUILD @@ -22,6 +22,8 @@ java_library( "intellij-ue-2023.2": ["@scala_2023_2//:scala"], "intellij-2023.3": ["@scala_2023_3//:scala"], "intellij-ue-2023.3": ["@scala_2023_3//:scala"], + "intellij-2024.1": ["@scala_2024_1//:scala"], + "intellij-ue-2024.1": ["@scala_2024_1//:scala"], "default": [], }), )