void (@NotNull PsiReference reference, @NotNull List<? super UsageInfo> usages, @NotNull PsiNamedElement parameter, int paramIdx, boolean isVararg) { final PsiElement element = reference.getElement(); PsiCall call = null; if (element instanceof PsiCall) { call = (PsiCall)element; } else { final PsiElement parent = element.getParent(); if (parent instanceof PsiCall) { call = (PsiCall)parent; } else if (parent instanceof PsiAnonymousClass) { call = (PsiNewExpression)parent.getParent(); } } if (call != null) { final PsiExpressionList argList = call.getArgumentList(); if (argList != null) { final PsiExpression[] args = argList.getExpressions(); if (paramIdx < args.length) { if (!isVararg) { usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[paramIdx], parameter)); } else { for (int i = paramIdx; i < args.length; i++) { usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[i], parameter)); } } } } } else if (element instanceof PsiDocMethodOrFieldRef) { String[] signature = ((PsiDocMethodOrFieldRef)element).getSignature(); PsiElement nameElement = ((PsiDocMethodOrFieldRef)element).getNameElement(); if (signature != null && nameElement != null) { @NonNls final StringBuffer newText = new StringBuffer(); newText.append("/** @see #").append(nameElement.getText()).append('('); boolean hasParams = false; for (int i = 0; i < signature.length; i++) { if (i == paramIdx) continue; if (hasParams) { newText.append(","); } else { hasParams = true; } newText.append(signature[i]); } newText.append(")*/"); usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(element, parameter, true) { @Override public void deleteElement() throws IncorrectOperationException { final PsiDocMethodOrFieldRef.MyReference javadocMethodReference = (PsiDocMethodOrFieldRef.MyReference)element.getReference(); if (javadocMethodReference != null) { javadocMethodReference.bindToText(newText); } } }); } } else if (element instanceof PsiMethodReferenceExpression) { usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(element, parameter, true) { @Override public void deleteElement() throws IncorrectOperationException { final PsiExpression callExpression = LambdaRefactoringUtil.convertToMethodCallInLambdaBody((PsiMethodReferenceExpression)element); if (callExpression instanceof PsiCallExpression) { final PsiExpressionList expressionList = ((PsiCallExpression)callExpression).getArgumentList(); if (expressionList != null) { final PsiExpression[] args = expressionList.getExpressions(); if (paramIdx < args.length) { args[paramIdx].delete(); } } } } }); } }