Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
d8ef80ea
Commit
d8ef80ea
authored
May 11, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust visibility
parent
2295e832
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
75 deletions
+22
-75
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
...commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
+20
-73
mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt
...Test/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt
+2
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
View file @
d8ef80ea
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
@
file
:
Suppress
(
@
file
:
Suppress
(
"MemberVisibilityCanBePrivate"
,
"unused"
,
"EXPERIMENTAL_API_USAGE"
,
"MemberVisibilityCanBePrivate"
,
"unused"
,
"EXPERIMENTAL_API_USAGE"
,
"NOTHING_TO_INLINE"
,
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
"NOTHING_TO_INLINE"
,
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
,
"INAPPLICABLE_JVM_NAME"
,
"WRONG_MODIFIER_CONTAINING_DECLARATION"
)
)
@
file
:
JvmMultifileClass
@
file
:
JvmMultifileClass
@
file
:
JvmName
(
"MessageUtils"
)
@
file
:
JvmName
(
"MessageUtils"
)
...
@@ -23,10 +24,9 @@ import net.mamoe.mirai.contact.Contact
...
@@ -23,10 +24,9 @@ import net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.message.MessageEvent
import
net.mamoe.mirai.message.MessageEvent
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Message.Key
import
net.mamoe.mirai.message.data.Message.Key
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.PlannedRemoval
import
net.mamoe.mirai.utils.PlannedRemoval
import
kotlin.contracts.contract
import
kotlin.contracts.contract
import
kotlin.internal.HidesMembers
import
kotlin.internal.LowPriorityInOverloadResolution
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmSynthetic
import
kotlin.jvm.JvmSynthetic
...
@@ -166,7 +166,8 @@ interface Message { // must be interface. Don't consider any changes.
...
@@ -166,7 +166,8 @@ interface Message { // must be interface. Don't consider any changes.
*
*
* @sample net.mamoe.mirai.message.data.ContentEqualsTest
* @sample net.mamoe.mirai.message.data.ContentEqualsTest
*/
*/
fun
contentEquals
(
another
:
Message
,
ignoreCase
:
Boolean
=
false
):
Boolean
=
contentEqualsImpl
(
another
,
ignoreCase
)
final
fun
contentEquals
(
another
:
Message
,
ignoreCase
:
Boolean
=
false
):
Boolean
=
contentEqualsImpl
(
another
,
ignoreCase
)
/**
/**
* 判断内容是否与 [another] 相等.
* 判断内容是否与 [another] 相等.
...
@@ -177,7 +178,7 @@ interface Message { // must be interface. Don't consider any changes.
...
@@ -177,7 +178,7 @@ interface Message { // must be interface. Don't consider any changes.
*
*
* @sample net.mamoe.mirai.message.data.ContentEqualsTest
* @sample net.mamoe.mirai.message.data.ContentEqualsTest
*/
*/
fun
contentEquals
(
another
:
String
,
ignoreCase
:
Boolean
=
false
):
Boolean
{
f
inal
f
un
contentEquals
(
another
:
String
,
ignoreCase
:
Boolean
=
false
):
Boolean
{
if
(!
this
.
contentToString
().
equals
(
another
,
ignoreCase
=
ignoreCase
))
return
false
if
(!
this
.
contentToString
().
equals
(
another
,
ignoreCase
=
ignoreCase
))
return
false
return
when
(
this
)
{
return
when
(
this
)
{
is
SingleMessage
->
true
is
SingleMessage
->
true
...
@@ -186,70 +187,25 @@ interface Message { // must be interface. Don't consider any changes.
...
@@ -186,70 +187,25 @@ interface Message { // must be interface. Don't consider any changes.
}
}
}
}
@LowPriorityInOverloadResolution
final
operator
fun
plus
(
another
:
MessageChain
):
MessageChain
=
this
+
another
as
Message
@PlannedRemoval
(
"1.2.0"
)
final
operator
fun
plus
(
another
:
Message
):
MessageChain
=
this
.
followedBy
(
another
)
@JvmSynthetic
final
operator
fun
plus
(
another
:
SingleMessage
):
MessageChain
=
this
.
followedBy
(
another
)
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
final
operator
fun
plus
(
another
:
String
):
MessageChain
=
this
.
followedBy
(
another
.
toMessage
())
operator
fun
plus
(
another
:
Message
):
MessageChain
=
this
.
followedBy
(
another
)
final
operator
fun
plus
(
another
:
CharSequence
):
MessageChain
=
this
.
followedBy
(
another
.
toString
().
toMessage
())
final
operator
fun
plus
(
another
:
Iterable
<
Message
>):
MessageChain
=
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@PlannedRemoval
(
"1.2.0"
)
@JvmName
(
"plusIterableString"
)
@LowPriorityInOverloadResolution
final
operator
fun
plus
(
another
:
Iterable
<
String
>):
MessageChain
=
@JvmSynthetic
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
operator
fun
plus
(
another
:
SingleMessage
):
MessageChain
=
this
.
followedBy
(
another
)
@PlannedRemoval
(
"1.2.0"
)
final
operator
fun
plus
(
another
:
Sequence
<
Message
>):
MessageChain
=
@JvmSynthetic
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@LowPriorityInOverloadResolution
// won't be resolved
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
operator
fun
plus
(
another
:
String
):
MessageChain
=
this
.
followedBy
(
another
.
toMessage
())
@PlannedRemoval
(
"1.2.0"
)
@LowPriorityInOverloadResolution
@JvmSynthetic
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
operator
fun
plus
(
another
:
CharSequence
):
MessageChain
=
this
.
followedBy
(
another
.
toString
().
toMessage
())
}
}
@MiraiExperimentalAPI
@JvmSynthetic
@JvmSynthetic
@HidesMembers
inline
operator
fun
Message
.
plus
(
another
:
Message
):
MessageChain
=
this
.
followedBy
(
another
)
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
SingleMessage
):
MessageChain
=
this
.
followedBy
(
another
)
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
String
):
MessageChain
=
this
.
followedBy
(
another
.
toMessage
())
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
CharSequence
):
MessageChain
=
this
.
followedBy
(
another
.
toString
().
toMessage
())
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
Iterable
<
Message
>):
MessageChain
=
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@JvmName
(
"plus1"
)
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
Iterable
<
String
>):
MessageChain
=
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@JvmSynthetic
@HidesMembers
inline
operator
fun
Message
.
plus
(
another
:
Sequence
<
Message
>):
MessageChain
=
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
MessageChain
):
MessageChain
=
this
+
another
as
Message
@ExperimentalCoroutinesApi
@ExperimentalCoroutinesApi
@HidesMembers
@JvmSynthetic
suspend
inline
operator
fun
Message
.
plus
(
another
:
Flow
<
Message
>):
MessageChain
=
suspend
inline
operator
fun
Message
.
plus
(
another
:
Flow
<
Message
>):
MessageChain
=
another
.
fold
(
this
)
{
acc
,
it
->
acc
+
it
}.
asMessageChain
()
another
.
fold
(
this
)
{
acc
,
it
->
acc
+
it
}.
asMessageChain
()
...
@@ -271,9 +227,6 @@ inline val Message.content: String
...
@@ -271,9 +227,6 @@ inline val Message.content: String
* - [MessageChain] 所有元素都满足 [isContentEmpty]
* - [MessageChain] 所有元素都满足 [isContentEmpty]
*/
*/
fun
Message
.
isContentEmpty
():
Boolean
{
fun
Message
.
isContentEmpty
():
Boolean
{
contract
{
returns
(
false
)
implies
(
this
@
isContentEmpty
is
MessageContent
)
}
return
when
(
this
)
{
return
when
(
this
)
{
is
MessageMetadata
->
true
is
MessageMetadata
->
true
is
PlainText
->
this
.
content
.
isEmpty
()
is
PlainText
->
this
.
content
.
isEmpty
()
...
@@ -282,12 +235,7 @@ fun Message.isContentEmpty(): Boolean {
...
@@ -282,12 +235,7 @@ fun Message.isContentEmpty(): Boolean {
}
}
}
}
inline
fun
Message
.
isContentNotEmpty
():
Boolean
{
inline
fun
Message
.
isContentNotEmpty
():
Boolean
=
!
this
.
isContentEmpty
()
contract
{
returns
(
true
)
implies
(
this
@
isContentNotEmpty
is
MessageContent
)
}
return
!
this
.
isContentEmpty
()
}
inline
fun
Message
.
isPlain
():
Boolean
{
inline
fun
Message
.
isPlain
():
Boolean
{
contract
{
contract
{
...
@@ -364,7 +312,6 @@ interface MessageMetadata : SingleMessage {
...
@@ -364,7 +312,6 @@ interface MessageMetadata : SingleMessage {
/**
/**
* 返回空字符串
* 返回空字符串
*/
*/
@Suppress
(
"WRONG_MODIFIER_CONTAINING_DECLARATION"
)
final
override
fun
contentToString
():
String
=
""
final
override
fun
contentToString
():
String
=
""
}
}
...
...
mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt
View file @
d8ef80ea
...
@@ -26,12 +26,12 @@ internal class SubscribingGetTest {
...
@@ -26,12 +26,12 @@ internal class SubscribingGetTest {
runBlockingWithTimeout
(
10000
)
{
runBlockingWithTimeout
(
10000
)
{
suspendCancellableCoroutine
<
Unit
>
{
cont
->
suspendCancellableCoroutine
<
Unit
>
{
cont
->
launch
{
launch
{
syncFromEvent
(
3
000
)
{
_
:
TestEvent
->
syncFromEvent
(
8
000
)
{
_
:
TestEvent
->
cont
.
resume
(
Unit
)
cont
.
resume
(
Unit
)
}
}
}
}
launch
{
launch
{
delay
(
2
000
)
delay
(
4
000
)
TestEvent
().
broadcast
()
TestEvent
().
broadcast
()
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment