Skip to content

CommonViewerSorter broken since 2026-03 #3900

@Wooza

Description

@Wooza

The CommonViewerSorter has been deprecated in favor of CommonViewerComparator in #3621.

The above PR added additional cases for TreePathViewerComparator in most locations, but here, the existing check for TreePathViewerSorter was replaced with TreePathViewerComparator.

@Override
protected Object[] getSortedChildren(Object parentElementOrTreePath) {
Object[] result = null;
ViewerComparator comparator = getComparator();
if (parentElementOrTreePath != null
&& comparator instanceof TreePathViewerComparator tpvs) {
result = getFilteredChildren(parentElementOrTreePath);
// be sure we're not modifying the original array from the model
result = result.clone();
TreePath path = null;
if (parentElementOrTreePath instanceof TreePath) {
path = (TreePath) parentElementOrTreePath;
} else {
Object parent = parentElementOrTreePath;
Widget w = internalGetWidgetToSelect(parent);
if (w != null) {
path = internalGetSorterParentPath(w, comparator);
}
}
tpvs.sort(this, path, result);
result = applyItemsLimit(parentElementOrTreePath, result);
} else {
return super.getSortedChildren(parentElementOrTreePath);
}
return result;
}

So when using CommonViewerSorter, the above code falls trough to the else case where some default sorting is applied. I think instead of replacing the case for TreePathViewerSorter, the case should have been duplicated for TreePathViewerComparator.

This surfaced as a test-failure in LSP4E (see eclipse-lsp4e/lsp4e#1512), where it was solved by using the new CommonViewerComparator. However, other Plugins still using CommonViewerSorter will be broken on 2026-03+

FYI: @iloveeclipse @akurtakov

Edit: Sorry, meant to post this with my work account (@FlorianKroiss)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions