From 356ee93e3328a3fdc3cba6fa28e5eb94f6685a87 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Thu, 31 Jan 2013 20:12:39 +0100 Subject: [PATCH] AppCode:Unit Testing: comparator corrected (CR-OC-150) --- .../intellij/testIntegration/TestFinderHelper.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java index 58fc1de4cbd1..8b419e4a58bb 100644 --- a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java +++ b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; import com.intellij.psi.codeStyle.NameUtil; +import org.jetbrains.annotations.Nullable; import java.util.*; @@ -72,12 +73,18 @@ public class TestFinderHelper { public static List getSortedElements(final List> elementsWithWeights, final boolean weightsAscending) { + return getSortedElements(elementsWithWeights, weightsAscending, null); + } + + public static List getSortedElements(final List> elementsWithWeights, + final boolean weightsAscending, + @Nullable final Comparator sameNameComparator) { Collections.sort(elementsWithWeights, new Comparator>() { public int compare(Pair o1, Pair o2) { int result = weightsAscending ? o1.second.compareTo(o2.second) : o2.second.compareTo(o1.second); - if (result == 0) { - result = Comparing.compare(o1.first.getName(), o2.first.getName()); - } + if (result == 0) result = Comparing.compare(o1.first.getName(), o2.first.getName()); + if (result == 0 && sameNameComparator != null) result = sameNameComparator.compare(o1.first, o2.first); + return result; } });