[Lombok] Properly support Guava collections with @Singular

^KT-53683 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-09-09 12:14:12 +03:00
committed by teamcity
parent 69a857649f
commit 2aadaee69f
12 changed files with 253 additions and 90 deletions
@@ -22,6 +22,7 @@ object LombokNames {
val BUILDER = FqName("lombok.Builder")
val SINGULAR = FqName("lombok.Singular")
val TABLE = FqName("com.google.common.collect.Table")
val ACCESSORS_ID = ClassId.topLevel(ACCESSORS)
val GETTER_ID = ClassId.topLevel(GETTER)
@@ -35,6 +36,8 @@ object LombokNames {
val ALL_ARGS_CONSTRUCTOR_ID = ClassId.topLevel(ALL_ARGS_CONSTRUCTOR)
val REQUIRED_ARGS_CONSTRUCTOR_ID = ClassId.topLevel(REQUIRED_ARGS_CONSTRUCTOR)
val TABLE_CLASS_ID = ClassId.topLevel(TABLE)
//taken from idea lombok plugin
val NON_NULL_ANNOTATIONS = listOf(
"androidx.annotation.NonNull",
@@ -83,36 +86,23 @@ object LombokNames {
"kotlin.collections.MutableMap",
)
private val SUPPORTED_COLLECTIONS = SUPPORTED_JAVA_COLLECTIONS + SUPPORTED_KOTLIN_COLLECTIONS
private val SUPPORTED_MAPS = SUPPORTED_JAVA_MAPS + SUPPORTED_KOTLIN_MAPS
private val SUPPORTED_COLLECTIONS_WITH_GUAVA = SUPPORTED_COLLECTIONS + setOf(
val SUPPORTED_GUAVA_COLLECTIONS = setOf(
"com.google.common.collect.ImmutableCollection",
"com.google.common.collect.ImmutableList",
"com.google.common.collect.ImmutableSet",
"com.google.common.collect.ImmutableSortedSet",
)
private val SUPPORTED_MAPS_WITH_GUAVA = SUPPORTED_MAPS + setOf(
private val SUPPORTED_GUAVA_MAPS = setOf(
"com.google.common.collect.ImmutableMap",
"com.google.common.collect.ImmutableBiMap",
"com.google.common.collect.ImmutableSortedMap",
)
val SUPPORTED_COLLECTIONS = SUPPORTED_JAVA_COLLECTIONS + SUPPORTED_KOTLIN_COLLECTIONS + SUPPORTED_GUAVA_COLLECTIONS
val SUPPORTED_MAPS = SUPPORTED_JAVA_MAPS + SUPPORTED_KOTLIN_MAPS + SUPPORTED_GUAVA_MAPS
val SUPPORTED_TABLES = setOf(
"com.google.common.collect.ImmutableTable",
)
fun getSupportedCollectionsForSingular(includeGuava: Boolean): Set<String> {
return if (includeGuava) {
SUPPORTED_COLLECTIONS_WITH_GUAVA
} else {
SUPPORTED_COLLECTIONS
}
}
fun getSupportedMapsForSingular(includeGuava: Boolean): Set<String> {
return if (includeGuava) {
SUPPORTED_MAPS_WITH_GUAVA
} else {
SUPPORTED_MAPS
}
}
}