From c1f1f111abbac5539fdcd179c3daf6641d5e050b Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Tue, 1 Aug 2023 21:24:13 +0300 Subject: [PATCH] Plugin is not compatible with latest IntelliJ IDEA 2023.2 #2460 --- gradle.properties | 8 ++--- .../table/UtPyMemberSelectionTable.java | 25 +++++++++++---- .../python/IntellijRequirementsInstaller.kt | 31 +++++++++++-------- .../language/python/PythonDialogWindow.kt | 14 +-------- utbot-intellij/build.gradle.kts | 2 +- .../intellij/plugin/process/EngineProcess.kt | 2 +- utbot-ui-commons/build.gradle.kts | 2 +- 7 files changed, 45 insertions(+), 39 deletions(-) diff --git a/gradle.properties b/gradle.properties index 603eb5e3b8..b19a73ddc0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio ideType=IC -ideVersion=231.8109.175 +ideVersion=232.8660.185 # ALL, NOJS buildType=NOJS @@ -28,11 +28,11 @@ goIde=IU #androidStudioPath=your_path_to_android_studio # Version numbers: https://plugins.jetbrains.com/plugin/7322-python-community-edition/versions -pythonCommunityPluginVersion=231.8109.144 +pythonCommunityPluginVersion=232.8660.185 # Version numbers: https://plugins.jetbrains.com/plugin/631-python/versions -pythonUltimatePluginVersion=231.8109.175 +pythonUltimatePluginVersion=232.8660.185 # Version numbers: https://plugins.jetbrains.com/plugin/9568-go/versions -goPluginVersion=231.8109.175 +goPluginVersion=232.8660.142 junit5Version=5.8.2 junit4Version=4.13.2 diff --git a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyMemberSelectionTable.java b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyMemberSelectionTable.java index c1d88eae78..f11d7a606a 100644 --- a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyMemberSelectionTable.java +++ b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyMemberSelectionTable.java @@ -1,13 +1,14 @@ package org.utbot.intellij.plugin.language.python.table; +import com.intellij.openapi.actionSystem.BackgroundableDataProvider; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.refactoring.ui.EnableDisableAction; import com.intellij.ui.*; import com.intellij.ui.icons.RowIcon; import com.intellij.ui.table.JBTable; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; +import com.jetbrains.python.psi.PyElement; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,13 +22,14 @@ import java.util.Collection; import java.util.List; -public class UtPyMemberSelectionTable extends JBTable implements DataProvider { +public class UtPyMemberSelectionTable extends JBTable implements BackgroundableDataProvider { protected static final int CHECKED_COLUMN = 0; protected static final int DISPLAY_NAME_COLUMN = 1; protected static final int ICON_POSITION = 0; protected List myItems; protected MyTableModel myTableModel; + private DataProvider dataProvider; public UtPyMemberSelectionTable(Collection items) { myItems = new ArrayList<>(items); @@ -52,11 +54,22 @@ public void setItems(Collection items) { } @Override - public @Nullable Object getData(@NotNull @NonNls String dataId) { - if (CommonDataKeys.PSI_ELEMENT.is(dataId)) { - return ContainerUtil.getFirstItem(getSelectedMemberInfos()); + public @Nullable DataProvider createBackgroundDataProvider() { + if (dataProvider == null) { + dataProvider = new DataProvider() { + @Override + public @Nullable Object getData(@NotNull @NonNls String dataId) { + if (CommonDataKeys.PSI_ELEMENT.is(dataId)) { + for (UtPyTableItem item : getSelectedMemberInfos()) { + PyElement pyElement = item.getContent(); + if (pyElement != null) return pyElement; + } + } + return null; + } + }; } - return null; + return dataProvider; } public Collection getSelectedMemberInfos() { diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/IntellijRequirementsInstaller.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/IntellijRequirementsInstaller.kt index e8701bdbe6..2bea00fc73 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/IntellijRequirementsInstaller.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/IntellijRequirementsInstaller.kt @@ -12,6 +12,7 @@ import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater import org.utbot.python.utils.RequirementsInstaller import org.utbot.python.utils.RequirementsUtils import javax.swing.JComponent +import org.jetbrains.concurrency.runAsync class IntellijRequirementsInstaller( @@ -24,20 +25,24 @@ class IntellijRequirementsInstaller( override fun installRequirements(pythonPath: String, requirements: List) { invokeLater { if (InstallRequirementsDialog(requirements).showAndGet()) { - val installResult = RequirementsUtils.installRequirements(pythonPath, requirements) - if (installResult.exitValue != 0) { - showErrorDialogLater( - project, - "Requirements installing failed.
" + - "${installResult.stderr}

" + - "Try to install with pip:
" + - " ${requirements.joinToString("
")}", - "Requirements error" - ) - } else { + runAsync { + val installResult = RequirementsUtils.installRequirements(pythonPath, requirements) invokeLater { - runReadAction { - PythonNotifier.notify("Requirements installation is complete") + if (installResult.exitValue != 0) { + showErrorDialogLater( + project, + "Requirements installing failed.
" + + "${installResult.stderr}

" + + "Try to install with pip:
" + + " ${requirements.joinToString("
")}", + "Requirements error" + ) + } else { + invokeLater { + runReadAction { + PythonNotifier.notify("Requirements installation is complete") + } + } } } } diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogWindow.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogWindow.kt index 32b83945a9..e675499ac7 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogWindow.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogWindow.kt @@ -63,6 +63,7 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj } init() + setOKButtonText(ACTION_GENERATE) } override fun createCenterPanel(): JComponent { @@ -140,19 +141,6 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj private fun checkMembers(members: Collection) = members.forEach { it.isChecked = true } - class OKOptionAction(private val okAction: Action) : AbstractAction(ACTION_GENERATE) { - init { - putValue(DEFAULT_ACTION, java.lang.Boolean.TRUE) - putValue(FOCUSED_ACTION, java.lang.Boolean.TRUE) - } - override fun actionPerformed(e: ActionEvent?) { - okAction.actionPerformed(e) - } - } - - private val okOptionAction: OKOptionAction get() = OKOptionAction(super.getOKAction()) - override fun getOKAction() = okOptionAction - override fun doOKAction() { val selectedMembers = pyElementsTable.selectedMemberInfos model.selectedElements = selectedMembers.mapNotNull { it.content }.toSet() diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index 264a23a689..01f4a81802 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -114,7 +114,7 @@ tasks { patchPluginXml { sinceBuild.set("223") - untilBuild.set("231.*") + untilBuild.set("232.*") version.set(semVer) } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt index 221cacad88..99500c19a3 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt @@ -172,7 +172,7 @@ class EngineProcess private constructor(val project: Project, private val classN } } - private fun computeSourceFileByClass(params: ComputeSourceFileByClassArguments): String = + private fun computeSourceFileByClass(params: ComputeSourceFileByClassArguments): String? = DumbService.getInstance(project).runReadActionInSmartMode { val scope = GlobalSearchScope.allScope(project) // JavaFileManager requires canonical name as it is said in import diff --git a/utbot-ui-commons/build.gradle.kts b/utbot-ui-commons/build.gradle.kts index ff729c6a4a..76e484069e 100644 --- a/utbot-ui-commons/build.gradle.kts +++ b/utbot-ui-commons/build.gradle.kts @@ -42,7 +42,7 @@ tasks { patchPluginXml { sinceBuild.set("223") - untilBuild.set("223.*") + untilBuild.set("232.*") version.set(semVer) } }