From ee68f394d01df92b5ca895f4d027794151c6f9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=80=A1=E7=84=B6?= <63996691+zhaodice@users.noreply.github.com> Date: Sat, 19 Nov 2022 01:53:16 +0800 Subject: [PATCH] Reformat --- .../src/internal/plugin/JvmPluginInternal.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt b/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt index 9e2960aa2c..fafd3a6947 100644 --- a/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt +++ b/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt @@ -128,16 +128,17 @@ internal abstract class JvmPluginInternal( val except = try { javaClass.getDeclaredAnnotation(ConsoleJvmPluginFuncCallbackStatusExcept.OnEnable::class.java) - }catch(e: Throwable){ + } catch (e: Throwable) { null } - + kotlin.runCatching { onEnable() }.fold( onSuccess = { if (except?.excepted == ConsoleJvmPluginFuncCallbackStatus.FAILED) { - val msg = "Test point '${javaClass.name}' assets failed but onEnable() invoked successfully" + val msg = + "Test point '${javaClass.name}' assets failed but onEnable() invoked successfully" cancel(msg) logger.error(msg) throw AssertionError(msg) @@ -205,7 +206,9 @@ internal abstract class JvmPluginInternal( .plus(parentCoroutineContext) .plus(CoroutineName("Plugin ${(this as AbstractJvmPlugin).dataHolderName}")) .plus( - SupervisorJob(parentCoroutineContext[Job] ?: JvmPluginLoader.coroutineContext[Job]!!) + SupervisorJob( + parentCoroutineContext[Job] ?: JvmPluginLoader.coroutineContext[Job]!! + ) ) .also { if (!MiraiConsole.isActive) return@also @@ -237,7 +240,10 @@ internal abstract class JvmPluginInternal( // endregion } -internal inline fun AtomicLong.updateWhen(condition: (Long) -> Boolean, update: (Long) -> Long): Boolean { +internal inline fun AtomicLong.updateWhen( + condition: (Long) -> Boolean, + update: (Long) -> Long +): Boolean { while (true) { val current = value if (condition(current)) { @@ -249,4 +255,5 @@ internal inline fun AtomicLong.updateWhen(condition: (Long) -> Boolean, update: } } -internal val Throwable.rootCauseOrSelf: Throwable get() = generateSequence(this) { it.cause }.lastOrNull() ?: this +internal val Throwable.rootCauseOrSelf: Throwable + get() = generateSequence(this) { it.cause }.lastOrNull() ?: this