BaseInspectionVisitor () { return new BaseInspectionVisitor() { @Override public void visitTypeDefinition(@NotNull GrTypeDefinition typeDefinition) { super.visitTypeDefinition(typeDefinition); List<PsiClass> superTraits = collectImplementedTraits(typeDefinition); if (superTraits.size() < 2) return; List<ClashingMethod> clashingMethods = collectClassingMethods(typeDefinition); for (ClashingMethod clashing : clashingMethods) { registerError(typeDefinition.getNameIdentifierGroovy(), buildWarning(clashing), new LocalQuickFix[]{getFix()}, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } @NotNull @InspectionMessage private String buildWarning(@NotNull ClashingMethod entry) { return GroovyBundle.message("inspection.message.traits.0.contain.clashing.methods.with.signature.1", buildTraitString(entry), buildSignatureString(entry)); } @NotNull @NlsSafe private static String buildSignatureString(@NotNull ClashingMethod entry) { HierarchicalMethodSignature signature = entry.getSignature(); return PsiFormatUtil.formatMethod(signature.getMethod(), signature.getSubstitutor(), PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE); } @NotNull @NlsSafe private static String buildTraitString(@NotNull ClashingMethod entry) { return StringUtil.join(entry.getSuperTraits(), tr -> tr.getName(), ", "); } }; }