mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user