Skip to content

Commit

Permalink
Properly sort marker resolution by relevance
Browse files Browse the repository at this point in the history
Currently the marker resolution is sorted, but markers with the *lowest*
relevance are show on top, and therefore these are selected by default.
This is confusing and gives a bad user experience, also this is the
reverse order than we use when offering the quickfix in the editor
itself.

This now sorts the list that the marker with the highest relevance is on
top and selected by default.
  • Loading branch information
laeubi committed Jan 23, 2025
1 parent 6d3c665 commit 935b1db
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,27 @@ public Image getImage(Object element) {
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
int relevanceMarker1 = (e1 instanceof IMarkerResolutionRelevance)
? ((IMarkerResolutionRelevance) e1).getRelevanceForResolution()
: 0;
int relevanceMarker2 = (e2 instanceof IMarkerResolutionRelevance)
? ((IMarkerResolutionRelevance) e2).getRelevanceForResolution()
: 0;
int c = Integer.compare(relevanceMarker1, relevanceMarker2);
int relevanceMarker1 = getRelevance(e1);
int relevanceMarker2 = getRelevance(e2);
int c = Integer.compare(relevanceMarker2, relevanceMarker1);
if (c != 0) {
return c;
}
return ((IMarkerResolution) e1).getLabel().compareTo(((IMarkerResolution) e2).getLabel());
return getLabel(e1).compareTo(getLabel(e2));
}

private static String getLabel(Object object) {
if (object instanceof IMarkerResolution resolution) {
return resolution.getLabel();
}
return ""; //$NON-NLS-1$
}

private static int getRelevance(Object object) {
if (object instanceof IMarkerResolutionRelevance relevance) {
return relevance.getRelevanceForResolution();
}
return 0;
}
});

Expand Down

0 comments on commit 935b1db

Please sign in to comment.