be prepared to some crazy ChooseByName models that put "non-prefix matches:" as the first item (EA-92486 - assert: ContributorsBasedGotoByModel.getElementName)

This commit is contained in:
peter
2017-02-27 14:37:49 +01:00
parent 4e01a68e2a
commit dfa6ae7f6f
@@ -1029,22 +1029,24 @@ public abstract class ChooseByNameBase {
reversed();
int bestPosition = 0;
while (bestPosition < modelElements.length - 1 && isSpecialElement(modelElements[bestPosition])) bestPosition++;
for (int i = 1; i < modelElements.length; i++) {
final Object modelElement = modelElements[i];
if (EXTRA_ELEM.equals(modelElement) || NON_PREFIX_SEPARATOR.equals(modelElement)) continue;
if (isSpecialElement(modelElement)) continue;
if (itemComparator.compare(modelElement, modelElements[bestPosition]) < 0) {
bestPosition = i;
}
}
if (bestPosition < modelElements.length - 1 && modelElements[bestPosition] == NON_PREFIX_SEPARATOR) {
bestPosition++;
}
return bestPosition;
}
private static boolean isSpecialElement(Object modelElement) {
return EXTRA_ELEM.equals(modelElement) || NON_PREFIX_SEPARATOR.equals(modelElement);
}
private int getUseCount(String statContext, Object modelElement) {
String text = myModel.getFullName(modelElement);
return text == null ? Integer.MIN_VALUE : StatisticsManager.getInstance().getUseCount(new StatisticsInfo(statContext, text));