Correct JavaHappy to JavaFriendly

This commit is contained in:
Him188 2020-03-24 16:39:06 +08:00
parent 472aaccbe9
commit 3e1925e2fc
16 changed files with 40 additions and 40 deletions

View File

@ -25,9 +25,9 @@ import net.mamoe.mirai.utils.*
*/ */
@Suppress("INAPPLICABLE_JVM_NAME") @Suppress("INAPPLICABLE_JVM_NAME")
@OptIn( @OptIn(
MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaFriendlyAPI::class
) )
actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaHappyAPI() { actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI() {
actual companion object { actual companion object {
/** /**
* 复制一份此时的 [Bot] 实例列表. * 复制一份此时的 [Bot] 实例列表.

View File

@ -20,14 +20,14 @@ import java.util.concurrent.TimeoutException
*/ */
@MiraiInternalAPI @MiraiInternalAPI
@Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused") @Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused")
actual abstract class BotJavaHappyAPI actual constructor() { actual abstract class BotJavaFriendlyAPI actual constructor() {
init { init {
@Suppress("LeakingThis") @Suppress("LeakingThis")
assert(this is Bot) assert(this is Bot)
} }
private inline fun <R> runBlocking(crossinline block: suspend Bot.() -> R): R { private inline fun <R> runBlocking(crossinline block: suspend Bot.() -> R): R {
return kotlinx.coroutines.runBlocking { block(this@BotJavaHappyAPI as Bot) } return kotlinx.coroutines.runBlocking { block(this@BotJavaFriendlyAPI as Bot) }
} }
private inline fun <R> future(crossinline block: suspend Bot.() -> R): Future<R> { private inline fun <R> future(crossinline block: suspend Bot.() -> R): Future<R> {

View File

@ -11,7 +11,7 @@ package net.mamoe.mirai.contact
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.BeforeImageUploadEvent import net.mamoe.mirai.event.events.BeforeImageUploadEvent
import net.mamoe.mirai.event.events.EventCancelledException import net.mamoe.mirai.event.events.EventCancelledException
import net.mamoe.mirai.event.events.ImageUploadEvent import net.mamoe.mirai.event.events.ImageUploadEvent
@ -32,7 +32,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
* *
* @author Him188moe * @author Him188moe
*/ */
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
actual abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI() { actual abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI() {
/** /**
* 这个联系人所属 [Bot]. * 这个联系人所属 [Bot].

View File

@ -13,7 +13,7 @@ import android.graphics.Bitmap
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.io.core.Input import kotlinx.io.core.Input
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.* import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent
import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent
@ -31,7 +31,7 @@ import java.net.URL
import java.util.concurrent.Future import java.util.concurrent.Future
@MiraiInternalAPI @MiraiInternalAPI
@JavaHappyAPI @JavaFriendlyAPI
@Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused") @Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused")
actual abstract class ContactJavaFriendlyAPI { actual abstract class ContactJavaFriendlyAPI {
@ -206,7 +206,7 @@ actual abstract class ContactJavaFriendlyAPI {
@Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused", "unused") @Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused", "unused")
@MiraiInternalAPI @MiraiInternalAPI
@JavaHappyAPI @JavaFriendlyAPI
actual abstract class MemberJavaFriendlyAPI : QQ() { actual abstract class MemberJavaFriendlyAPI : QQ() {
private inline fun <R> runBlocking(crossinline block: suspend Member.() -> R): R { private inline fun <R> runBlocking(crossinline block: suspend Member.() -> R): R {
@Suppress("CAST_NEVER_SUCCEEDS") @Suppress("CAST_NEVER_SUCCEEDS")

View File

@ -12,7 +12,7 @@
package net.mamoe.mirai.contact package net.mamoe.mirai.contact
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.* import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent
import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent
@ -25,7 +25,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
* 群成员. * 群成员.
*/ */
@Suppress("INAPPLICABLE_JVM_NAME") @Suppress("INAPPLICABLE_JVM_NAME")
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
actual abstract class Member : MemberJavaFriendlyAPI() { actual abstract class Member : MemberJavaFriendlyAPI() {
/** /**
* 所在的群. * 所在的群.

View File

@ -6,7 +6,7 @@ import kotlinx.atomicfu.atomic
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.LowLevelAPI import net.mamoe.mirai.LowLevelAPI
import net.mamoe.mirai.contact.* import net.mamoe.mirai.contact.*
import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.*
@ -121,19 +121,19 @@ actual open class MessageReceipt<C : Contact> actual constructor(
} }
@JavaHappyAPI @JavaFriendlyAPI
@JvmName("quoteReply") @JvmName("quoteReply")
fun __quoteReplyBlockingForJava__(message: Message) { fun __quoteReplyBlockingForJava__(message: Message) {
runBlocking { quoteReply(message) } runBlocking { quoteReply(message) }
} }
@JavaHappyAPI @JavaFriendlyAPI
@JvmName("recall") @JvmName("recall")
fun __recallBlockingForJava__() { fun __recallBlockingForJava__() {
runBlocking { recall() } runBlocking { recall() }
} }
@JavaHappyAPI @JavaFriendlyAPI
@JvmName("quote") @JvmName("quote")
fun __quoteBlockingForJava__() { fun __quoteBlockingForJava__() {
runBlocking { quote() } runBlocking { quote() }

View File

@ -14,7 +14,7 @@ package net.mamoe.mirai.contact
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.BeforeImageUploadEvent import net.mamoe.mirai.event.events.BeforeImageUploadEvent
import net.mamoe.mirai.event.events.EventCancelledException import net.mamoe.mirai.event.events.EventCancelledException
import net.mamoe.mirai.event.events.ImageUploadEvent import net.mamoe.mirai.event.events.ImageUploadEvent
@ -35,7 +35,7 @@ import kotlin.jvm.JvmSynthetic
* *
* @author Him188moe * @author Him188moe
*/ // 不要删除多平台结构 !!! kotlin bug */ // 不要删除多平台结构 !!! kotlin bug
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
expect abstract class Contact() : CoroutineScope, ContactJavaFriendlyAPI { expect abstract class Contact() : CoroutineScope, ContactJavaFriendlyAPI {
/** /**
* 这个联系人所属 [Bot]. * 这个联系人所属 [Bot].

View File

@ -12,7 +12,7 @@
package net.mamoe.mirai.contact package net.mamoe.mirai.contact
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.* import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.MessageReceipt
import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.Message
@ -26,7 +26,7 @@ import kotlin.time.ExperimentalTime
* 群成员. * 群成员.
*/ // 不要删除多平台结构, kotlin bug */ // 不要删除多平台结构, kotlin bug
@Suppress("INAPPLICABLE_JVM_NAME") @Suppress("INAPPLICABLE_JVM_NAME")
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
expect abstract class Member() : MemberJavaFriendlyAPI { expect abstract class Member() : MemberJavaFriendlyAPI {
/** /**
* 所在的群. * 所在的群.

View File

@ -9,19 +9,19 @@
package net.mamoe.mirai.contact package net.mamoe.mirai.contact
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.utils.MiraiInternalAPI import net.mamoe.mirai.utils.MiraiInternalAPI
/** /**
* [Contact] 中为了让 `Java` 更容易调用的 API * [Contact] 中为了让 `Java` 更容易调用的 API
*/ */
@MiraiInternalAPI @MiraiInternalAPI
@JavaHappyAPI @JavaFriendlyAPI
expect abstract class ContactJavaFriendlyAPI expect abstract class ContactJavaFriendlyAPI
/** /**
* [Member] 中为了让 `Java` 更容易调用的 API * [Member] 中为了让 `Java` 更容易调用的 API
*/ */
@MiraiInternalAPI @MiraiInternalAPI
@JavaHappyAPI @JavaFriendlyAPI
expect abstract class MemberJavaFriendlyAPI : QQ expect abstract class MemberJavaFriendlyAPI : QQ

View File

@ -17,14 +17,14 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
@MiraiInternalAPI @MiraiInternalAPI
@RequiresOptIn(level = RequiresOptIn.Level.ERROR) @RequiresOptIn(level = RequiresOptIn.Level.ERROR)
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.CLASS) @Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.CLASS)
annotation class JavaHappyAPI annotation class JavaFriendlyAPI
/** /**
* [Bot] 中为了让 Java 使用者调用更方便的 API 列表. * [Bot] 中为了让 Java 使用者调用更方便的 API 列表.
*/ */
@MiraiInternalAPI @MiraiInternalAPI
@Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused") @Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused")
expect abstract class BotJavaHappyAPI() { // 不要使用 interface, 会无法添加默认实现 expect abstract class BotJavaFriendlyAPI() { // 不要使用 interface, 会无法添加默认实现
} }
// 保留多平台结构, 以避免在 Android 和 JVM 都定义这个类 ---- 这会造成代码重复. // 保留多平台结构, 以避免在 Android 和 JVM 都定义这个类 ---- 这会造成代码重复.

View File

@ -25,9 +25,9 @@ import net.mamoe.mirai.utils.*
*/ */
@Suppress("INAPPLICABLE_JVM_NAME") @Suppress("INAPPLICABLE_JVM_NAME")
@OptIn( @OptIn(
MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaFriendlyAPI::class
) )
actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaHappyAPI() { actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI() {
actual companion object { actual companion object {
/** /**
* 复制一份此时的 [Bot] 实例列表. * 复制一份此时的 [Bot] 实例列表.
@ -46,7 +46,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
/** /**
* 遍历每一个 [Bot] 实例 * 遍历每一个 [Bot] 实例
*/ */
@JavaHappyAPI @JavaFriendlyAPI
@JvmName("forEachInstance") @JvmName("forEachInstance")
@Suppress("FunctionName") @Suppress("FunctionName")
fun __forEachInstanceForJava__(block: (Bot) -> Unit) = forEachInstance(block) fun __forEachInstanceForJava__(block: (Bot) -> Unit) = forEachInstance(block)

View File

@ -20,14 +20,14 @@ import java.util.concurrent.TimeoutException
*/ */
@MiraiInternalAPI @MiraiInternalAPI
@Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused") @Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused")
actual abstract class BotJavaHappyAPI actual constructor() { actual abstract class BotJavaFriendlyAPI actual constructor() {
init { init {
@Suppress("LeakingThis") @Suppress("LeakingThis")
assert(this is Bot) assert(this is Bot)
} }
private inline fun <R> runBlocking(crossinline block: suspend Bot.() -> R): R { private inline fun <R> runBlocking(crossinline block: suspend Bot.() -> R): R {
return kotlinx.coroutines.runBlocking { block(this@BotJavaHappyAPI as Bot) } return kotlinx.coroutines.runBlocking { block(this@BotJavaFriendlyAPI as Bot) }
} }
private inline fun <R> future(crossinline block: suspend Bot.() -> R): Future<R> { private inline fun <R> future(crossinline block: suspend Bot.() -> R): Future<R> {

View File

@ -11,7 +11,7 @@ package net.mamoe.mirai.contact
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.BeforeImageUploadEvent import net.mamoe.mirai.event.events.BeforeImageUploadEvent
import net.mamoe.mirai.event.events.EventCancelledException import net.mamoe.mirai.event.events.EventCancelledException
import net.mamoe.mirai.event.events.ImageUploadEvent import net.mamoe.mirai.event.events.ImageUploadEvent
@ -31,7 +31,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
* *
* @author Him188moe * @author Him188moe
*/ */
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
actual abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI() { actual abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI() {
/** /**
* 这个联系人所属 [Bot]. * 这个联系人所属 [Bot].

View File

@ -12,7 +12,7 @@ package net.mamoe.mirai.contact
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.io.core.Input import kotlinx.io.core.Input
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.* import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent
import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent
@ -31,7 +31,7 @@ import java.net.URL
import java.util.concurrent.Future import java.util.concurrent.Future
@MiraiInternalAPI @MiraiInternalAPI
@JavaHappyAPI @JavaFriendlyAPI
@Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused") @Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused")
actual abstract class ContactJavaFriendlyAPI { actual abstract class ContactJavaFriendlyAPI {
@ -204,7 +204,7 @@ actual abstract class ContactJavaFriendlyAPI {
@Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused", "unused") @Suppress("INAPPLICABLE_JVM_NAME", "FunctionName", "unused", "unused")
@MiraiInternalAPI @MiraiInternalAPI
@JavaHappyAPI @JavaFriendlyAPI
actual abstract class MemberJavaFriendlyAPI : QQ() { actual abstract class MemberJavaFriendlyAPI : QQ() {
private inline fun <R> runBlocking(crossinline block: suspend Member.() -> R): R { private inline fun <R> runBlocking(crossinline block: suspend Member.() -> R): R {
@Suppress("CAST_NEVER_SUCCEEDS") @Suppress("CAST_NEVER_SUCCEEDS")

View File

@ -12,7 +12,7 @@
package net.mamoe.mirai.contact package net.mamoe.mirai.contact
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.event.events.* import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent
import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent import net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent
@ -24,7 +24,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
/** /**
* 群成员. * 群成员.
*/ */
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
@Suppress("INAPPLICABLE_JVM_NAME") @Suppress("INAPPLICABLE_JVM_NAME")
actual abstract class Member : MemberJavaFriendlyAPI() { actual abstract class Member : MemberJavaFriendlyAPI() {
/** /**

View File

@ -6,7 +6,7 @@ import kotlinx.atomicfu.atomic
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.JavaHappyAPI import net.mamoe.mirai.JavaFriendlyAPI
import net.mamoe.mirai.LowLevelAPI import net.mamoe.mirai.LowLevelAPI
import net.mamoe.mirai.contact.* import net.mamoe.mirai.contact.*
import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.*
@ -113,19 +113,19 @@ actual open class MessageReceipt<C : Contact> actual constructor(
} }
@JavaHappyAPI @JavaFriendlyAPI
@JvmName("quoteReply") @JvmName("quoteReply")
fun __quoteReplyBlockingForJava__(message: Message) { fun __quoteReplyBlockingForJava__(message: Message) {
runBlocking { quoteReply(message) } runBlocking { quoteReply(message) }
} }
@JavaHappyAPI @JavaFriendlyAPI
@JvmName("recall") @JvmName("recall")
fun __recallBlockingForJava__() { fun __recallBlockingForJava__() {
runBlocking { recall() } runBlocking { recall() }
} }
@JavaHappyAPI @JavaFriendlyAPI
@JvmName("quote") @JvmName("quote")
fun __quoteBlockingForJava__() { fun __quoteBlockingForJava__() {
runBlocking { quote() } runBlocking { quote() }