Skip to content

Commit

Permalink
Show notification if run configuration is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinVaadin committed Dec 2, 2024
1 parent b028e18 commit 7c05862
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class CopilotPluginUtil {

private const val NORMALIZED_LINE_SEPARATOR = "\n"

private const val NOTIFICATION_GROUP = "Vaadin Copilot"

private enum class HANDLERS(val command: String) {
WRITE("write"),
WRITE_BASE64("writeBase64"),
Expand All @@ -66,6 +64,8 @@ class CopilotPluginUtil {

private val pluginVersion = PluginManagerCore.getPlugin(PluginId.getId("com.vaadin.intellij-plugin"))?.version

const val NOTIFICATION_GROUP = "Vaadin Copilot"

fun getPluginVersion(): String? {
return pluginVersion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import com.intellij.execution.JavaRunConfigurationBase
import com.intellij.execution.configurations.JavaCommandLine
import com.intellij.execution.configurations.RunProfile
import com.intellij.execution.runners.ExecutionEnvironment
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.openapi.application.ApplicationManager
import com.vaadin.plugin.copilot.CopilotPluginUtil.Companion.NOTIFICATION_GROUP

class HotswapAgentRunner : GenericDebuggerRunner() {

Expand All @@ -18,9 +21,19 @@ class HotswapAgentRunner : GenericDebuggerRunner() {
}

override fun execute(environment: ExecutionEnvironment) {
val runProfile =
environment.runProfile as? JavaRunConfigurationBase
?: throw IllegalStateException("$runnerId can only run Java configurations")

if (environment.runProfile !is JavaRunConfigurationBase) {
Notification(
NOTIFICATION_GROUP,
"To launch, open the Spring Boot application class and press \"Debug using Hotswap Agent\". " +
"Do not launch through Maven or Gradle.",
NotificationType.WARNING)
.setTitle("Only Spring Boot applications are supported")
.notify(environment.project)
return
}

val runProfile = environment.runProfile as JavaRunConfigurationBase
val javaCommandLine =
environment.state as? JavaCommandLine ?: throw IllegalStateException("$runnerId needs a JavaCommandLine")
val module = runProfile.configurationModule?.module ?: throw IllegalStateException("$runnerId needs a module")
Expand Down

0 comments on commit 7c05862

Please sign in to comment.