don't extend DynamicBundle

GitOrigin-RevId: 4fd78070bd82f3c3aade54f6d869f222f5cb7bee
This commit is contained in:
Vladimir Krivosheev
2023-05-04 21:31:06 +02:00
committed by intellij-monorepo-bot
parent a518d1a094
commit cf3043ffcc
6 changed files with 24 additions and 29 deletions

View File

@@ -12,12 +12,11 @@ import java.util.function.Supplier;
/**
* Provides access to localized properties of the IntelliJ Platform.
*/
public final class ApplicationBundle extends DynamicBundle {
public final class ApplicationBundle {
public static final String BUNDLE = "messages.ApplicationBundle";
public static final ApplicationBundle INSTANCE = new ApplicationBundle();
public static final DynamicBundle INSTANCE = new DynamicBundle(ApplicationBundle.class, BUNDLE);
private ApplicationBundle() {
super(BUNDLE);
}
public static @NotNull @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {

View File

@@ -24,9 +24,10 @@ import com.jetbrains.packagesearch.intellij.plugin.gradle.GradlePackageVersionRa
internal class GradlePackageUpdateInspection : PackageUpdateInspection() {
override fun getStaticDescription(): String = PackageSearchBundle.getMessage("packagesearch.inspection.upgrade.description.gradle")
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes) =
dependencyDeclarationIndexes.coordinatesStartIndex
override fun getStaticDescription(): String = PackageSearchBundle.message("packagesearch.inspection.upgrade.description.gradle")
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes): Int {
return dependencyDeclarationIndexes.coordinatesStartIndex
}
override fun shouldCheckFile(file: PsiFile): Boolean =
hasSupportFor(file)

View File

@@ -25,7 +25,6 @@ import com.jetbrains.packagesearch.intellij.plugin.extensibility.ProjectModuleTy
internal class GradlePackageVersionRangeInspection : PackageVersionRangeInspection() {
companion object {
private const val FILE_TYPE_GROOVY = "groovy"
private const val FILE_TYPE_KOTLIN = "kotlin"
private const val EXTENSION_GRADLE = "gradle"
@@ -46,10 +45,11 @@ internal class GradlePackageVersionRangeInspection : PackageVersionRangeInspecti
projectModuleType is GradleProjectModuleType
}
override fun getStaticDescription(): String = PackageSearchBundle.getMessage("packagesearch.inspection.range.description.gradle")
override fun getStaticDescription(): String = PackageSearchBundle.message("packagesearch.inspection.range.description.gradle")
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes) =
dependencyDeclarationIndexes.coordinatesStartIndex
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes): Int {
return dependencyDeclarationIndexes.coordinatesStartIndex
}
override fun shouldCheckFile(file: PsiFile) = hasSupportFor(file)
}

View File

@@ -24,10 +24,10 @@ import org.jetbrains.idea.maven.utils.MavenUtil
internal class MavenPackageUpdateInspection : PackageUpdateInspection() {
override fun getStaticDescription(): String = PackageSearchBundle.getMessage("packagesearch.inspection.upgrade.description.maven")
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes) =
dependencyDeclarationIndexes.versionStartIndex
override fun getStaticDescription(): String = PackageSearchBundle.message("packagesearch.inspection.upgrade.description.maven")
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes): Int? {
return dependencyDeclarationIndexes.versionStartIndex
}
override fun shouldCheckFile(file: PsiFile) =
MavenUtil.isPomFile(file.project, file.virtualFile)
override fun shouldCheckFile(file: PsiFile) = MavenUtil.isPomFile(file.project, file.virtualFile)
}

View File

@@ -23,10 +23,10 @@ import com.jetbrains.packagesearch.intellij.plugin.extensibility.PackageVersionR
import org.jetbrains.idea.maven.utils.MavenUtil
internal class MavenPackageVersionRangeInspection : PackageVersionRangeInspection() {
override fun getStaticDescription(): String = PackageSearchBundle.getMessage("packagesearch.inspection.range.description.maven")
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes) =
dependencyDeclarationIndexes.versionStartIndex
override fun getStaticDescription(): String = PackageSearchBundle.message("packagesearch.inspection.range.description.maven")
override fun selectPsiElementIndex(dependencyDeclarationIndexes: DependencyDeclarationIndexes): Int? {
return dependencyDeclarationIndexes.versionStartIndex
}
override fun shouldCheckFile(file: PsiFile) = MavenUtil.isPomFile(file.project, file.virtualFile)
}

View File

@@ -19,19 +19,14 @@ package com.jetbrains.packagesearch.intellij.plugin
import com.intellij.DynamicBundle
import org.jetbrains.annotations.Nls
import org.jetbrains.annotations.PropertyKey
import java.util.function.Supplier
private const val BUNDLE_NAME = "messages.packageSearchBundle"
object PackageSearchBundle : DynamicBundle(BUNDLE_NAME) {
private const val BUNDLE = "messages.packageSearchBundle"
object PackageSearchBundle {
private val bundle = DynamicBundle(PackageSearchBundle::class.java, BUNDLE)
@Nls
fun message(
@PropertyKey(resourceBundle = BUNDLE_NAME) key: String,
@PropertyKey(resourceBundle = BUNDLE) key: String,
vararg params: Any
): String = getMessage(key, *params)
@Nls
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE_NAME) key: String, vararg params: Any): Supplier<String> =
getLazyMessage(key, *params)
): String = bundle.getMessage(key, *params)
}