From 5d5ef16235b151d6f9f4ed1c1ee9969f43ad64b7 Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Sat, 30 Aug 2025 10:15:28 +0200 Subject: [PATCH] Fix subclassing of DynamicBundle in ComposeTemplateBundle It is not recommended --- .../plugins/template/ComposeTemplateBundle.kt | 18 ++++++++++-------- .../template/weatherApp/ui/WeatherAppSample.kt | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/org/jetbrains/plugins/template/ComposeTemplateBundle.kt b/src/main/kotlin/org/jetbrains/plugins/template/ComposeTemplateBundle.kt index 12f61e3..e9f7242 100644 --- a/src/main/kotlin/org/jetbrains/plugins/template/ComposeTemplateBundle.kt +++ b/src/main/kotlin/org/jetbrains/plugins/template/ComposeTemplateBundle.kt @@ -1,20 +1,22 @@ package org.jetbrains.plugins.template import com.intellij.DynamicBundle -import org.jetbrains.annotations.NonNls +import org.jetbrains.annotations.Nls import org.jetbrains.annotations.PropertyKey +import java.util.function.Supplier -@NonNls private const val BUNDLE = "messages.ComposeTemplate" -object ComposeTemplateBundle : DynamicBundle(BUNDLE) { +object ComposeTemplateBundle { + private val instance = DynamicBundle(ComposeTemplateBundle::class.java, BUNDLE) @JvmStatic - fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = - getMessage(key, *params) + fun message(key: @PropertyKey(resourceBundle = BUNDLE) String, vararg params: Any?): @Nls String { + return instance.getMessage(key, *params) + } - @Suppress("unused") @JvmStatic - fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = - getLazyMessage(key, *params) + fun lazyMessage(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): Supplier<@Nls String> { + return instance.getLazyMessage(key, *params) + } } diff --git a/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt b/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt index 52f8e34..309ccbc 100644 --- a/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt +++ b/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt @@ -217,7 +217,7 @@ private fun MyLocationList( } ) { ContextPopupMenuItem( - ComposeTemplateBundle.getMessage("weather.app.context.menu.delete.option"), + ComposeTemplateBundle.message("weather.app.context.menu.delete.option"), AllIconsKeys.General.Delete ) { showPopup.value = false