From f6821d7fe881907bf8922a6d5b0fca4aec5f754e Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Fri, 7 Oct 2016 10:23:58 +0200 Subject: [PATCH] EA-89456 - IAE: CleanupInspectionIntention.applyFixes --- .../codeInspection/actions/CleanupInspectionIntention.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java index 0a4e9104df61..f3d465ab3032 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java @@ -31,6 +31,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Comparing; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiUtilCore; @@ -97,7 +98,11 @@ public class CleanupInspectionIntention implements IntentionAction, HighPriority Collections.sort(descriptions, (o1, o2) -> { final ProblemDescriptorBase d1 = (ProblemDescriptorBase)o1; final ProblemDescriptorBase d2 = (ProblemDescriptorBase)o2; - return -PsiUtilCore.compareElementsByPosition(d1.getPsiElement(), d2.getPsiElement()); + final int elementsDiff = PsiUtilCore.compareElementsByPosition(d1.getPsiElement(), d2.getPsiElement()); + if (elementsDiff == 0) { + return Comparing.compare(d1.getDescriptionTemplate(), d2.getDescriptionTemplate()); + } + return -elementsDiff; }); final SequentialModalProgressTask progressTask =