Add LocalVariableName to common suppressions (#1040)

* Add LocalVariableName to common suppressions

NameAllocator will add underscores to names, which kotlin doesn't like for stylistic reasons

* Simplify structure a bit

Keeping track of template counts is error prone and would have failed only at runtime
This commit is contained in:
Zac Sweers
2019-12-05 22:37:26 +01:00
committed by GitHub
parent 791ff3211e
commit 14cb9e4bbb

View File

@@ -60,8 +60,7 @@ internal class AdapterGenerator(
private val DEFAULT_CONSTRUCTOR_MARKER_TYPE_BLOCK = CodeBlock.of(
"%T.DEFAULT_CONSTRUCTOR_MARKER", Util::class)
private val COMMON_SUPPRESS = AnnotationSpec.builder(Suppress::class)
.addMember("%S, %S, %S, %S",
private val COMMON_SUPPRESS = arrayOf(
// https://github.com/square/moshi/issues/1023
"DEPRECATION",
// Because we look it up reflectively
@@ -70,10 +69,19 @@ internal class AdapterGenerator(
"ClassName",
// Because we generate redundant `out` variance for some generics and there's no way
// for us to know when it's redundant.
"REDUNDANT_PROJECTION"
"REDUNDANT_PROJECTION",
// NameAllocator will just add underscores to differentiate names, which Kotlin doesn't
// like for stylistic reasons.
"LocalVariableName"
).let { suppressions ->
AnnotationSpec.builder(Suppress::class)
.addMember(
suppressions.indices.joinToString { "%S" },
*suppressions
)
.build()
}
}
private val nonTransientProperties = propertyList.filterNot { it.isTransient }
private val className = target.typeName.rawType()