xref: /aosp_15_r20/external/ksp/common-util/src/main/kotlin/com/google/devtools/ksp/KSPUtils.kt (revision af87fb4bb8e3042070d2a054e912924f599b22b7)
1 package com.google.devtools.ksp
2 
3 import com.google.devtools.ksp.processing.impl.KSNameImpl
4 import org.jetbrains.kotlin.name.ClassId
5 
6 class IdKey<T>(private val k: T) {
equalsnull7     override fun equals(other: Any?): Boolean = if (other is IdKey<*>) k === other.k else false
8     override fun hashCode(): Int = k.hashCode()
9 }
10 
11 class IdKeyPair<T, P>(private val k1: T, private val k2: P) {
12     override fun equals(other: Any?): Boolean = if (other is IdKeyPair<*, *>) k1 === other.k1 &&
13         k2 === other.k2 else false
14     override fun hashCode(): Int = k1.hashCode() * 31 + k2.hashCode()
15 }
16 
17 class IdKeyTriple<T, P, Q>(private val k1: T, private val k2: P, private val k3: Q) {
equalsnull18     override fun equals(other: Any?): Boolean = if (other is IdKeyTriple<*, *, *>) k1 === other.k1 &&
19         k2 === other.k2 && k3 === other.k3 else false
20     override fun hashCode(): Int = k1.hashCode() * 31 * 31 + k2.hashCode() * 31 + k3.hashCode()
21 }
22 
23 fun ClassId.toKSName() = KSNameImpl.getCached(asSingleFqName().toString())
24