diff --git a/ksp-processors/src/main/kotlin/KSPUtils.kt b/ksp-processors/src/main/kotlin/KSPUtils.kt deleted file mode 100644 index 0486d482a37..00000000000 --- a/ksp-processors/src/main/kotlin/KSPUtils.kt +++ /dev/null @@ -1,52 +0,0 @@ -package dev.kord.ksp - -import com.google.devtools.ksp.KspExperimental -import com.google.devtools.ksp.findActualType -import com.google.devtools.ksp.getAnnotationsByType -import com.google.devtools.ksp.isDefault -import com.google.devtools.ksp.processing.Resolver -import com.google.devtools.ksp.symbol.* -import kotlin.reflect.KProperty1 - -//internal inline fun Resolver.getSymbolsWithAnnotation(inDepth: Boolean = false) = -// getSymbolsWithAnnotation(A::class.qualifiedName!!, inDepth) -// -//internal fun Resolver.getNewClasses() = getNewFiles().flatMap { it.declarations.filterIsInstance() } -// -//internal inline fun KSAnnotation.isOfType() = isOfType(A::class.qualifiedName!!) -// -//internal fun KSAnnotation.isOfType(qualifiedName: String) = annotationType.resolve() -// .declaration.let { if (it is KSTypeAlias) it.findActualType() else it } -// .qualifiedName?.asString() == qualifiedName -// -//@OptIn(KspExperimental::class) -//internal inline fun KSAnnotated.getAnnotationsByType() = getAnnotationsByType(A::class) -// -//internal class AnnotationArguments private constructor( -// private val arguments: Map, -//) { -// private fun getArgument(parameter: KProperty1) = arguments.getValue(parameter.name) -// private val KProperty1.value get() = getArgument(this).value -// -// fun isDefault(parameter: KProperty1) = getArgument(parameter).isDefault() -// -// // can't return non-nullable values because of https://github.com/google/ksp/issues/885 -// operator fun get(parameter: KProperty1) = parameter.value as KSAnnotation? -// operator fun get(parameter: KProperty1>) = -// @Suppress("UNCHECKED_CAST") (parameter.value as List?) -// -// companion object { -// fun KSAnnotation.arguments() = -// AnnotationArguments(arguments.associateBy { it.name!!.asString() }) -// } -//} -// -//@Suppress("RecursivePropertyAccessor") -//internal val KSReferenceElement.isClassifierReference: Boolean -// get() = when (this) { -// is KSDynamicReference, is KSCallableReference -> false -// is KSClassifierReference -> true -// is KSDefNonNullReference -> enclosedType.isClassifierReference -// is KSParenthesizedReference -> element.isClassifierReference -// else -> error("Unexpected KSReferenceElement: $this") -// } diff --git a/ksp-processors/src/main/kotlin/KotlinPoetDsl.kt b/ksp-processors/src/main/kotlin/KotlinPoetDsl.kt deleted file mode 100644 index 9d73919edc4..00000000000 --- a/ksp-processors/src/main/kotlin/KotlinPoetDsl.kt +++ /dev/null @@ -1,122 +0,0 @@ -package dev.kord.ksp -// -//import com.squareup.kotlinpoet.* -//import com.squareup.kotlinpoet.MemberName.Companion.member -//import kotlin.annotation.AnnotationRetention.SOURCE -//import kotlin.annotation.AnnotationTarget.TYPE -// -//// for scope control, see https://kotlinlang.org/docs/type-safe-builders.html#scope-control-dslmarker -//@DslMarker -//@Retention(SOURCE) -//@Target(TYPE) -//internal annotation class KotlinPoetDsl -// -//internal typealias FileSpecBuilder = (@KotlinPoetDsl FileSpec.Builder).() -> Unit -//internal typealias TypeSpecBuilder = (@KotlinPoetDsl TypeSpec.Builder).() -> Unit -//internal typealias AnnotationSpecBuilder = (@KotlinPoetDsl AnnotationSpec.Builder).() -> Unit -//internal typealias FunSpecBuilder = (@KotlinPoetDsl FunSpec.Builder).() -> Unit -//internal typealias PropertySpecBuilder = (@KotlinPoetDsl PropertySpec.Builder).() -> Unit -//internal typealias ParameterSpecBuilder = (@KotlinPoetDsl ParameterSpec.Builder).() -> Unit -//internal typealias CodeBlockBuilder = (@KotlinPoetDsl CodeBlock.Builder).() -> Unit -// -// -//// miscellaneous -// -//internal inline fun > E.asMemberName() = E::class.member(name) -// -//internal inline fun FileSpec(packageName: String, fileName: String, builder: FileSpecBuilder) = -// FileSpec.builder(packageName, fileName).apply(builder).build() -// -// -//// extensions for `Annotatable.Builder` -// -//@DelicateKotlinPoetApi("See 'AnnotationSpec.get'") -//internal fun > T.addAnnotation( -// annotation: Annotation, -// includeDefaultValues: Boolean = false, -//) = addAnnotation(AnnotationSpec.get(annotation, includeDefaultValues)) -// -//internal inline fun > T.addAnnotation(type: ClassName, builder: AnnotationSpecBuilder) = -// addAnnotation(AnnotationSpec.builder(type).apply(builder).build()) -// -//internal inline fun Annotatable.Builder<*>.addAnnotation(builder: AnnotationSpecBuilder) = -// addAnnotation(AnnotationSpec.builder(A::class).apply(builder).build()) -// -// -//// extensions for `TypeSpecHolder.Builder` -// -//internal inline fun > T.addClass(name: String, builder: TypeSpecBuilder) = -// addType(TypeSpec.classBuilder(name).apply(builder).build()) -// -//internal inline fun > T.addClass(className: ClassName, builder: TypeSpecBuilder) = -// addType(TypeSpec.classBuilder(className).apply(builder).build()) -// -//internal inline fun > T.addObject(name: String, builder: TypeSpecBuilder) = -// addType(TypeSpec.objectBuilder(name).apply(builder).build()) -// -// -//// extensions for `MemberSpecHolder.Builder` -// -//internal inline fun > T.addFunction(name: String, builder: FunSpecBuilder) = -// addFunction(FunSpec.builder(name).apply(builder).build()) -// -//internal inline fun MemberSpecHolder.Builder<*>.addProperty( -// name: String, -// vararg modifiers: KModifier, -// builder: PropertySpecBuilder, -//) = addProperty(PropertySpec.builder(name, typeNameOf(), *modifiers).apply(builder).build()) -// -//internal inline fun > T.addProperty( -// name: String, -// type: TypeName, -// vararg modifiers: KModifier, -// builder: PropertySpecBuilder, -//) = addProperty(PropertySpec.builder(name, type, *modifiers).apply(builder).build()) -// -// -//// extensions for `TypeSpec.Builder` -// -//internal inline fun TypeSpec.Builder.addCompanionObject(name: String? = null, builder: TypeSpecBuilder) = -// addType(TypeSpec.companionObjectBuilder(name).apply(builder).build()) -// -//internal inline fun TypeSpec.Builder.primaryConstructor(builder: FunSpecBuilder) = -// primaryConstructor(FunSpec.constructorBuilder().apply(builder).build()) -// -//internal inline fun TypeSpec.Builder.addInitializerBlock(builder: CodeBlockBuilder) = -// addInitializerBlock(CodeBlock.builder().apply(builder).build()) -// -// -//// extensions for `FunSpec.Builder` -// -//internal inline fun FunSpec.Builder.addParameter( -// name: String, -// type: TypeName, -// vararg modifiers: KModifier, -// builder: ParameterSpecBuilder, -//) = addParameter(ParameterSpec.builder(name, type, *modifiers).apply(builder).build()) -// -//internal inline fun FunSpec.Builder.addParameter(name: String, vararg modifiers: KModifier) = -// addParameter(name, typeNameOf(), *modifiers) -// -//internal inline fun FunSpec.Builder.returns() = returns(typeNameOf()) -// -//internal inline fun FunSpec.Builder.withControlFlow(controlFlow: String, vararg args: Any, builder: FunSpecBuilder) = -// beginControlFlow(controlFlow, *args).apply(builder).endControlFlow() -// -// -//// extensions for `PropertySpec.Builder` -// -//internal inline fun PropertySpec.Builder.delegate(builder: CodeBlockBuilder) = -// delegate(CodeBlock.builder().apply(builder).build()) -// -//internal inline fun PropertySpec.Builder.getter(builder: FunSpecBuilder) = -// getter(FunSpec.getterBuilder().apply(builder).build()) -// -// -//// extensions for `CodeBlock.Builder` -// -//internal inline fun CodeBlock.Builder.withControlFlow( -// controlFlow: String, -// vararg args: Any?, -// builder: CodeBlockBuilder, -//) = beginControlFlow(controlFlow, *args).apply(builder).endControlFlow()