Bug 566547

Summary: CompareUIPlugin.findContentViewer should check for supported descriptors
Product: [Eclipse Project] Platform Reporter: Christopher Hendrich <christopher.hendrich>
Component: CompareAssignee: Platform-Compare-Inbox <platform-compare-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: 4.17   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Christopher Hendrich CLA 2020-09-01 08:04:05 EDT
Currently the method "CompareUIPlugin.findContentViewer" collects all matching (from a static point of view, e.g. file ending) ViewerDescriptor[s] for a given compare input and simply uses the first one from that list.

It would be more beneficial if there was a method "boolean ViewerDescriptor.supports(input)" which would be checked beforehand such that the first descriptor that supports the input would be used. By default, this method can return true all the time (might be implemented by custom descriptors).


The current behavior is a problem. For example, when searching and replacing text via the file search dialog, the TextEditChangePreviewViewer shows a preview of the changed text (by using text snippets) and uses the first matching compare content viewer for those text snippets. 
If you have a custom compare viewer registered for your complex object, this viewer will be used. It can - however - not work on text snippets and fails. For this scenario, I would like to check the compare input first and decide whether my special descriptor can be used or not.