Skip to content

Update compatibility and dependencies, fix Python plugin integration a bit #2471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,13 +22,14 @@
import java.util.Collection;
import java.util.List;

public class UtPyMemberSelectionTable<T extends UtPyTableItem> extends JBTable implements DataProvider {
public class UtPyMemberSelectionTable<T extends UtPyTableItem> 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<T> myItems;
protected MyTableModel<T> myTableModel;
private DataProvider dataProvider;

public UtPyMemberSelectionTable(Collection<T> items) {
myItems = new ArrayList<>(items);
Expand All @@ -52,11 +54,22 @@ public void setItems(Collection<T> 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<T> getSelectedMemberInfos() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -24,20 +25,24 @@ class IntellijRequirementsInstaller(
override fun installRequirements(pythonPath: String, requirements: List<String>) {
invokeLater {
if (InstallRequirementsDialog(requirements).showAndGet()) {
val installResult = RequirementsUtils.installRequirements(pythonPath, requirements)
if (installResult.exitValue != 0) {
showErrorDialogLater(
project,
"Requirements installing failed.<br>" +
"${installResult.stderr}<br><br>" +
"Try to install with pip:<br>" +
" ${requirements.joinToString("<br>")}",
"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.<br>" +
"${installResult.stderr}<br><br>" +
"Try to install with pip:<br>" +
" ${requirements.joinToString("<br>")}",
"Requirements error"
)
} else {
invokeLater {
runReadAction {
PythonNotifier.notify("Requirements installation is complete")
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
}

init()
setOKButtonText(ACTION_GENERATE)
}

override fun createCenterPanel(): JComponent {
Expand Down Expand Up @@ -140,19 +141,6 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj

private fun checkMembers(members: Collection<UtPyTableItem>) = 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()
Expand Down
2 changes: 1 addition & 1 deletion utbot-intellij/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ tasks {

patchPluginXml {
sinceBuild.set("223")
untilBuild.set("231.*")
untilBuild.set("232.*")
version.set(semVer)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String?> {
val scope = GlobalSearchScope.allScope(project)
// JavaFileManager requires canonical name as it is said in import
Expand Down
2 changes: 1 addition & 1 deletion utbot-ui-commons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tasks {

patchPluginXml {
sinceBuild.set("223")
untilBuild.set("223.*")
untilBuild.set("232.*")
version.set(semVer)
}
}
Expand Down