Skip to content
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

User's possibility to automatically increase limits on file size and … #1510

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
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