Fix StringConstant.toString and add notes for AbstractCommandValueParameter implementers

This commit is contained in:
Him188 2020-11-17 09:48:45 +08:00
parent fd2a22a798
commit 21428094a8
3 changed files with 7 additions and 7 deletions

View File

@ -208,6 +208,8 @@ public sealed class AbstractCommandValueParameter<T> : CommandValueParameter<T>,
public override val isVararg: Boolean,
public override val type: KType,
) : AbstractCommandValueParameter<T>() {
override fun toString(): String = super.toString()
init {
requireNotNull(type.classifierAsKClassOrNull()) {
"type.classifier must be KClass."
@ -237,7 +239,5 @@ public sealed class AbstractCommandValueParameter<T> : CommandValueParameter<T>,
* Extended by [CommandValueArgumentParser]
*/
@ConsoleExperimentalApi
public abstract class Extended<T> : AbstractCommandValueParameter<T>() {
abstract override fun toString(): String
}
public abstract class Extended<T> : AbstractCommandValueParameter<T>() // For implementer: take care of toString()
}

View File

@ -58,9 +58,9 @@ public abstract class AbstractCommandSignature : CommandSignature {
override fun toString(): String {
val receiverParameter = receiverParameter
return if (receiverParameter == null) {
"CommandSignatureVariant(${valueParameters.joinToString()})"
"CommandSignature(${valueParameters.joinToString()})"
} else {
"CommandSignatureVariant($receiverParameter, ${valueParameters.joinToString()})"
"CommandSignature($receiverParameter, ${valueParameters.joinToString()})"
}
}
}

View File

@ -181,8 +181,8 @@ internal class TestCommand {
@Test
fun `composite command descriptors`() {
val overloads = TestCompositeCommand.overloads
assertEquals("CommandSignatureVariant(<mute>, seconds: Int = ...)", overloads[0].toString())
assertEquals("CommandSignatureVariant(<mute>, target: Long, seconds: Int)", overloads[1].toString())
assertEquals("CommandSignature(<mute>, seconds: Int = ...)", overloads[0].toString())
assertEquals("CommandSignature(<mute>, target: Long, seconds: Int)", overloads[1].toString())
}
@Test