in src/main/kotlin/com/netflix/dgs/plugin/hints/DgsDataSimplifyingInspector.kt [36:72]
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
return UastVisitorAdapter(object : AbstractUastNonRecursiveVisitor() {
@Suppress("UElementAsPsi")
override fun visitMethod(node: UMethod): Boolean {
val dgsService = node.project.getService(DgsService::class.java)
if (!dgsService.isDgsProject(node.project)) {
return false
}
if (node.hasAnnotation(DGS_DATA_ANNOTATION)) {
val dgsDataAnnotation = node.getAnnotation(DGS_DATA_ANNOTATION)
val parentTypeAttribute = dgsDataAnnotation?.findAttribute("parentType")
val parentTypeValue =
if (parentTypeAttribute != null && parentTypeAttribute.attributeValue != null) {
(parentTypeAttribute.attributeValue as JvmAnnotationConstantValue).constantValue
} else null
if (parentTypeValue == "Query" || parentTypeValue == "Mutation" || parentTypeValue == "Subscription") {
val message = MyBundle.getMessage(
"dgs.inspection.dgsdata.simplify",
parentTypeValue,
"@Dgs${parentTypeValue}"
)
holder.registerProblem(
dgsDataAnnotation.toUElement()?.sourcePsi!!,
message,
ProblemHighlightType.WEAK_WARNING,
DgsDataQuickFix("@Dgs${parentTypeValue}", message)
)
}
}
return super.visitMethod(node)
}
}, false)
}