kotlin: Switch from ktfmt to ktlint (fixes build)
This commit is contained in:
parent
f0a4add565
commit
5648128217
6 changed files with 69 additions and 49 deletions
|
|
@ -1,10 +1,9 @@
|
|||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import java.net.URL
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.4.31"
|
||||
id("org.jetbrains.dokka") version "1.4.20"
|
||||
id("com.ncorti.ktfmt.gradle") version "0.6.0"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
|
|
@ -50,7 +49,3 @@ tasks {
|
|||
kotlin {
|
||||
explicitApi()
|
||||
}
|
||||
|
||||
ktfmt {
|
||||
dropboxStyle()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public constructor(
|
||||
name: String,
|
||||
description: Description = Description.empty(),
|
||||
|
|
@ -100,7 +101,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public constructor(
|
||||
name: String,
|
||||
description: Description = Description.empty(),
|
||||
|
|
@ -171,7 +173,7 @@ public class MutableCommandBuilder<C : Any> {
|
|||
return this
|
||||
}
|
||||
|
||||
private fun onlyMutate(mutator: (Command.Builder<C>) -> Command.Builder<C>): Unit {
|
||||
private fun onlyMutate(mutator: (Command.Builder<C>) -> Command.Builder<C>) {
|
||||
mutate(mutator)
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +209,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun copy(
|
||||
literal: String,
|
||||
description: Description,
|
||||
|
|
@ -306,7 +309,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun registerCopy(
|
||||
literal: String,
|
||||
description: Description,
|
||||
|
|
@ -341,8 +345,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
*/
|
||||
public fun <T : Any> meta(key: CommandMeta.Key<T>, value: T): MutableCommandBuilder<C> =
|
||||
mutate {
|
||||
it.meta(key, value)
|
||||
}
|
||||
it.meta(key, value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value for a certain [CommandMeta.Key] in the command meta storage for this builder
|
||||
|
|
@ -481,7 +485,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun argument(
|
||||
argument: CommandArgument<C, *>,
|
||||
description: Description = Description.empty()
|
||||
|
|
@ -511,7 +516,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun argument(
|
||||
argument: CommandArgument.Builder<C, *>,
|
||||
description: Description = Description.empty()
|
||||
|
|
@ -541,7 +547,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun argument(
|
||||
description: Description = Description.empty(),
|
||||
argumentSupplier: () -> CommandArgument<C, *>
|
||||
|
|
@ -572,7 +579,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun literal(
|
||||
name: String,
|
||||
description: Description = Description.empty(),
|
||||
|
|
@ -627,7 +635,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
.withAliases(*aliases)
|
||||
.withDescription(description)
|
||||
.withArgument(argumentSupplier())
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -652,7 +661,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
.withAliases(*aliases)
|
||||
.withDescription(description)
|
||||
.withArgument(argument)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -677,7 +687,8 @@ public class MutableCommandBuilder<C : Any> {
|
|||
.withAliases(*aliases)
|
||||
.withDescription(description)
|
||||
.withArgument(argumentBuilder)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -699,6 +710,7 @@ public class MutableCommandBuilder<C : Any> {
|
|||
.flagBuilder(name)
|
||||
.withAliases(*aliases)
|
||||
.withDescription(description)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ import cloud.commandframework.annotations.AnnotationParser
|
|||
import cloud.commandframework.annotations.MethodCommandExecutionHandler
|
||||
import cloud.commandframework.context.CommandContext
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.future.asCompletableFuture
|
||||
import java.lang.reflect.Method
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.function.Predicate
|
||||
|
|
@ -34,8 +38,6 @@ import kotlin.coroutines.CoroutineContext
|
|||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.reflect.full.callSuspend
|
||||
import kotlin.reflect.jvm.kotlinFunction
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.future.asCompletableFuture
|
||||
|
||||
/**
|
||||
* Adds coroutine support to the [AnnotationParser].
|
||||
|
|
@ -48,8 +50,9 @@ public fun <C> AnnotationParser<C>.installCoroutineSupport(
|
|||
) {
|
||||
if (manager().commandExecutionCoordinator() is CommandExecutionCoordinator.SimpleCoordinator) {
|
||||
RuntimeException(
|
||||
"""You are highly advised to not use the simple command execution coordinator together
|
||||
with coroutine support. Consider using the asynchronous command execution coordinator instead.""")
|
||||
"""You are highly advised to not use the simple command execution coordinator together
|
||||
with coroutine support. Consider using the asynchronous command execution coordinator instead."""
|
||||
)
|
||||
.printStackTrace()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ import kotlin.reflect.KClass
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun <C : Any> CommandManager<C>.commandBuilder(
|
||||
name: String,
|
||||
description: Description = Description.empty(),
|
||||
|
|
@ -79,7 +80,8 @@ public fun <C : Any> CommandManager<C>.commandBuilder(
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "ArgumentDescription should be used over Description",
|
||||
level = DeprecationLevel.HIDDEN)
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public fun <C : Any> CommandManager<C>.buildAndRegister(
|
||||
name: String,
|
||||
description: Description = Description.empty(),
|
||||
|
|
@ -137,7 +139,8 @@ public fun <C : Any> Command.Builder<C>.senderType(type: KClass<out C>): Command
|
|||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "Use interface variant that allows for rich text",
|
||||
replaceWith = ReplaceWith("argumentDescription(description)"))
|
||||
replaceWith = ReplaceWith("argumentDescription(description)")
|
||||
)
|
||||
public fun description(description: String = ""): Description =
|
||||
if (description.isEmpty()) Description.empty() else Description.of(description)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ import cloud.commandframework.CommandManager
|
|||
import cloud.commandframework.arguments.standard.StringArgument
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator
|
||||
import cloud.commandframework.internal.CommandRegistrationHandler
|
||||
import cloud.commandframework.kotlin.extension.*
|
||||
import cloud.commandframework.kotlin.extension.argumentDescription
|
||||
import cloud.commandframework.kotlin.extension.buildAndRegister
|
||||
import cloud.commandframework.kotlin.extension.command
|
||||
import cloud.commandframework.kotlin.extension.commandBuilder
|
||||
import cloud.commandframework.meta.CommandMeta
|
||||
import cloud.commandframework.meta.SimpleCommandMeta
|
||||
import org.junit.jupiter.api.Assertions
|
||||
|
|
@ -58,8 +61,10 @@ class CommandBuildingDSLTest {
|
|||
handler {
|
||||
// ...
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
manager.buildAndRegister("is") {
|
||||
commandDescription("Command description")
|
||||
|
|
@ -85,20 +90,21 @@ class CommandBuildingDSLTest {
|
|||
Assertions.assertEquals(
|
||||
manager.commandHelpHandler.allCommands.map { it.syntaxString }.sorted(),
|
||||
setOf(
|
||||
"kotlin dsl <moment>",
|
||||
"kotlin dsl <moment> bruh_moment",
|
||||
"is",
|
||||
"is this",
|
||||
"is this going",
|
||||
"is this going too_far",
|
||||
)
|
||||
.sorted())
|
||||
"kotlin dsl <moment>",
|
||||
"kotlin dsl <moment> bruh_moment",
|
||||
"is",
|
||||
"is this",
|
||||
"is this going",
|
||||
"is this going too_far",
|
||||
)
|
||||
.sorted()
|
||||
)
|
||||
}
|
||||
|
||||
class TestCommandManager :
|
||||
CommandManager<TestCommandSender>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
CommandRegistrationHandler.nullCommandRegistrationHandler()) {
|
||||
class TestCommandManager : CommandManager<TestCommandSender>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
CommandRegistrationHandler.nullCommandRegistrationHandler()
|
||||
) {
|
||||
override fun createDefaultCommandMeta(): SimpleCommandMeta {
|
||||
return SimpleCommandMeta.empty()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator
|
|||
import cloud.commandframework.internal.CommandRegistrationHandler
|
||||
import cloud.commandframework.meta.CommandMeta
|
||||
import cloud.commandframework.meta.SimpleCommandMeta
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.future.await
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class KotlinAnnotatedMethodsTest {
|
||||
|
||||
|
|
@ -60,22 +60,23 @@ class KotlinAnnotatedMethodsTest {
|
|||
@Test
|
||||
fun `test suspending command methods`(): Unit = runBlocking {
|
||||
AnnotationParser(commandManager, TestCommandSender::class.java) {
|
||||
SimpleCommandMeta.empty()
|
||||
}
|
||||
SimpleCommandMeta.empty()
|
||||
}
|
||||
.also { it.installCoroutineSupport() }
|
||||
.parse(CommandMethods())
|
||||
|
||||
commandManager.executeCommand(TestCommandSender(), "test").await()
|
||||
}
|
||||
|
||||
private class TestCommandSender {}
|
||||
private class TestCommandSender
|
||||
|
||||
private class TestCommandManager :
|
||||
CommandManager<TestCommandSender>(
|
||||
AsynchronousCommandExecutionCoordinator.newBuilder<TestCommandSender>()
|
||||
.withExecutor(executorService)
|
||||
.build(),
|
||||
CommandRegistrationHandler.nullCommandRegistrationHandler()) {
|
||||
CommandRegistrationHandler.nullCommandRegistrationHandler()
|
||||
) {
|
||||
|
||||
override fun hasPermission(sender: TestCommandSender, permission: String): Boolean = true
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue