Bug 43237 - Code generation and refactorings should respect configured java members sort order [code manipulation] [refactoring]
Summary: Code generation and refactorings should respect configured java members sort ...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2003-09-17 13:59 EDT by Eugene Kuleshov CLA
Modified: 2009-08-30 02:07 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Kuleshov CLA 2003-09-17 13:59:45 EDT
Several actions related to Java code generation and refactorings (i.e. create
method, create inner class, create field, generate getters/setters and some
others) does not respect configured members sort order (Preferences -> Java ->
Appearance -> Members Sort Order) and place new code just after current method
or in the beginning of the class file. I believe the right approach will be to
add new methods/classes/fields to the end of the particular member group
(complete group list is available at "Members Sort Order" preference page).

Several refactorings allow to choose insertion point. This dropdown should also
set the default insertion point using the same rules above.
Comment 1 Olivier Thomann CLA 2003-09-17 16:54:02 EDT
Move to JDT/UI.
Comment 2 Eugene Kuleshov CLA 2003-09-17 17:01:52 EDT
Is it really UI? For me it sounds like something from the backend...
Comment 3 Dirk Baeumer CLA 2003-09-18 04:15:35 EDT
This is JDT/UI since we are coding backend stuff as well <g>.

I agree with your comment. There are plans to improve the sorting capabilities 
and we decided to not change the refactoring/source manipulation code until we 
know how the new sorting feature will look like.
Comment 4 Eugene Kuleshov CLA 2004-07-23 11:45:02 EDT
Any chance to get this feature implemented in 3.0.1 or 3.1 release?
Comment 5 Dirk Baeumer CLA 2004-07-25 12:54:42 EDT
Eugene, please don't change the target milestone field.

We have this on the plan for 3.1 but it depends on how much effort has to go 
into J2SE 5.0.
Comment 6 Eugene Kuleshov CLA 2004-07-25 13:08:39 EDT
Sorry, I wasn't sure about process. This is unclear when and how bugs in
"resolved later" status will be picked up. Some of these over a year old and
looks like forgotten.
Comment 7 Eugene Kuleshov CLA 2005-02-16 12:09:09 EST
Sorry for disturbing. I wonder if there is any estimate when this issue would be
resolved.
Comment 8 Martin Aeschlimann CLA 2005-02-16 12:36:50 EST
There's no news yet. We are still covered with 5.0 issues which have priority.
Comment 9 Dirk Baeumer CLA 2005-03-16 14:04:12 EST
Sorry, but this will not make it into 3.1.
Comment 10 Martin Aeschlimann CLA 2006-06-19 09:47:06 EDT
We started doing that and it seems most refactorings already do. Can you file bugs against the features that don't?
Comment 11 Eugene Kuleshov CLA 2006-06-19 10:17:01 EDT
(In reply to comment #10)
> We started doing that and it seems most refactorings already do. Can you file
> bugs against the features that don't?

Really? I must be not using those most then. Extract method creates new private method right after method where it is extracted from andconvert anonymous class to nested always creates new class at the beginning of the class even if my sort order says to have them at the end.

Comment 12 Eugene Kuleshov CLA 2006-06-24 10:28:32 EDT
The following refactorings does not respect sorting order:

-- "Extract method" always put extracted method next to one where it is extracted from. I have private method at the bottom of the class
-- "Convert anonymous class to nested" always put new class to the top of the class. I have nested types at the bottom of the class right after private methods.

I just realized that member sorting order configuration can be defined on the project level...
Comment 13 Martin Aeschlimann CLA 2006-06-24 18:34:06 EDT
The member sort order is only per workspace. It's main purpose is to specify the sort order in views (for example sort button in outline). Therefore we can't put that on a per project level.

I filed bug 148544 for "Convert anonymous class to nested" and bug 148543 for Extract method. If you find more refactorings that randomly insert new elements,  I'dbe happy if you could also file new bugs. This bug is too general and hard to track.

The only thing we want to fix is that elements are entered next to elements of similar kinds. For example static methods next to static. If no element of the same kind is found, we use the member sort order to evaluate a good insertion point. Obviously, classes that don't follow the sort order themself might find the created element at some stranger place.
We do not plan to enter the new method alphabetically. 
Comment 14 Eugene Kuleshov CLA 2006-07-03 09:59:48 EDT
(In reply to comment #13)
> The member sort order is only per workspace. It's main purpose is to specify
> the sort order in views (for example sort button in outline). Therefore we
> can't put that on a per project level.

Hmm. It sounds like another setting is needed to allow sorting for refactoring actions and such. So, that one can be made per-project.

> The only thing we want to fix is that elements are entered next to elements of
> similar kinds. For example static methods next to static. If no element of the
> same kind is found, we use the member sort order to evaluate a good insertion
> point. Obviously, classes that don't follow the sort order themself might find
> the created element at some stranger place.
> We do not plan to enter the new method alphabetically. 

I wasn't really looking for alphabetical sorting. Most annoying thing is that Eclipse refactorings are creating private methods in the middle of class. It would be really handy if those would be created at the end. So, it seems that searching for "same kind" probably should work from the end of the class and not from the current position. That would also help to deal with versionned resources since those will be easier to merge in case of conflicts.
Comment 15 Denis Roy CLA 2009-08-30 02:07:20 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.