fix custom severities order

This commit is contained in:
Dmitry Batkovich
2018-09-06 14:33:09 +03:00
parent 2a8900284f
commit 2c6b0c44b6
@@ -151,7 +151,7 @@ public class SeverityRegistrar implements Comparator<HighlightSeverity> {
}
else {
//enforce include all known
List<HighlightSeverity> list = getAllSeverities();
List<HighlightSeverity> list = getSortedSeverities(orderMap);
for (HighlightSeverity stdSeverity : knownSeverities) {
if (!list.contains(stdSeverity)) {
for (int oIdx = 0; oIdx < list.size(); oIdx++) {
@@ -200,9 +200,14 @@ public class SeverityRegistrar implements Comparator<HighlightSeverity> {
@NotNull
public List<HighlightSeverity> getAllSeverities() {
return Arrays.stream(getOrderMap().keys())
return getSortedSeverities(getOrderMap());
}
@NotNull
private List<HighlightSeverity> getSortedSeverities(OrderMap map) {
return Arrays.stream(map.keys())
.map(o -> (HighlightSeverity)o)
.sorted(this)
.sorted((o1, o2) -> compare(o1, o2, map))
.collect(Collectors.toList());
}
@@ -264,7 +269,12 @@ public class SeverityRegistrar implements Comparator<HighlightSeverity> {
@Override
public int compare(@NotNull HighlightSeverity s1, @NotNull HighlightSeverity s2) {
OrderMap orderMap = getOrderMap();
return compare(s1, s2, getOrderMap());
}
private int compare(@NotNull HighlightSeverity s1,
@NotNull HighlightSeverity s2,
@NotNull OrderMap orderMap) {
int o1 = orderMap.getOrder(s1);
int o2 = orderMap.getOrder(s2);
return o1 - o2;