Bug 566547 - CompareUIPlugin.findContentViewer should check for supported descriptors
Summary: CompareUIPlugin.findContentViewer should check for supported descriptors
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 4.17   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-01 08:04 EDT by Christopher Hendrich CLA
Modified: 2020-09-01 08:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.