unused declaration inspection: improve CommentOut quick fix if parent element is not suspicious IDEA-157566

This commit is contained in:
Dmitry Batkovich
2016-07-06 18:25:39 +03:00
parent 459edd9fb0
commit c400fa39ce
@@ -249,13 +249,14 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
protected boolean applyFix(@NotNull RefEntity[] refElements) {
if (!super.applyFix(refElements)) return false;
List<RefElement> deletedRefs = new ArrayList<RefElement>(1);
final RefFilter filter = getFilter();
for (RefEntity refElement : refElements) {
PsiElement psiElement = refElement instanceof RefElement ? ((RefElement)refElement).getElement() : null;
if (psiElement == null) continue;
if (getFilter().getElementProblemCount((RefJavaElement)refElement) == 0) continue;
if (filter.getElementProblemCount((RefJavaElement)refElement) == 0) continue;
final RefEntity owner = refElement.getOwner();
if (!(owner instanceof RefElement && ArrayUtil.find(refElements, owner) > -1)) {
if (!(owner instanceof RefJavaElement) || filter.getElementProblemCount((RefJavaElement)owner) == 0 || !(ArrayUtil.find(refElements, owner) > -1)) {
commentOutDead(psiElement);
}