PsiParameter (PsiElement call, final int parameterIndex, final PsiMethod nodeMethod) { if (call instanceof PsiCallExpression) { final PsiExpressionList argumentList = ((PsiCallExpression)call).getArgumentList(); if (argumentList != null) { final PsiExpression[] expressions = argumentList.getExpressions(); if (expressions.length > parameterIndex) { final PsiExpression expression = PsiUtil.deparenthesizeExpression(expressions[parameterIndex]); if (expression != null) { final Set<PsiParameter> paramRefs = new HashSet<>(); expression.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); final PsiElement resolve = expression.resolve(); if (resolve instanceof PsiParameter) { paramRefs.add((PsiParameter)resolve); } } }); final PsiParameter parameter = ContainerUtil.getFirstItem(paramRefs); if (parameter != null && !parameter.isVarArgs()) { final PsiElement scope = parameter.getDeclarationScope(); if (scope instanceof PsiMethod && ((PsiMethod)scope).findDeepestSuperMethods().length == 0 && OverridingMethodsSearch.search((PsiMethod)scope).findFirst() == null) { final int scopeParamIdx = ((PsiMethod)scope).getParameterList().getParameterIndex(parameter); final Ref<Boolean> ref = new Ref<>(false); if (ReferencesSearch.search(parameter, new LocalSearchScope(scope)).forEach(new Processor<>() { @Override public boolean process(PsiReference reference) { final PsiElement element = reference.getElement(); if (element instanceof PsiReferenceExpression) { PsiCallExpression parent = PsiTreeUtil.getParentOfType(element, PsiCallExpression.class); while (parent != null) { final PsiMethod resolved = parent.resolveMethod(); if (scope.equals(resolved)) { if (usedInQualifier(element, parent, scopeParamIdx)) return false; return true; } if (nodeMethod.equals(resolved)) { if (usedInQualifier(element, parent, parameterIndex)) return false; ref.set(true); return true; } parent = PsiTreeUtil.getParentOfType(parent, PsiCallExpression.class, true); } return false; } return true; } private static boolean usedInQualifier(PsiElement element, PsiCallExpression parent, int parameterIndex) { PsiExpression qualifier = null; if (parent instanceof PsiMethodCallExpression) { qualifier = ((PsiMethodCallExpression)parent).getMethodExpression(); } else if (parent instanceof PsiNewExpression) { qualifier = ((PsiNewExpression)parent).getQualifier(); } if (PsiTreeUtil.isAncestor(qualifier, element, true)) { return true; } final PsiExpressionList list = parent.getArgumentList(); return list != null && !PsiTreeUtil.isAncestor(list.getExpressions()[parameterIndex], element, false); } }) && ref.get()) { return parameter; } } } } } } } return null; }