aboutsummaryrefslogtreecommitdiff
path: root/common-util/src/main/kotlin/com/google/devtools/ksp/KSPUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'common-util/src/main/kotlin/com/google/devtools/ksp/KSPUtils.kt')
-rw-r--r--common-util/src/main/kotlin/com/google/devtools/ksp/KSPUtils.kt23
1 files changed, 23 insertions, 0 deletions
diff --git a/common-util/src/main/kotlin/com/google/devtools/ksp/KSPUtils.kt b/common-util/src/main/kotlin/com/google/devtools/ksp/KSPUtils.kt
new file mode 100644
index 00000000..31707e58
--- /dev/null
+++ b/common-util/src/main/kotlin/com/google/devtools/ksp/KSPUtils.kt
@@ -0,0 +1,23 @@
+package com.google.devtools.ksp
+
+import com.google.devtools.ksp.processing.impl.KSNameImpl
+import org.jetbrains.kotlin.name.ClassId
+
+class IdKey<T>(private val k: T) {
+ override fun equals(other: Any?): Boolean = if (other is IdKey<*>) k === other.k else false
+ override fun hashCode(): Int = k.hashCode()
+}
+
+class IdKeyPair<T, P>(private val k1: T, private val k2: P) {
+ override fun equals(other: Any?): Boolean = if (other is IdKeyPair<*, *>) k1 === other.k1 &&
+ k2 === other.k2 else false
+ override fun hashCode(): Int = k1.hashCode() * 31 + k2.hashCode()
+}
+
+class IdKeyTriple<T, P, Q>(private val k1: T, private val k2: P, private val k3: Q) {
+ override fun equals(other: Any?): Boolean = if (other is IdKeyTriple<*, *, *>) k1 === other.k1 &&
+ k2 === other.k2 && k3 === other.k3 else false
+ override fun hashCode(): Int = k1.hashCode() * 31 * 31 + k2.hashCode() * 31 + k3.hashCode()
+}
+
+fun ClassId.toKSName() = KSNameImpl.getCached(asSingleFqName().toString())