diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java index 21b860a63fac..f51fa8b95e02 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java @@ -77,17 +77,17 @@ public abstract class InspectionRVContentProvider { final TreePath[] treePaths = tree.getSelectionPaths(); if (treePaths == null) return false; for (TreePath selectionPath : treePaths) { - if (!TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() { - @Override - public boolean accept(final Object node) { - if (!((InspectionTreeNode)node).isValid()) return true; - if (node instanceof ProblemDescriptionNode) { - final CommonProblemDescriptor descriptor = ((ProblemDescriptionNode)node).getDescriptor(); + if (!TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), node -> { + if (!((InspectionTreeNode) node).isValid()) return true; + if (node instanceof ProblemDescriptionNode) { + ProblemDescriptionNode problemDescriptionNode = (ProblemDescriptionNode)node; + if (!problemDescriptionNode.isQuickFixAppliedFromView()) { + final CommonProblemDescriptor descriptor = problemDescriptionNode.getDescriptor(); final QuickFix[] fixes = descriptor != null ? descriptor.getFixes() : null; return fixes == null || fixes.length == 0; } - return true; } + return true; })) { return true; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java index c074f366a8c4..c39ef74da145 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java @@ -69,27 +69,25 @@ public class OfflineInspectionRVContentProvider extends InspectionRVContentProvi final List selectedElements = new ArrayList(); final Map actions = new HashMap<>(); for (TreePath selectionPath : treePaths) { - TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() { - @Override - public boolean accept(final Object node) { - if (!((InspectionTreeNode)node).isValid()) return true; - if (node instanceof OfflineProblemDescriptorNode) { - final OfflineProblemDescriptorNode descriptorNode = (OfflineProblemDescriptorNode)node; - final RefEntity element = descriptorNode.getElement(); - selectedElements.add(element); - CommonProblemDescriptor[] descriptors = actions.get(element); - final CommonProblemDescriptor descriptor = descriptorNode.getDescriptor(); - final CommonProblemDescriptor[] descriptorAsArray = descriptor == null ? CommonProblemDescriptor.EMPTY_ARRAY - : new CommonProblemDescriptor[]{descriptor}; - actions.put(element, descriptors == null ? - descriptorAsArray : - DefaultInspectionToolPresentation.mergeDescriptors(descriptors, descriptorAsArray)); - } - else if (node instanceof RefElementNode) { - selectedElements.add(((RefElementNode)node).getElement()); - } - return true; + TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), node -> { + if (!((InspectionTreeNode)node).isValid()) return true; + if (node instanceof OfflineProblemDescriptorNode) { + if (!((OfflineProblemDescriptorNode)node).isQuickFixAppliedFromView()) return true; + final OfflineProblemDescriptorNode descriptorNode = (OfflineProblemDescriptorNode)node; + final RefEntity element = descriptorNode.getElement(); + selectedElements.add(element); + CommonProblemDescriptor[] descriptors = actions.get(element); + final CommonProblemDescriptor descriptor = descriptorNode.getDescriptor(); + final CommonProblemDescriptor[] descriptorAsArray = descriptor == null ? CommonProblemDescriptor.EMPTY_ARRAY + : new CommonProblemDescriptor[]{descriptor}; + actions.put(element, descriptors == null ? + descriptorAsArray : + DefaultInspectionToolPresentation.mergeDescriptors(descriptors, descriptorAsArray)); } + else if (node instanceof RefElementNode) { + selectedElements.add(((RefElementNode)node).getElement()); + } + return true; }); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index f42c5a4056f5..85c24e4c52f2 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -241,8 +241,19 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } } else if (node instanceof ProblemDescriptionNode) { - if (!((ProblemDescriptionNode)node).isValid()) return null; - return navigate(((ProblemDescriptionNode)node).getDescriptor()); + boolean isValid; + if (((ProblemDescriptionNode)node).isValid()) { + if (((ProblemDescriptionNode)node).isQuickFixAppliedFromView()) { + isValid = ((ProblemDescriptionNode)node).calculateIsValid(); + } else { + isValid = true; + } + } else { + isValid = false; + } + return isValid + ? navigate(((ProblemDescriptionNode)node).getDescriptor()) + : InspectionResultsViewUtil.getNavigatableForInvalidNode((ProblemDescriptionNode)node); } return null; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java index 7ac852d50401..f8bd048de864 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java @@ -43,6 +43,9 @@ public class InspectionResultsViewUtil { @Nullable static Navigatable getNavigatableForInvalidNode(ProblemDescriptionNode node) { RefEntity element = node.getElement(); + while (element != null && !element.isValid()) { + element = element.getOwner(); + } if (!(element instanceof RefElement)) return null; PsiElement containingElement = ((RefElement)element).getElement(); if (!(containingElement instanceof NavigatablePsiElement) || !containingElement.isValid()) return null; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionViewPsiTreeChangeAdapter.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionViewPsiTreeChangeAdapter.java index e9f9dd781a6d..877b44ec9b0d 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionViewPsiTreeChangeAdapter.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionViewPsiTreeChangeAdapter.java @@ -70,12 +70,7 @@ class InspectionViewPsiTreeChangeAdapter extends PsiTreeChangeAdapter { Set files = new HashSet<>(); for (Update update : updates) { VirtualFile file = (VirtualFile)update.getEqualityObjects()[0]; - VfsUtilCore.iterateChildrenRecursively(file, VirtualFileFilter.ALL, new ContentIterator() { - @Override - public boolean processFile(VirtualFile fileOrDir) { - return files.add(fileOrDir); - } - }); + VfsUtilCore.iterateChildrenRecursively(file, VirtualFileFilter.ALL, files::add); } final Project project = view.getProject(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java index ff390ec20f3f..c3c1a90bc515 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java @@ -93,7 +93,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode { } @Override - public boolean calculateIsValid() { + protected boolean calculateIsValid() { if (myElement instanceof RefElement && !myElement.isValid()) return false; final CommonProblemDescriptor descriptor = getDescriptor(); if (descriptor instanceof ProblemDescriptor) { @@ -138,7 +138,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode { } @Override - public String calculatePresentableName() { + protected String calculatePresentableName() { CommonProblemDescriptor descriptor = getDescriptor(); if (descriptor == null) return ""; PsiElement element = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;