Last active
May 2, 2022 17:12
-
-
Save rubenquadros/65db713b66574e4d1251d5dc79ccab03 to your computer and use it in GitHub Desktop.
SerializedName inspector for data classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SerializedNameInspector : AbstractKotlinInspection() { | |
override fun buildVisitor( | |
holder: ProblemsHolder, | |
isOnTheFly: Boolean | |
): KtVisitorVoid { | |
return classVisitor { ktClass -> | |
if (ktClass.isData()) { | |
// check if serialized name annotation is required. | |
val param = ktClass.isSerializedNameAnnotationMissing() | |
param?.let { | |
holder.registerProblem( | |
it as PsiElement, | |
"Missing SerializedName annotation" | |
) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment