From c3105c7335bd877b0b117be626660abd09ff58f4 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Mon, 27 Nov 2017 19:58:06 +0300 Subject: [PATCH] inspection view: do not insert problem node twice --- .../ex/InspectionRVContentProviderImpl.java | 17 ++--------------- .../ui/InspectionResultsView.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java index 8c565e3a18f9..548862cf10ec 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.codeInspection.ex; @@ -126,8 +114,7 @@ public class InspectionRVContentProviderImpl extends InspectionRVContentProvider final RefElementNode elemNode = addNodeToParent(container, presentation, pNode); for (CommonProblemDescriptor problem : problems) { assert problem != null; - elemNode - .insertByOrder(ReadAction.compute(() -> new ProblemDescriptionNode(refElement, problem, presentation)), true); + elemNode.insertByOrder(ReadAction.compute(() -> new ProblemDescriptionNode(refElement, problem, presentation)), false); elemNode.setProblem(elemNode.getChildCount() == 1 ? problems[0] : null); } } 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 2ec3c269f7c5..3065597bc2b1 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -42,7 +42,10 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.pom.Navigatable; import com.intellij.profile.ProfileChangeAdapter; import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; -import com.intellij.psi.*; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiDocumentManager; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.*; import com.intellij.util.EditSourceOnDoubleClickHandler; @@ -53,6 +56,7 @@ import com.intellij.util.containers.HashSet; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; +import com.intellij.vfs.AsyncVfsEventsPostProcessor; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -212,7 +216,7 @@ public class InspectionResultsView extends JPanel implements Disposable, DataPro } }; createActionsToolbar(); - PsiManager.getInstance(getProject()).addPsiTreeChangeListener(new InspectionViewPsiTreeChangeAdapter(this), this); + AsyncVfsEventsPostProcessor.getInstance().addListener(new InspectionViewPsiTreeChangeAdapter(this), this); ProjectInspectionProfileManager profileManager = ProjectInspectionProfileManager.getInstance(getProject()); profileManager.addProfileChangeListener(new ProfileChangeAdapter() { @@ -653,8 +657,10 @@ public class InspectionResultsView extends JPanel implements Disposable, DataPro final AnalysisUIOptions uiOptions = myGlobalInspectionContext.getUIOptions(); final InspectionToolPresentation presentation = myGlobalInspectionContext.getPresentation(wrapper); if (presentation.getToolNode() == null) { + presentation.updateContent(); addTool(wrapper, HighlightDisplayLevel.find(presentation.getSeverity((RefElement)refElement)), uiOptions.GROUP_BY_SEVERITY, isSingleInspectionRun()); + return; } final InspectionNode toolNode = presentation.getToolNode(); LOG.assertTrue(toolNode != null);