diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java index b7e0447b933..5e69330e723 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java @@ -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; } });