boolean (final PsiVariable[] parameters, PsiCallExpression callExpression, PsiMethod psiMethod) { final PsiExpressionList argumentList = callExpression.getArgumentList(); if (argumentList == null) { return false; } final int calledParametersCount = psiMethod.getParameterList().getParametersCount(); final PsiExpression[] expressions = argumentList.getExpressions(); final PsiExpression qualifier; if (callExpression instanceof PsiMethodCallExpression) { qualifier = ((PsiMethodCallExpression)callExpression).getMethodExpression().getQualifierExpression(); } else if (callExpression instanceof PsiNewExpression) { qualifier = ((PsiNewExpression)callExpression).getQualifier(); } else { qualifier = null; } if (expressions.length == 0 && parameters.length == 0) { return !(callExpression instanceof PsiNewExpression && qualifier != null); } final int offset = parameters.length > 0 && ExpressionUtils.isReferenceTo(qualifier, parameters[0]) ? 1 : 0; if (parameters.length != expressions.length + offset) return false; if (psiMethod.isVarArgs()) { if (expressions.length < calledParametersCount - 1) return false; } else { if (expressions.length != calledParametersCount) return false; } for (int i = 0; i < expressions.length; i++) { if (!ExpressionUtils.isReferenceTo(expressions[i], parameters[i + offset])) { return false; } } if (offset == 0 && qualifier != null) { return SyntaxTraverser.psiTraverser(qualifier) .filter(PsiReferenceExpression.class) .map(PsiReferenceExpression::resolve) .filter(target -> ArrayUtil.find(parameters, target) >= 0) .first() == null; } return true; }