Skip to content
Snippets Groups Projects
Unverified Commit bc305cfc authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

fix: ksp warnings

parent 28f7dbca
No related branches found
No related tags found
No related merge requests found
/*
* libquassel
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2024 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
......@@ -11,20 +11,20 @@ package de.justjanne.libquassel.generator.util.ksp
import com.google.devtools.ksp.symbol.KSType
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.DelicateKotlinPoetApi
import com.squareup.kotlinpoet.asClassName
import kotlin.reflect.KClass
internal inline fun <reified T : Enum<T>> KSType.toEnum(): T? {
return asClassName().toEnum(T::class.java)
return asClassName().toEnum(T::class)
}
internal inline fun <reified T : Enum<T>> ClassName.toEnum(): T? {
return toEnum(T::class.java)
return toEnum(T::class)
}
internal fun <T : Enum<T>> ClassName.toEnum(clazz: Class<T>): T? {
internal fun <T : Enum<T>> ClassName.toEnum(clazz: KClass<T>): T? {
val enumClassName = clazz.asClassName()
return clazz.enumConstants.find {
return clazz.java.enumConstants.find {
this.canonicalName == enumClassName.nestedClass(it.name).canonicalName
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment