Skip to content

Commit

Permalink
User's possibility to automatically increase limits on file size and … (
Browse files Browse the repository at this point in the history
#1510)

User's possibility to automatically increase limits on file size and tests number #1348
  • Loading branch information
Vassiliy-Kudryashov authored Dec 13, 2022
1 parent 9de97f8 commit 4b288cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<AnAction>) {
notificationGroup
.createNotification(content(project, module, info), notificationType)
.createNotification(content(project, module, info), notificationType)
.apply { actions.forEach { this.addAction(it) } }
.notify(project)
}

Expand Down

0 comments on commit 4b288cf

Please sign in to comment.