From 4bff0e1a77942f6d895f01118e21e9a6ac303bb4 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Mon, 12 Dec 2022 20:57:48 +0300 Subject: [PATCH] User's possibility to automatically increase limits on file size and tests number #1348 --- .../intellij/plugin/generator/CodeGenerationController.kt | 8 +++++--- .../kotlin/org/utbot/intellij/plugin/ui/Notifications.kt | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt index 5dbf400933..cc9f876f33 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt @@ -18,6 +18,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.fileTypes.FileType import com.intellij.openapi.module.Module import com.intellij.openapi.progress.ProgressIndicator +import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project import com.intellij.openapi.util.Computable @@ -97,6 +98,7 @@ import java.nio.file.Path import java.util.concurrent.CancellationException import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit +import org.utbot.intellij.plugin.util.showSettingsEditor import org.utbot.sarif.* object CodeGenerationController { @@ -771,9 +773,9 @@ object CodeGenerationController { if (fileLength > UtSettings.maxTestFileSize && file.name != model.codegenLanguage.utilClassFileName) { CommonLoggingNotifier().notify( "Size of ${file.virtualFile.presentableName} exceeds configured limit " + - "(${FileUtil.byteCountToDisplaySize(UtSettings.maxTestFileSize.toLong())}), reformatting was skipped. " + - "The limit can be configured in '{HOME_DIR}/.utbot/settings.properties' with 'maxTestFileSize' property", - model.project) + "(${FileUtil.byteCountToDisplaySize(UtSettings.maxTestFileSize.toLong())}), reformatting was skipped.", + model.project, model.testModule, arrayOf(DumbAwareAction.create("Configure the Limit") { showSettingsEditor(model.project, "maxTestFileSize") } + )) return } diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/Notifications.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/Notifications.kt index a5190f9769..9fbbf58b71 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/Notifications.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/Notifications.kt @@ -7,6 +7,7 @@ import com.intellij.notification.NotificationGroup import com.intellij.notification.NotificationListener import com.intellij.notification.NotificationType import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.keymap.KeymapUtil import com.intellij.openapi.module.Module @@ -29,8 +30,13 @@ abstract class Notifier { protected open fun content(project: Project?, module: Module?, info: String): String = info open fun notify(info: String, project: Project? = null, module: Module? = null) { + notify(info, project, module, AnAction.EMPTY_ARRAY) + } + + open fun notify(info: String, project: Project? = null, module: Module? = null, actions: Array) { notificationGroup - .createNotification(content(project, module, info), notificationType) + .createNotification(content(project, module, info), notificationType) + .apply { actions.forEach { this.addAction(it) } } .notify(project) }