Skip to content

Add hint for disabled fuzzing control #1411 #1429

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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.utbot.framework

import com.jetbrains.rd.util.LogLevel
import java.io.File
import mu.KotlinLogging
import org.utbot.common.AbstractSettings
import java.lang.reflect.Executable
Expand All @@ -9,12 +10,12 @@ private val logger = KotlinLogging.logger {}
/**
* Path to the utbot home folder.
*/
internal val utbotHomePath = "${System.getProperty("user.home")}/.utbot"
internal val utbotHomePath = "${System.getProperty("user.home")}${File.separatorChar}.utbot"

/**
* Default path for properties file
*/
private val defaultSettingsPath = "$utbotHomePath/settings.properties"
private val defaultSettingsPath = "$utbotHomePath${File.separatorChar}settings.properties"
private const val defaultKeyForSettingsPath = "utbot.settings.path"

/**
Expand All @@ -26,6 +27,9 @@ object UtSettings : AbstractSettings(
logger, defaultKeyForSettingsPath, defaultSettingsPath
) {

@JvmStatic
fun getPath(): String = System.getProperty(defaultKeyForSettingsPath)?: defaultSettingsPath

/**
* Setting to disable coroutines debug explicitly.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.DialogPanel
import com.intellij.ui.ContextHelpLabel
import com.intellij.ui.components.ActionLink
import com.intellij.ui.components.JBLabel
import com.intellij.ui.layout.CCFlags
import com.intellij.ui.layout.LayoutBuilder
Expand All @@ -20,6 +21,7 @@ import com.intellij.util.ui.components.BorderLayoutPanel
import javax.swing.DefaultComboBoxModel
import javax.swing.JCheckBox
import javax.swing.JPanel
import javax.swing.JSlider
import kotlin.reflect.KClass
import org.utbot.framework.UtSettings
import org.utbot.framework.codegen.domain.ForceStaticMocking
Expand All @@ -29,9 +31,9 @@ import org.utbot.framework.plugin.api.CodeGenerationSettingItem
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.api.JavaDocCommentStyle
import org.utbot.framework.plugin.api.TreatOverflowAsError
import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer
import javax.swing.JSlider
import org.utbot.framework.plugin.api.isSummarizationCompatible
import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer
import org.utbot.intellij.plugin.util.showSettingsEditor

class SettingsWindow(val project: Project) {
private val settings = project.service<Settings>()
Expand Down Expand Up @@ -209,6 +211,17 @@ class SettingsWindow(val project: Project) {
addToRight(symLabel)
}().constraints(CCFlags.growX)
}
if (!UtSettings.useFuzzing) {
row("") {
cell {
component(comment("Fuzzing is disabled in configuration file.").component)
component(ActionLink("Edit configuration") {
UIUtil.getWindow(fuzzLabel)?.dispose()
showSettingsEditor(project, "useFuzzing")
})
}
}
}
}

fun isModified(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.utbot.intellij.plugin.util

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.OpenFileDescriptor
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VfsUtil
import java.io.File
import java.nio.charset.Charset
import org.utbot.framework.UtSettings

fun showSettingsEditor(project: Project, key: String? = null) {
val ioFile = File(UtSettings.getPath())
ApplicationManager.getApplication().executeOnPooledThread {
var logicalLine: Int = -1
key?.let {
logicalLine = ioFile.readLines(Charset.defaultCharset())
.indexOfFirst { s -> s.startsWith("$key=") or s.startsWith("#$key=") }
}
VfsUtil.findFileByIoFile(ioFile, true)?.let {
val descriptor = if (logicalLine != -1) {
OpenFileDescriptor(project, it, logicalLine, 0)
} else {
OpenFileDescriptor(project, it)
}
ApplicationManager.getApplication().invokeLater {
FileEditorManager.getInstance(project).openTextEditor(descriptor, true)
}
}
}
}