From 165e5b5c5e55f75706ebb128659166ef477cb5c0 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Mon, 13 Mar 2017 11:56:30 +0300 Subject: [PATCH] inspection view: should not return OpenFileDescriptor when psiElement is requested (EA-97956) --- .../ui/InspectionResultsView.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 a1f2f6c55b66..85c2cdbcc187 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -967,25 +967,24 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren if (psiElement == null) return null; final CommonProblemDescriptor problem = refElementNode.getDescriptor(); - if (problem != null) { - if (problem instanceof ProblemDescriptor) { - PsiElement elementFromDescriptor = ((ProblemDescriptor)problem).getPsiElement(); - if (elementFromDescriptor == null) { - final InspectionTreeNode node = (InspectionTreeNode)refElementNode.getChildAt(0); - if (node.isValid()) { - return InspectionResultsViewUtil.getNavigatableForInvalidNode((ProblemDescriptionNode)node); - } - } else { - psiElement = elementFromDescriptor; + if (problem instanceof ProblemDescriptor) { + PsiElement elementFromDescriptor = ((ProblemDescriptor)problem).getPsiElement(); + if (elementFromDescriptor == null && CommonDataKeys.NAVIGATABLE.is(dataId)) { + final InspectionTreeNode node = (InspectionTreeNode)refElementNode.getChildAt(0); + if (node.isValid()) { + return InspectionResultsViewUtil.getNavigatableForInvalidNode((ProblemDescriptionNode)node); } } + else { + psiElement = elementFromDescriptor; + } } if (CommonDataKeys.NAVIGATABLE.is(dataId)) { return getSelectedNavigatable(problem, psiElement); } else if (CommonDataKeys.PSI_ELEMENT.is(dataId)) { - return psiElement.isValid() ? psiElement : null; + return psiElement != null && psiElement.isValid() ? psiElement : null; } } else if (selectedNode instanceof ProblemDescriptionNode && CommonDataKeys.NAVIGATABLE.is(dataId)) {