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
Branches main
No related tags found
No related merge requests found
/* /*
* libquassel * 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, * 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 * 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 ...@@ -11,20 +11,20 @@ package de.justjanne.libquassel.generator.util.ksp
import com.google.devtools.ksp.symbol.KSType import com.google.devtools.ksp.symbol.KSType
import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.DelicateKotlinPoetApi
import com.squareup.kotlinpoet.asClassName import com.squareup.kotlinpoet.asClassName
import kotlin.reflect.KClass
internal inline fun <reified T : Enum<T>> KSType.toEnum(): T? { 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? { 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() val enumClassName = clazz.asClassName()
return clazz.enumConstants.find { return clazz.java.enumConstants.find {
this.canonicalName == enumClassName.nestedClass(it.name).canonicalName 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