Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly sort marker resolution by relevance #2752

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading