Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 23afe65

Browse files
Vassiliy-Kudryashovdenis-fokin
authored andcommitted
Summaries should be turned off for Kotlin related generations #1283 (#1298)
(cherry picked from commit 8734d59)
1 parent 9bfae4d commit 23afe65

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

‎utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,8 @@ enum class CodegenLanguage(
12961296
override val allItems: List<CodegenLanguage> = values().toList()
12971297
}
12981298
}
1299+
//TODO #1279
1300+
fun CodegenLanguage?.isSummarizationCompatible() = this == CodegenLanguage.JAVA
12991301

13001302
// https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#commandlineargfile
13011303
fun isolateCommandLineArgumentsToArgumentFile(arguments: List<String>): String {

‎utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Settings.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import org.utbot.framework.plugin.api.TreatOverflowAsError
3232
import org.utbot.intellij.plugin.models.GenerateTestsModel
3333
import java.util.concurrent.CompletableFuture
3434
import kotlin.reflect.KClass
35+
import org.utbot.framework.plugin.api.isSummarizationCompatible
3536

3637
@State(
3738
name = "UtBotSettings",
@@ -175,6 +176,9 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
175176

176177
override fun loadState(state: State) {
177178
this.state = state
179+
if (!state.codegenLanguage.isSummarizationCompatible()) {
180+
this.state.enableSummariesGeneration = false
181+
}
178182
}
179183

180184
fun loadStateFromModel(model: GenerateTestsModel) {

‎utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.utbot.intellij.plugin.settings
22

33
import com.intellij.openapi.components.service
44
import com.intellij.openapi.project.Project
5+
import com.intellij.openapi.ui.ComboBox
56
import com.intellij.openapi.ui.DialogPanel
67
import com.intellij.ui.ContextHelpLabel
78
import com.intellij.ui.components.JBLabel
@@ -10,6 +11,7 @@ import com.intellij.ui.layout.LayoutBuilder
1011
import com.intellij.ui.layout.PropertyBinding
1112
import com.intellij.ui.layout.labelTable
1213
import com.intellij.ui.layout.panel
14+
import com.intellij.ui.layout.selectedValueMatches
1315
import com.intellij.ui.layout.slider
1416
import com.intellij.ui.layout.withValueBinding
1517
import com.intellij.util.castSafelyTo
@@ -29,27 +31,42 @@ import org.utbot.framework.plugin.api.JavaDocCommentStyle
2931
import org.utbot.framework.plugin.api.TreatOverflowAsError
3032
import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer
3133
import javax.swing.JSlider
34+
import org.utbot.framework.plugin.api.isSummarizationCompatible
3235

3336
class SettingsWindow(val project: Project) {
3437
private val settings = project.service<Settings>()
3538

3639
// TODO it is better to use something like SearchEverywhere for classes but it is complicated to implement
40+
private lateinit var codegenLanguageCombo: ComboBox<CodegenLanguage>
3741
private val excludeTable = MockAlwaysClassesTable(project)
3842
private lateinit var runInspectionAfterTestGenerationCheckBox: JCheckBox
3943
private lateinit var forceMockCheckBox: JCheckBox
4044
private lateinit var enableSummarizationGenerationCheckBox: JCheckBox
4145

4246
val panel: JPanel = panel {
47+
row("Generated test language:") {
48+
cell {
49+
codegenLanguageCombo = comboBox(
50+
DefaultComboBoxModel(CodegenLanguage.values()),
51+
getter = { settings.providerNameByServiceLoader(CodegenLanguage::class) as CodegenLanguage },
52+
setter = { settings.setProviderByLoader(CodegenLanguage::class, it as CodeGenerationSettingItem) }
53+
).apply {
54+
component.renderer = CodeGenerationSettingItemRenderer()
55+
ContextHelpLabel.create("You can generate test methods in Java or Kotlin regardless of your source code language.")
56+
}.component
57+
codegenLanguageCombo.addActionListener {
58+
if (!codegenLanguageCombo.item.isSummarizationCompatible()) {
59+
enableSummarizationGenerationCheckBox.isSelected = false
60+
}
61+
}
62+
}
63+
}
4364
val valuesComboBox: LayoutBuilder.(KClass<*>, Array<*>) -> Unit = { loader, values ->
4465
val serviceLabels = mapOf(
45-
CodegenLanguage::class to "Generated test language:",
4666
RuntimeExceptionTestsBehaviour::class to "Tests with exceptions:",
4767
TreatOverflowAsError::class to "Overflow detection:",
4868
JavaDocCommentStyle::class to "Javadoc comment style:"
4969
)
50-
val tooltipLabels = mapOf(
51-
CodegenLanguage::class to "You can generate test methods in Java or Kotlin regardless of your source code language."
52-
)
5370

5471
row(serviceLabels[loader] ?: error("Unknown service loader: $loader")) {
5572
cell {
@@ -59,14 +76,11 @@ class SettingsWindow(val project: Project) {
5976
setter = { settings.setProviderByLoader(loader, it as CodeGenerationSettingItem) },
6077
).apply {
6178
component.renderer = CodeGenerationSettingItemRenderer()
62-
ContextHelpLabel.create(tooltipLabels[loader] ?: return@apply)()
6379
}
6480
}
6581
}
6682
}
6783

68-
valuesComboBox(CodegenLanguage::class, CodegenLanguage.values())
69-
7084
row("Hanging test timeout:") {
7185
cell {
7286
spinner(
@@ -129,6 +143,7 @@ class SettingsWindow(val project: Project) {
129143
.onIsModified {
130144
enableSummarizationGenerationCheckBox.isSelected xor settings.state.enableSummariesGeneration
131145
}
146+
.enableIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible))
132147
.component
133148
}
134149
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /