Bug 402464 - Add @Deprecated to ViewerSorter
Summary: Add @Deprecated to ViewerSorter
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 4.6 M4   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 395213
Blocks: 482137 483839
  Show dependency tree
 
Reported: 2013-03-05 12:33 EST by Lars Vogel CLA
Modified: 2017-03-22 09:49 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2013-03-05 12:33:27 EST
According to the Javadoc ViewerSorter should not be used, and ViewerComparator should be used instead. Once we move JFace to Java 1.5, I suggest to add the @Deprecate flag to the class. This makes it easier to people to see that they should avoid using this class.
Comment 1 Lars Vogel CLA 2013-07-23 16:02:02 EDT
Gerrit review request https://git.eclipse.org/r/14791
Comment 2 Paul Webster CLA 2013-07-24 15:12:45 EDT
This patch leads to 3 errors in the Problems view:

Description	Resource	Path	Location	Type
Javadoc: The type ViewerSorter is deprecated	TreePathViewerSorter.java	/org.eclipse.jface/src/org/eclipse/jface/viewers	line 72	Java Problem
Javadoc: The type ViewerSorter is deprecated	TreePathViewerSorter.java	/org.eclipse.jface/src/org/eclipse/jface/viewers	line 51	Java Problem
Javadoc: The type ViewerSorter is deprecated	TreePathViewerSorter.java	/org.eclipse.jface/src/org/eclipse/jface/viewers	line 32	Java Problem
Comment 3 Lars Vogel CLA 2013-07-24 16:08:36 EDT
Will you accept the patch to deprecate ViewerSorter if the Problems View gets updated to use ViewerComparator?
Comment 4 Paul Webster CLA 2013-07-25 14:36:22 EDT
I mean this patch caused 3 compile errors in jface in org/eclipse/jface/viewers/TreePathViewerSorter  It's API so we can delete it, we'll need to deal with those errors.

PW
Comment 5 Dani Megert CLA 2013-07-29 08:24:25 EDT
(In reply to comment #4)
> I mean this patch caused 3 compile errors in jface in
> org/eclipse/jface/viewers/TreePathViewerSorter  It's API so we can delete
> it, we'll need to deal with those errors.
> 
> PW

We should not change code just because we deprecate a certain member. The problem is only in Javadoc and only because that setting is set to error and includes deprecation, which for code is set to 'Warning'. I suggest to either exclude deprecation checking in Javadoc or report malformed Javadoc as warning instead of error.
Comment 6 Lars Vogel CLA 2013-07-30 04:43:25 EDT
New change pushed, following Danis suggestion (exclude deprecation checking in Javadoc).

One question, if the Javadoc says ViewerSort should not be used, should derived class as TreePathViewerSorter not also deprecated?
Comment 7 Paul Webster CLA 2013-07-30 11:38:52 EDT
(In reply to comment #4)
> I mean this patch caused 3 compile errors in jface in
> org/eclipse/jface/viewers/TreePathViewerSorter  It's API so we can delete
> it, we'll need to deal with those errors.

This should read "it's API so we can't delete it"

PW
Comment 8 Lars Vogel CLA 2013-08-01 05:03:15 EDT
> This should read "it's API so we can't delete it"

New patch set updated with the suggestion of Dani.
Comment 9 Paul Webster CLA 2013-08-01 11:04:18 EDT
(In reply to comment #8)
> 
> New patch set updated with the suggestion of Dani.

I can't rebase patch set 4, it says it's in conflict.  It also doesn't include any changes to prefs, won't I still get my compile errors?

PW
Comment 11 Lars Vogel CLA 2015-11-13 11:49:37 EST
.
Comment 12 Markus Keller CLA 2015-11-27 09:34:09 EST
>  ** @deprecated see <code>ViewerSorter</code> for more information.
>...
> public class TreePathViewerSorter extends ViewerSorter {

That doesn't make sense and violates our rules about API deprecation.

ViewerSorter doesn't tell what clients of TreePathViewerSorter should do. If you want to deprecate TreePathViewerSorter, you have to implement a new class TreePathViewerComparator and port at least one client as a proof that it really works.
Comment 13 Eclipse Genie CLA 2015-12-07 14:18:58 EST
New Gerrit change created: https://git.eclipse.org/r/62144
Comment 15 Lars Vogel CLA 2015-12-07 14:22:18 EST
(In reply to Markus Keller from comment #12)
> >  ** @deprecated see <code>ViewerSorter</code> for more information.
> >...
> > public class TreePathViewerSorter extends ViewerSorter {
> 
> That doesn't make sense and violates our rules about API deprecation.
> 
> ViewerSorter doesn't tell what clients of TreePathViewerSorter should do. If
> you want to deprecate TreePathViewerSorter, you have to implement a new
> class TreePathViewerComparator and port at least one client as a proof that
> it really works.

Thanks Markus, I reverted the change for TreePathViewerSorter and opened Bug 483839 for its replacement.
Comment 16 Patrick Tasse CLA 2015-12-11 12:35:59 EST
In our project we replaced all use of ViewerSorter with ViewerComparator.

But we have one class which is now an instance of ViewerComparator that is used in the org.eclipse.ui.navigator.navigatorContent extension point in the navigatorContent/commonSorter element.

That class is instantiated by the platform and it triggers a ClassCastException:

java.lang.ClassCastException: org.eclipse.myproject.ui.MyViewerComparator cannot be cast to org.eclipse.jface.viewers.ViewerSorter
	at org.eclipse.ui.internal.navigator.sorters.CommonSorterDescriptor$1.run(CommonSorterDescriptor.java:97)

Should that extension point be deprecated? Or should it accept both ViewerComparator and ViewerSorter? Can it be fixed in both Neon and Mars.2?
Comment 17 Lars Vogel CLA 2015-12-11 13:06:57 EST
(In reply to Patrick Tasse from comment #16)
> In our project we replaced all use of ViewerSorter with ViewerComparator.
> 
> But we have one class which is now an instance of ViewerComparator that is
> used in the org.eclipse.ui.navigator.navigatorContent extension point in the
> navigatorContent/commonSorter element.
> 
> That class is instantiated by the platform and it triggers a
> ClassCastException:
> 
> java.lang.ClassCastException: org.eclipse.myproject.ui.MyViewerComparator
> cannot be cast to org.eclipse.jface.viewers.ViewerSorter
> 	at
> org.eclipse.ui.internal.navigator.sorters.CommonSorterDescriptor$1.
> run(CommonSorterDescriptor.java:97)
> 
> Should that extension point be deprecated? Or should it accept both
> ViewerComparator and ViewerSorter? Can it be fixed in both Neon and Mars.2?

Can you open a new bug for this?
Comment 18 Patrick Tasse CLA 2015-12-14 10:48:41 EST
Created Bug 484248 and linked it with Bug 482137.