Skip to content

Commit 7f46841

Browse files
authored
Fix problem with Pycharm plugin #2720 (#2721)
* Create new module for Pycharm plugin * Change github script publish-plugin-from-branch.yml
1 parent e66620d commit 7f46841

File tree

12 files changed

+145
-23
lines changed

12 files changed

+145
-23
lines changed

.github/workflows/publish-plugin-from-branch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
directory: utbot-intellij-main
5353
- plugin_type: PY
5454
extra_options: "-PideType=PY -PprojectType=Ultimate"
55-
directory: utbot-intellij-python
55+
directory: utbot-python-pycharm
5656
runs-on: ubuntu-20.04
5757
container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0
5858
steps:

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ golandVersion=2023.2
1818
# ALL, NOJS
1919
buildType=NOJS
2020

21+
# IDE types that supports appropriate language
2122
javaIde=IC,IU
2223
pythonIde=IC,IU,PC,PY
2324
jsIde=IU,PY
2425
jsBuild=ALL
2526
goIde=IU,GO
2627

28+
# IDE types that require Pycharm plugin
29+
pycharmIdeType=PC,PY
30+
2731
# In order to run Android Studio instead of IntelliJ Community, specify the path to your Android Studio installation
2832
#androidStudioPath=your_path_to_android_studio
2933

settings.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ val ultimateEdition: String by settings
44

55
val ideType: String by settings
66
val buildType: String by settings
7+
val pycharmIdeType: String by settings
78

89
val javaIde: String by settings
910
val pythonIde: String by settings
@@ -65,6 +66,12 @@ include("utbot-spring-analyzer")
6566
include("utbot-spring-sample")
6667
include("utbot-spring-test")
6768

69+
if (pycharmIdeType.split(",").contains(ideType)) {
70+
include("utbot-python-pycharm")
71+
} else {
72+
include("utbot-intellij-main")
73+
}
74+
6875
if (javaIde.split(",").contains(ideType)) {
6976
include("utbot-intellij")
7077
}
@@ -93,4 +100,3 @@ if (projectType == ultimateEdition) {
93100
}
94101

95102
include("utbot-light")
96-
include("utbot-intellij-main")

utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ import org.utbot.intellij.plugin.settings.Settings
3131
import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater
3232
import org.utbot.python.PythonMethodHeader
3333
import org.utbot.python.PythonTestGenerationConfig
34-
import org.utbot.python.utils.RequirementsInstaller
3534
import org.utbot.python.TestFileInformation
3635
import org.utbot.python.framework.api.python.PythonClassId
3736
import org.utbot.python.framework.codegen.PythonCgLanguageAssistant
3837
import org.utbot.python.newtyping.mypy.dropInitFile
39-
import org.utbot.python.utils.PythonVersionChecker
38+
import org.utbot.python.utils.RequirementsInstaller
4039
import java.util.concurrent.ScheduledFuture
4140
import java.util.concurrent.TimeUnit
4241
import kotlin.io.path.Path
@@ -125,24 +124,16 @@ object PythonDialogProcessor {
125124
title = "Python test generation error"
126125
)
127126
} else {
128-
if (!PythonVersionChecker.checkPythonVersion(pythonPath)) {
129-
showErrorDialogLater(
130-
project,
131-
message = "Please use Python 3.10 or newer",
132-
title = "Python test generation error"
133-
)
134-
} else {
135-
val dialog = createDialog(
136-
project,
137-
elementsToShow,
138-
focusedElement,
139-
pythonPath,
140-
)
141-
if (!dialog.showAndGet()) {
142-
return
143-
}
144-
createTests(project, dialog.model)
127+
val dialog = createDialog(
128+
project,
129+
elementsToShow,
130+
focusedElement,
131+
pythonPath,
132+
)
133+
if (!dialog.showAndGet()) {
134+
return
145135
}
136+
createTests(project, dialog.model)
146137
}
147138
}
148139

utbot-python-pycharm/build.gradle.kts

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
val semVer: String? by rootProject
2+
val kotlinLoggingVersion: String? by rootProject
3+
4+
// === IDE settings ===
5+
val projectType: String by rootProject
6+
val communityEdition: String by rootProject
7+
val ultimateEdition: String by rootProject
8+
9+
val ideType: String by rootProject
10+
val androidStudioPath: String? by rootProject
11+
12+
val ideaVersion: String? by rootProject
13+
val pycharmVersion: String? by rootProject
14+
val golandVersion: String? by rootProject
15+
16+
val javaIde: String? by rootProject
17+
val pythonIde: String? by rootProject
18+
val jsIde: String? by rootProject
19+
val goIde: String? by rootProject
20+
21+
val ideVersion = when(ideType) {
22+
"PC", "PY" -> pycharmVersion
23+
"GO" -> golandVersion
24+
else -> ideaVersion
25+
}
26+
27+
val pythonCommunityPluginVersion: String? by rootProject
28+
val pythonUltimatePluginVersion: String? by rootProject
29+
val goPluginVersion: String? by rootProject
30+
31+
// https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file
32+
val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC"
33+
34+
project.tasks.asMap["runIde"]?.enabled = false
35+
// === IDE settings ===
36+
37+
plugins {
38+
id("org.jetbrains.intellij") version "1.13.1"
39+
}
40+
41+
tasks {
42+
compileKotlin {
43+
kotlinOptions {
44+
jvmTarget = "17"
45+
freeCompilerArgs = freeCompilerArgs + listOf("-Xallow-result-return-type", "-Xsam-conversions=class")
46+
allWarningsAsErrors = false
47+
}
48+
}
49+
50+
java {
51+
sourceCompatibility = JavaVersion.VERSION_17
52+
targetCompatibility = JavaVersion.VERSION_17
53+
}
54+
55+
patchPluginXml {
56+
sinceBuild.set("223")
57+
untilBuild.set("232.*")
58+
version.set(semVer)
59+
}
60+
}
61+
62+
dependencies {
63+
implementation(group = "io.github.microutils", name = "kotlin-logging", version = kotlinLoggingVersion)
64+
implementation(project(":utbot-ui-commons"))
65+
66+
//Family
67+
implementation(project(":utbot-intellij-python"))
68+
}
69+
70+
intellij {
71+
72+
val androidPlugins = listOf("org.jetbrains.android")
73+
74+
val jvmPlugins = mutableListOf(
75+
"java"
76+
)
77+
78+
val kotlinPlugins = listOf(
79+
"org.jetbrains.kotlin"
80+
)
81+
82+
androidStudioPath?.let { jvmPlugins += androidPlugins }
83+
84+
val pythonCommunityPlugins = listOf(
85+
"PythonCore:${pythonCommunityPluginVersion}"
86+
)
87+
88+
val pythonUltimatePlugins = listOf(
89+
"Pythonid:${pythonUltimatePluginVersion}"
90+
)
91+
92+
val jsPlugins = listOf(
93+
"JavaScript"
94+
)
95+
96+
val goPlugins = listOf(
97+
"org.jetbrains.plugins.go:${goPluginVersion}"
98+
)
99+
100+
val mavenUtilsPlugins = listOf(
101+
"org.jetbrains.idea.maven"
102+
)
103+
104+
val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins
105+
106+
plugins.set(
107+
when (projectType) {
108+
communityEdition -> basePluginSet + pythonCommunityPlugins
109+
ultimateEdition -> when (ideType) {
110+
"IC" -> basePluginSet + pythonCommunityPlugins
111+
"IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins
112+
"PC" -> pythonCommunityPlugins
113+
"PY" -> pythonUltimatePlugins + jsPlugins
114+
"GO" -> goPlugins
115+
else -> basePluginSet
116+
}
117+
else -> basePluginSet
118+
}
119+
)
120+
121+
version.set(ideVersion)
122+
type.set(ideType)
123+
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package org.utbot.intellij.plugin.python.ui.actions
33
import com.intellij.openapi.actionSystem.ActionUpdateThread
44
import com.intellij.openapi.actionSystem.AnAction
55
import com.intellij.openapi.actionSystem.AnActionEvent
6-
import com.intellij.openapi.components.service
76
import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant
8-
import org.utbot.intellij.plugin.settings.Settings
97

108
class GenerateTestsAction : AnAction() {
119
override fun actionPerformed(e: AnActionEvent) {

0 commit comments

Comments
 (0)