aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/utilities')
-rw-r--r--core/src/main/kotlin/utilities/ServiceLocator.kt17
-rw-r--r--core/src/main/kotlin/utilities/safeEnumValueOf.kt2
2 files changed, 8 insertions, 11 deletions
diff --git a/core/src/main/kotlin/utilities/ServiceLocator.kt b/core/src/main/kotlin/utilities/ServiceLocator.kt
index 00c9ae9f..3e515348 100644
--- a/core/src/main/kotlin/utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/utilities/ServiceLocator.kt
@@ -65,20 +65,17 @@ object ServiceLocator {
when (it.protocol) {
"file" -> it.toFile().listFiles()?.filter { it.extension == "properties" }?.map { lookupDescriptor(category, it.nameWithoutExtension) } ?: emptyList()
"jar" -> {
- val file = JarFile(URL(it.file.substringBefore("!")).toFile())
- try {
+ JarFile(URL(it.file.substringBefore("!")).toFile()).use { file ->
val jarPath = it.file.substringAfterLast("!").removePrefix("/").removeSuffix("/")
file.entries()
- .asSequence()
- .filter { entry -> !entry.isDirectory && entry.path == jarPath && entry.extension == "properties" }
- .map { entry ->
- lookupDescriptor(category, entry.fileName.substringBeforeLast("."))
- }.toList()
- } finally {
- file.close()
+ .asSequence()
+ .filter { entry -> !entry.isDirectory && entry.path == jarPath && entry.extension == "properties" }
+ .map { entry ->
+ lookupDescriptor(category, entry.fileName.substringBeforeLast("."))
+ }.toList()
}
}
- else -> emptyList<ServiceDescriptor>()
+ else -> emptyList()
}
}
}
diff --git a/core/src/main/kotlin/utilities/safeEnumValueOf.kt b/core/src/main/kotlin/utilities/safeEnumValueOf.kt
index 8fd5a086..9f4c23c9 100644
--- a/core/src/main/kotlin/utilities/safeEnumValueOf.kt
+++ b/core/src/main/kotlin/utilities/safeEnumValueOf.kt
@@ -1,4 +1,4 @@
package org.jetbrains.dokka.utilities
inline fun <reified T : Enum<*>> enumValueOrNull(name: String): T? =
- T::class.java.enumConstants.firstOrNull { it.name.toUpperCase() == name.toUpperCase() } \ No newline at end of file
+ T::class.java.enumConstants.firstOrNull { it.name.equals(name, ignoreCase = true) } \ No newline at end of file