void ( @NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); final PsiReferenceExpression methodExpression = expression.getMethodExpression(); @NonNls final String methodName = methodExpression.getReferenceName(); final boolean isElements; if ("elements".equals(methodName)) { isElements = true; } else if ("keys".equals(methodName)) { isElements = false; } else { return; } if (!TypeUtils.expressionHasTypeOrSubtype(expression, "java.util.Enumeration")) { return; } final PsiElement parent = expression.getParent(); final PsiVariable variable; if (parent instanceof PsiLocalVariable) { variable = (PsiVariable)parent; } else if (parent instanceof PsiAssignmentExpression assignmentExpression) { final PsiExpression lhs = assignmentExpression.getLExpression(); if (!(lhs instanceof PsiReferenceExpression referenceExpression)) { return; } final PsiElement element = referenceExpression.resolve(); if (!(element instanceof PsiVariable)) { return; } variable = (PsiVariable)element; } else { return; } final PsiMethod containingMethod = PsiTreeUtil.getParentOfType( expression, PsiMethod.class); if (containingMethod == null) { return; } if (!isEnumerationMethodCalled(variable, containingMethod)) { return; } final PsiMethod method = expression.resolveMethod(); if (method == null) { return; } final PsiClass containingClass = method.getContainingClass(); if (isElements) { if (InheritanceUtil.isInheritor(containingClass, "java.util.Vector")) { registerMethodCallError(expression, ITERATOR_TEXT); } else if (InheritanceUtil.isInheritor(containingClass, "java.util.Hashtable")) { registerMethodCallError(expression, VALUES_ITERATOR_TEXT); } } else { if (InheritanceUtil.isInheritor(containingClass, "java.util.Hashtable")) { registerMethodCallError(expression, KEY_SET_ITERATOR_TEXT); } } }