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")
@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 {
/**
* 复制一份此时的 [Bot] 实例列表.

View File

@ -20,14 +20,14 @@ import java.util.concurrent.TimeoutException
*/
@MiraiInternalAPI
@Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused")
actual abstract class BotJavaHappyAPI actual constructor() {
actual abstract class BotJavaFriendlyAPI actual constructor() {
init {
@Suppress("LeakingThis")
assert(this is Bot)
}
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> {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,14 +20,14 @@ import java.util.concurrent.TimeoutException
*/
@MiraiInternalAPI
@Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused")
actual abstract class BotJavaHappyAPI actual constructor() {
actual abstract class BotJavaFriendlyAPI actual constructor() {
init {
@Suppress("LeakingThis")
assert(this is Bot)
}
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> {

View File

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

View File

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

View File

@ -12,7 +12,7 @@
package net.mamoe.mirai.contact
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.MessageSendEvent.FriendMessageSendEvent
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")
actual abstract class Member : MemberJavaFriendlyAPI() {
/**

View File

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