void (@NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); final PsiReferenceExpression reference = expression.getMethodExpression(); final PsiExpression qualifier = PsiUtil.skipParenthesizedExprDown(reference.getQualifierExpression()); if (qualifier == null) { return; } if (!(qualifier instanceof PsiCallExpression)) { return; } if (m_ignoreFieldInitializations) { final PsiElement field = PsiTreeUtil.getParentOfType(expression, PsiField.class); if (field != null) { return; } } final PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(expression, PsiExpressionList.class); if (expressionList != null) { final PsiElement parent = expressionList.getParent(); if (JavaPsiConstructorUtil.isConstructorCall(parent)) { return; } } if (ignoreSelfTypes) { if (qualifier instanceof PsiMethodCallExpression methodCallExpression) { final PsiMethod qualifierMethod = methodCallExpression.resolveMethod(); if (qualifierMethod == null) { return; } PsiClass containingClass = qualifierMethod.getContainingClass(); PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(qualifierMethod.getReturnType()); if (containingClass == null || containingClass.equals(aClass)) { return; } } PsiClass callClass = PsiUtil.resolveClassInClassTypeOnly(expression.getType()); PsiClass qualifierClass = PsiUtil.resolveClassInClassTypeOnly(qualifier.getType()); if (qualifierClass == null || qualifierClass.equals(callClass)) { return; } } registerMethodCallError(expression); }