eclipse.platform.ui
eclipse.platform.ui copied to clipboard
sortOnly CommonSorter gets thrown away by other NavigationContent TriggerPoints
How to reproduce:
Setup:
- navigationContent
navA
providinge1
with specific trigger points (e.g. providing and acting on.xml
files) - Object
e1
belonging tonavA
(e.g. filefoo.xml
) - Object
e2
not belonging tonavA
and not fulfilling its trigger points/enablement (e.g. filebar.txt
) - sortOnly commonSorter
sortF
with the same or higher priority thannavA
valid for the objects (e.g. parent isIFolder
)
https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L132-L138
Sequence:
-
sorterService.findSorter(...)
will correctly return the sorter defined bysortF
(implementation:org.eclipse.ui.internal.navigator.sorters.NavigatorSorterService
) -
if (!descriptor.isSortOnly())
will be entered asnavA
can't be sortOnly -
descriptor.isTriggerPoint(e2)
will befalse
-
sortF
sorter will be wrongfully discarded
Notes:
1.
if (!descriptor.isSortOnly())
will always be entered (if my understanding is correct) as this code
https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L83-L84
can't ever give a sortOnly navigationContent as source (as it can't provide items per definition).
These are used in the later call:
https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L108-L110
If both navigationContents involved fail isTriggerPoint()
then no sorter will ever be provided (e.g. navA
as above and navB
only acting on .json
files)
A sortOnly commonSorter with lower priority would be a good idea in case no common sorter is found (as a fallback). That could be added right before https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L118-L120