From 11688b1decb07382d8bdec5c6e0eff83c031e41c Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sat, 12 Sep 2020 19:40:34 +0800 Subject: [PATCH] Correct class naming following Kotlin formal style --- .../mirai/console/pure/ConsolePureSettings.kt | 4 +- .../mamoe/mirai/console/pure/ConsoleThread.kt | 2 +- .../pure/MiraiConsoleImplementationPure.kt | 2 +- .../console/pure/MiraiConsolePureLoader.kt | 6 +-- .../mirai/console/pure/noconsole/NoConsole.kt | 45 +++++++------------ 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsolePureSettings.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsolePureSettings.kt index 68ea3c074..5a1fdec47 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsolePureSettings.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsolePureSettings.kt @@ -23,9 +23,9 @@ package net.mamoe.mirai.console.pure AnnotationTarget.CONSTRUCTOR ) @MustBeDocumented -annotation class ConsolePureExperimentalAPI +annotation class ConsolePureExperimentalApi -@ConsolePureExperimentalAPI +@ConsolePureExperimentalApi public object ConsolePureSettings { @JvmField var setupAnsi: Boolean = System.getProperty("os.name") diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt index 22684d20c..276c6ed18 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt @@ -27,7 +27,7 @@ import org.jline.reader.UserInterruptException val consoleLogger by lazy { DefaultLogger("console") } -@OptIn(ConsoleInternalApi::class, ConsolePureExperimentalAPI::class) +@OptIn(ConsoleInternalApi::class, ConsolePureExperimentalApi::class) internal fun startupConsoleThread() { if (ConsolePureSettings.noConsole) return diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt index ed17d6916..f55466259 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt @@ -17,7 +17,7 @@ "INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING", "EXPOSED_SUPER_CLASS" ) -@file:OptIn(ConsoleInternalApi::class, ConsoleFrontEndImplementation::class, ConsolePureExperimentalAPI::class) +@file:OptIn(ConsoleInternalApi::class, ConsoleFrontEndImplementation::class, ConsolePureExperimentalApi::class) package net.mamoe.mirai.console.pure diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt index 946d3afdf..0fa6abe1f 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt @@ -15,7 +15,7 @@ "INVISIBLE_GETTER", "INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER", ) -@file:OptIn(ConsoleInternalApi::class, ConsolePureExperimentalAPI::class) +@file:OptIn(ConsoleInternalApi::class, ConsolePureExperimentalApi::class) package net.mamoe.mirai.console.pure @@ -53,7 +53,7 @@ object MiraiConsolePureLoader { } } - @ConsolePureExperimentalAPI + @ConsolePureExperimentalApi fun printHelpMessage() { val help = listOf( "" to "Mirai-Console[Pure FrontEnd] v" + kotlin.runCatching { @@ -96,7 +96,7 @@ object MiraiConsolePureLoader { } } - @ConsolePureExperimentalAPI + @ConsolePureExperimentalApi fun parse(args: Array, exitProcess: Boolean = false) { val iterator = args.iterator() while (iterator.hasNext()) { diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt index d77667538..d04a69470 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt @@ -10,11 +10,11 @@ /* * @author Karlatemp */ -@file:OptIn(ConsolePureExperimentalAPI::class) +@file:OptIn(ConsolePureExperimentalApi::class) package net.mamoe.mirai.console.pure.noconsole -import net.mamoe.mirai.console.pure.ConsolePureExperimentalAPI +import net.mamoe.mirai.console.pure.ConsolePureExperimentalApi import net.mamoe.mirai.console.pure.ConsolePureSettings import org.jline.keymap.KeyMap import org.jline.reader.* @@ -38,8 +38,7 @@ internal object NoConsoleNonBlockingReader : NonBlockingReader() { return LN_INT } - override fun close() { - } + override fun close() {} override fun readBuffered(b: CharArray?): Int { return 0 @@ -47,13 +46,9 @@ internal object NoConsoleNonBlockingReader : NonBlockingReader() { } internal object AllNextLineInputStream : InputStream() { - override fun read(): Int { - return LN_INT - } + override fun read(): Int = LN_INT - override fun available(): Int { - return 1 - } + override fun available(): Int = 1 override fun read(b: ByteArray, off: Int, len: Int): Int { for (i in off until (off + len)) { @@ -62,28 +57,19 @@ internal object AllNextLineInputStream : InputStream() { return len } - override fun close() { - } + override fun close() {} } internal object AllIgnoredOutputStream : OutputStream() { - override fun close() { - } - - override fun write(b: ByteArray, off: Int, len: Int) { - } - - override fun write(b: ByteArray) { - } - - override fun write(b: Int) { - } - - override fun flush() { - } + override fun close() {} + override fun write(b: ByteArray, off: Int, len: Int) {} + override fun write(b: ByteArray) {} + override fun write(b: Int) {} + override fun flush() {} } internal val SystemOutputPrintStream by lazy { + @OptIn(ConsolePureExperimentalApi::class) if (ConsolePureSettings.setupAnsi) { org.fusesource.jansi.AnsiConsole.systemInstall() } @@ -95,12 +81,13 @@ internal object AllEmptyLineReader : LineReader { override fun printAbove(str: String?) { if (str == null) return + @OptIn(ConsolePureExperimentalApi::class) if (ConsolePureSettings.noAnsi) { SystemOutputPrintStream.println(ANSI_REGEX.replace(str, "")) } else SystemOutputPrintStream.println(str) } - @OptIn(ConsolePureExperimentalAPI::class) + @OptIn(ConsolePureExperimentalApi::class) override fun readLine(): String = if (ConsolePureSettings.noConsoleSafeReading) ConsolePureSettings.noConsoleReadingReplacement else error("Unsupported Reading line when console front-end closed.") @@ -111,13 +98,13 @@ internal object AllEmptyLineReader : LineReader { override fun readLine(prompt: String?): String = readLine() override fun readLine(prompt: String?, mask: Char?): String = readLine() override fun readLine(prompt: String?, mask: Char?, buffer: String?): String = readLine() - override fun readLine(prompt: String?, rightPrompt: String?, mask: Char?, buffer: String?): String = "" + override fun readLine(prompt: String?, rightPrompt: String?, mask: Char?, buffer: String?): String = readLine() override fun readLine( prompt: String?, rightPrompt: String?, maskingCallback: MaskingCallback?, buffer: String? - ): String = "" + ): String = readLine() override fun printAbove(str: AttributedString?) { str?.let { printAbove(it.toAnsi()) }