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

chore: Show notification if run configuration is not supported #197

Merged
merged 2 commits into from
Dec 10, 2024
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 @@ -64,8 +64,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 @@ -78,6 +76,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
Loading