int[] (final Collection<? extends PsiElement> array) { IntList offsets = new IntArrayList(array.size()); for (PsiElement element : array) { int offset = element.getTextOffset(); assert offset >= 0 : element + " ("+element.getClass()+"); offset: " + offset; offsets.add(offset); } offsets.sort(null); return offsets.toIntArray(); }