Skip to content

Commit

Permalink
Review deprecation for 2.10. close #1742 (#1774)
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 authored Jan 14, 2022
1 parent 1299935 commit 7d39712
Show file tree
Hide file tree
Showing 49 changed files with 198 additions and 138 deletions.
2 changes: 1 addition & 1 deletion logging/mirai-logging-log4j2/test/MiraiLog4JAdapterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlin.test.assertIs

internal class MiraiLog4JAdapterTest {

@Suppress("DEPRECATION")
@Suppress("DEPRECATION_ERROR")
@Test
fun `services prevail than legacy overrides`() {
MiraiLogger.setDefaultLoggerCreator {
Expand Down
4 changes: 2 additions & 2 deletions mirai-console/backend/codegen/src/MessageScopeCodegen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ internal object MessageScopeCodegen {
@Deprecated(
"Senseless scopeWith. Use asMessageScope.",
ReplaceWith("this.asMessageScope()", "net.mamoe.mirai.console.util.asMessageScope")
)
) // diagnostic deprecation
public inline fun ${a}.scopeWith(): MessageScope = asMessageScope()
"""
)
Expand All @@ -181,7 +181,7 @@ internal object MessageScopeCodegen {
"net.mamoe.mirai.console.util.asMessageScope",
"net.mamoe.mirai.console.util.invoke",
)
)
) // diagnostic deprecation
public inline fun <R> ${a}.scopeWith(action: MessageScope.() -> R): R = asMessageScope()(action)
"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ public abstract interface class net/mamoe/mirai/console/plugin/PluginFileExtensi
public final class net/mamoe/mirai/console/plugin/PluginKt {
public static final fun getAuthor (Lnet/mamoe/mirai/console/plugin/Plugin;)Ljava/lang/String;
public static final fun getDependencies (Lnet/mamoe/mirai/console/plugin/Plugin;)Ljava/util/Set;
public static final fun getDescription (Lnet/mamoe/mirai/console/plugin/Plugin;)Lnet/mamoe/mirai/console/plugin/description/PluginDescription;
public static final synthetic fun getDescription (Lnet/mamoe/mirai/console/plugin/Plugin;)Lnet/mamoe/mirai/console/plugin/description/PluginDescription;
public static final fun getId (Lnet/mamoe/mirai/console/plugin/Plugin;)Ljava/lang/String;
public static final fun getInfo (Lnet/mamoe/mirai/console/plugin/Plugin;)Ljava/lang/String;
public static final fun getName (Lnet/mamoe/mirai/console/plugin/Plugin;)Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.message.data.PlainText
import net.mamoe.mirai.utils.childScope
import net.mamoe.mirai.utils.childScopeContext
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
import kotlin.coroutines.CoroutineContext
Expand Down Expand Up @@ -589,8 +590,9 @@ public open class MemberCommandSender internal constructor(
@Deprecated(
"mirai 正计划支持其他渠道发起的临时会话, 届时此事件会变动. 原 TempCommandSender 已更改为 GroupTempCommandSender",
replaceWith = ReplaceWith("GroupTempCommandSender", "net.mamoe.mirai.console.command.GroupTempCommandSender"),
DeprecationLevel.ERROR
DeprecationLevel.HIDDEN
)
@DeprecatedSinceMirai(errorSince = "2.0", hiddenSince = "2.10")
public sealed class TempCommandSender(
public override val user: NormalMember,
) : AbstractUserCommandSender(), GroupAwareCommandSender, CoroutineScope by user.childScope("TempCommandSender")
Expand Down Expand Up @@ -705,8 +707,9 @@ public class MemberCommandSenderOnMessage internal constructor(
"GroupTempCommandSenderOnMessage",
"net.mamoe.mirai.console.command.GroupTempCommandSenderOnMessage"
),
DeprecationLevel.ERROR
DeprecationLevel.HIDDEN
)
@DeprecatedSinceMirai(errorSince = "2.0", hiddenSince = "2.10")
public sealed class TempCommandSenderOnMessage(
public override val fromEvent: GroupTempMessageEvent,
) : GroupTempCommandSender(fromEvent.sender), CommandSenderOnMessage<GroupTempMessageEvent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package net.mamoe.mirai.console.data
import net.mamoe.mirai.console.data.PluginDataExtensions.withDefault
import net.mamoe.mirai.console.internal.data.ShadowMap
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import kotlin.internal.LowPriorityInOverloadResolution

/**
Expand All @@ -32,7 +33,7 @@ public object PluginDataExtensions {
"getOrDefault on NotNullMap always returns the value in the map, and defaultValue will never be returned.",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("this.get(key)")
)
) // diagnostic deprecation
override fun getOrDefault(key: K, defaultValue: V): V {
return super.getOrDefault(key, defaultValue)
}
Expand All @@ -49,7 +50,7 @@ public object PluginDataExtensions {
"getOrDefault on NotNullMutableMap always returns the value in the map, and defaultValue will never be returned.",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("this.get(key)")
)
) // diagnostic deprecation
override fun getOrDefault(key: K, defaultValue: V): V {
return super<MutableMap>.getOrDefault(key, defaultValue)
}
Expand All @@ -58,7 +59,7 @@ public object PluginDataExtensions {
"putIfAbsent on NotNullMutableMap always does nothing.",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("")
)
) // diagnostic deprecation
override fun putIfAbsent(key: K, value: V): Nothing? = null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal inline fun <T : Any> T?.ifNull(block: () -> T): T {
}

@Suppress("DeprecatedCallableAddReplaceWith", "UnusedParameter", "UNUSED_PARAMETER")
@Deprecated("Useless ifNull on not null value.")
@Deprecated("Useless ifNull on not null value.") // diagnostic deprecation
@JvmName("ifNull1")
internal inline fun <T : Any> T.ifNull(block: () -> T): T = this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import net.mamoe.mirai.console.internal.permission.parseFromStringImpl
import net.mamoe.mirai.console.permission.AbstractPermitteeId.*
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.contact.*
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import net.mamoe.mirai.utils.MiraiExperimentalApi

/**
Expand Down Expand Up @@ -275,8 +276,9 @@ public sealed class AbstractPermitteeId(
@Deprecated(
"use AnyGroupTemp",
ReplaceWith("AnyGroupTemp", "net.mamoe.mirai.console.permission.AbstractPermitteeId.AnyGroupTemp"),
DeprecationLevel.ERROR
DeprecationLevel.HIDDEN
)
@DeprecatedSinceMirai(errorSince = "2.0", hiddenSince = "2.10")
public abstract class AnyTemp(
groupId: Long,
) : AbstractPermitteeId(AnyMember(groupId), AnyTempFromAnyGroup)
Expand Down Expand Up @@ -308,8 +310,9 @@ public sealed class AbstractPermitteeId(
@Deprecated(
"use ExactGroupTemp",
ReplaceWith("ExactGroupTemp", "net.mamoe.mirai.console.permission.AbstractPermitteeId.ExactGroupTemp"),
DeprecationLevel.ERROR
DeprecationLevel.HIDDEN
)
@DeprecatedSinceMirai(errorSince = "2.0", hiddenSince = "2.10")
public abstract class ExactTemp internal constructor(
groupId: Long,
memberId: Long,
Expand Down
5 changes: 4 additions & 1 deletion mirai-console/backend/mirai-console/src/plugin/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import net.mamoe.mirai.console.plugin.description.PluginDescription
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
import net.mamoe.mirai.console.plugin.loader.PluginLoader
import net.mamoe.mirai.console.util.SemVersion
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import kotlin.DeprecationLevel.ERROR
import kotlin.DeprecationLevel.HIDDEN

/**
* 表示一个 mirai-console 插件.
Expand Down Expand Up @@ -53,8 +55,9 @@ public interface Plugin : CommandOwner {
@Deprecated(
"Moved to companion for a better Java API. ",
ReplaceWith("this.description", "net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.description"),
level = ERROR
level = HIDDEN
)
@DeprecatedSinceMirai(errorSince = "2.0", hiddenSince = "2.10")
public inline val Plugin.description: PluginDescription
get() = getPluginDescription(this) // resolved to net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.getDescription

Expand Down
18 changes: 9 additions & 9 deletions mirai-console/backend/mirai-console/src/util/MessageScope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -328,49 +328,49 @@ public inline fun <R> MessageScope?.scopeWith(vararg others: MessageScope?, acti
@Deprecated(
"Senseless scopeWith. Use asMessageScope.",
ReplaceWith("this.asMessageScope()", "net.mamoe.mirai.console.util.asMessageScope")
)
) // diagnostic deprecation
public inline fun Contact.scopeWith(): MessageScope = asMessageScope()

@Deprecated(
"Senseless scopeWith. Use asMessageScope.",
ReplaceWith("this.asMessageScope()", "net.mamoe.mirai.console.util.asMessageScope")
)
) // diagnostic deprecation
public inline fun CommandSender.scopeWith(): MessageScope = asMessageScope()

@Deprecated(
"Senseless scopeWith. Use asMessageScope.",
ReplaceWith("this.asMessageScope()", "net.mamoe.mirai.console.util.asMessageScope")
)
) // diagnostic deprecation
public inline fun MessageScope.scopeWith(): MessageScope = asMessageScope()

@Deprecated(
"Senseless scopeWith. Use .asMessageScope().invoke.",
ReplaceWith(
"this.asMessageScope()(action)",
"net.mamoe.mirai.console.util.asMessageScope",
"net.mamoe.mirai.console.util.invoke"
"net.mamoe.mirai.console.util.invoke",
)
)
) // diagnostic deprecation
public inline fun <R> Contact.scopeWith(action: MessageScope.() -> R): R = asMessageScope()(action)

@Deprecated(
"Senseless scopeWith. Use .asMessageScope().invoke.",
ReplaceWith(
"this.asMessageScope()(action)",
"net.mamoe.mirai.console.util.asMessageScope",
"net.mamoe.mirai.console.util.invoke"
"net.mamoe.mirai.console.util.invoke",
)
)
) // diagnostic deprecation
public inline fun <R> CommandSender.scopeWith(action: MessageScope.() -> R): R = asMessageScope()(action)

@Deprecated(
"Senseless scopeWith. Use .asMessageScope().invoke.",
ReplaceWith(
"this.asMessageScope()(action)",
"net.mamoe.mirai.console.util.asMessageScope",
"net.mamoe.mirai.console.util.invoke"
"net.mamoe.mirai.console.util.invoke",
)
)
) // diagnostic deprecation
public inline fun <R> MessageScope.scopeWith(action: MessageScope.() -> R): R = asMessageScope()(action)

//// endregion MessageScopeBuilders CODEGEN ////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins {
dependencies {
implementation("org.jline:jline:3.15.0")
implementation("org.fusesource.jansi:jansi:1.18")
compileAndTestRuntime(project(":mirai-core-utils"))

compileAndTestRuntime(project(":mirai-console"))
compileAndTestRuntime(project(":mirai-core-api"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@
package net.mamoe.mirai.console.terminal.net.mamoe.mirai.console.pure

import net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader
import net.mamoe.mirai.utils.DeprecatedSinceMirai

@Deprecated(
message = "Please use MiraiConsoleTerminalLoader",
level = DeprecationLevel.ERROR,
level = DeprecationLevel.HIDDEN,
replaceWith = ReplaceWith(
"MiraiConsoleTerminalLoader",
"net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader"
)
)
@DeprecatedSinceMirai(errorSince = "2.0", hiddenSince = "2.10")
object MiraiConsolePureLoader {
@Deprecated(
message = "for binary compatibility",
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
@JvmStatic
@DeprecatedSinceMirai(errorSince = "2.0", hiddenSince = "2.10")
fun main(args: Array<String>) {
System.err.println("WARNING: Mirai Console Pure已经更名为 Mirai Console Terminal")
System.err.println("请使用新的入口点 net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public open class MiraiConsoleExtension {
* 自定义配置 [BintrayExtension],覆盖
*/
@Suppress("DeprecatedCallableAddReplaceWith")
@Deprecated("不再支持发布到 bintray. 该配置会在 2.8 删除.", level = DeprecationLevel.WARNING)
@Deprecated("不再支持发布到 bintray. 该配置会在 2.8 删除.", level = DeprecationLevel.ERROR)
public fun bintray(configure: BintrayExtension.() -> Unit) {
bintrayConfigs.add(configure)
}
Expand All @@ -287,7 +287,7 @@ public open class MiraiConsoleExtension {
* 自定义配置 [BintrayExtension.PackageConfig]
*/
@Suppress("DeprecatedCallableAddReplaceWith")
@Deprecated("不再支持发布到 bintray. 该配置会在 2.8 删除.", level = DeprecationLevel.WARNING)
@Deprecated("不再支持发布到 bintray. 该配置会在 2.8 删除.", level = DeprecationLevel.ERROR)
public fun packageConfig(configure: BintrayExtension.PackageConfig.() -> Unit) {
bintrayPackageConfigConfigs.add(configure)
}
Expand Down
10 changes: 4 additions & 6 deletions mirai-core-api/compatibility-validation/android/api/android.api
Original file line number Diff line number Diff line change
Expand Up @@ -5670,7 +5670,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun getContactListCache ()Lnet/mamoe/mirai/utils/BotConfiguration$ContactListCache;
public static final fun getDefault ()Lnet/mamoe/mirai/utils/BotConfiguration;
public final fun getDeviceInfo ()Lkotlin/jvm/functions/Function1;
public final fun getFirstReconnectDelayMillis ()J
public final synthetic fun getFirstReconnectDelayMillis ()J
public final fun getHeartbeatPeriodMillis ()J
public final fun getHeartbeatStrategy ()Lnet/mamoe/mirai/utils/BotConfiguration$HeartbeatStrategy;
public final fun getHeartbeatTimeoutMillis ()J
Expand All @@ -5681,7 +5681,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun getNetworkLoggerSupplier ()Lkotlin/jvm/functions/Function1;
public final fun getParentCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
public final fun getProtocol ()Lnet/mamoe/mirai/utils/BotConfiguration$MiraiProtocol;
public final fun getReconnectPeriodMillis ()J
public final synthetic fun getReconnectPeriodMillis ()J
public final fun getReconnectionRetryTimes ()I
public final fun getStatHeartbeatPeriodMillis ()J
public final fun getWorkingDir ()Ljava/io/File;
Expand Down Expand Up @@ -5716,7 +5716,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun setContactListCache (Lnet/mamoe/mirai/utils/BotConfiguration$ContactListCache;)V
public final fun setConvertLineSeparator (Z)V
public final fun setDeviceInfo (Lkotlin/jvm/functions/Function1;)V
public final fun setFirstReconnectDelayMillis (J)V
public final synthetic fun setFirstReconnectDelayMillis (J)V
public final fun setHeartbeatPeriodMillis (J)V
public final fun setHeartbeatStrategy (Lnet/mamoe/mirai/utils/BotConfiguration$HeartbeatStrategy;)V
public final fun setHeartbeatTimeoutMillis (J)V
Expand All @@ -5727,7 +5727,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun setNetworkLoggerSupplier (Lkotlin/jvm/functions/Function1;)V
public final fun setParentCoroutineContext (Lkotlin/coroutines/CoroutineContext;)V
public final fun setProtocol (Lnet/mamoe/mirai/utils/BotConfiguration$MiraiProtocol;)V
public final fun setReconnectPeriodMillis (J)V
public final synthetic fun setReconnectPeriodMillis (J)V
public final fun setReconnectionRetryTimes (I)V
public final fun setShowingVerboseEventLog (Z)V
public final fun setStatHeartbeatPeriodMillis (J)V
Expand Down Expand Up @@ -5882,7 +5882,6 @@ public abstract interface class net/mamoe/mirai/utils/ExternalResource : java/io
public static fun create (Ljava/io/RandomAccessFile;Ljava/lang/String;Z)Lnet/mamoe/mirai/utils/ExternalResource;
public static fun create ([B)Lnet/mamoe/mirai/utils/ExternalResource;
public static fun create ([BLjava/lang/String;)Lnet/mamoe/mirai/utils/ExternalResource;
public static fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource;
public abstract fun getClosed ()Lkotlinx/coroutines/Deferred;
public abstract fun getFormatName ()Ljava/lang/String;
public abstract fun getMd5 ()[B
Expand Down Expand Up @@ -5947,7 +5946,6 @@ public final class net/mamoe/mirai/utils/ExternalResource$Companion {
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/InputStream;Ljava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/RandomAccessFile;Ljava/lang/String;ZILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;[BLjava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
public final fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource;
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;)Lnet/mamoe/mirai/message/MessageReceipt;
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lnet/mamoe/mirai/utils/RemoteFile$ProgressionCallback;)Lnet/mamoe/mirai/message/MessageReceipt;
Expand Down
Loading

0 comments on commit 7d39712

Please sign in to comment.