IJPL-157370 Refactor LocalizationUtil

Unnecessary conversion toList() before calling distinct() was removed in getLocalizedPathsWithDefault function, apply replaced to let. And removed redundant invocation with let in the getResourceAsStream method.

GitOrigin-RevId: da3536ac3923036600910960c6cb405929545e57
This commit is contained in:
Vera Petrenkova
2024-07-12 13:57:58 +02:00
committed by intellij-monorepo-bot
parent a9d4798099
commit 98ce361a93

View File

@@ -99,16 +99,16 @@ object LocalizationUtil {
defaultLoader?.getResourceAsStream(pathString)?.let { return it }
}
return getPluginClassLoader()?.getResourceAsStream(path.pathString) ?:
defaultLoader?.getResourceAsStream(path.pathString)?.let { return it }
defaultLoader?.getResourceAsStream(path.pathString)
}
@Internal
@JvmOverloads
fun getLocalizedPathsWithDefault(path: Path, specialLocale: Locale? = null): List<Path> {
val locale = specialLocale ?: getLocale()
return getLocalizedPaths(path, locale).toMutableList().apply {
add(path)
toList().distinct()
return getLocalizedPaths(path, locale).toMutableList().let {
it.add(path)
it.distinct()
}
}