void (@NotNull PsiMethod method) { super.visitMethod(method); @NonNls final String methodName = method.getName(); if (!"toString".equals(methodName)) { return; } final PsiParameterList parameterList = method.getParameterList(); if (!parameterList.isEmpty()) { return; } final PsiType returnType = method.getReturnType(); final PsiClassType javaLangString = PsiType.getJavaLangString(method.getManager(), method.getResolveScope()); if (!javaLangString.equals(returnType)) { return; } final PsiClass aClass = method.getContainingClass(); if (aClass == null) { return; } final PsiField[] fields = GenerateToStringUtils.filterAvailableFields(aClass, GenerateToStringContext.getConfig().getFilterPattern()); final PsiMethod[] methods; if (GenerateToStringContext.getConfig().isEnableMethods()) { methods = GenerateToStringUtils.filterAvailableMethods(aClass, GenerateToStringContext.getConfig().getFilterPattern()); } else { methods = PsiMethod.EMPTY_ARRAY; } final FieldUsedVisitor visitor = new FieldUsedVisitor(fields, methods); method.accept(visitor); for (PsiField field : visitor.getUnusedFields()) { if (!field.isPhysical()) continue; final String fieldName = field.getName(); myHolder.registerProblem(field.getNameIdentifier(), JavaAnalysisBundle.message("inspection.field.not.used.in.to.string.description2", fieldName), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, createFixes()); } for (PsiMethod unusedMethod : visitor.getUnusedMethods()) { if (!unusedMethod.isPhysical()) continue; final PsiIdentifier identifier = unusedMethod.getNameIdentifier(); final PsiElement target = identifier == null ? unusedMethod : identifier; myHolder.registerProblem(target, JavaAnalysisBundle.message("inspection.field.not.used.in.to.string.description", unusedMethod.getName()), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, createFixes()); } }