Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364678

Summary: [xtend] extract method refactoring
Product: [Tools] Xtend Reporter: Steve Ash <stevemash>
Component: CoreAssignee: Project Inbox <xtend-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jan, sven.efftinge, xtend-inbox
Version: 2.2.0   
Target Milestone: M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Steve Ash CLA 2011-11-24 02:36:09 EST
Build Identifier: 

Add editor support for the refactorings:
1- extract method
2- create method

As a side note, this summer some interns conducted a survey on the lombok mailing list via a large google docs spreadsheet.  They crunched the results and have a top 15 refactorings used in eclipse for java development (by lombok users at least:

 1) Rename Method 
 2) Organize Imports 
 3) Rename Class 
 4) Rename Field 
 5) Extract method 
 6) Rename Local Variable 
 7) Extract Local Variable 
 8) Rename Method Arguments 
 9) Toggle Comment (Ctrl + /) 
10) Inline Local Variable 
11) Override/Implement Methods 
12) Inline Method 
13) Extract Constant 
14) Handle uncaught exception by adding try/catch 
15) Create new method for references to method that can not be 
resolved  

This enhancement request is for 5 and 15.  I'm surprised 15 is so low.  Part of me thinks its because it is worded poorly.  Personally, I write code like this constantly: start at a high level of abstraction and type method names that dont exist, then ctrl+1 and have it generate the method stub.  This is how I write everything, so I'm really missing #15 right now.

Reproducible: Always
Comment 1 Sven Efftinge CLA 2011-11-24 02:40:02 EST
Cool, thanks for the list.
Seems like we did prioritization right so far :-)
It also pretty much looks like the stuff I do most often.

What do you mean by "create method"?
Comment 2 Steve Ash CLA 2011-11-24 03:05:09 EST
Yes agreed! I was really happy to use the rename successfully :-)

The create method is this: I'm creating a class like:

1 class ZombieScout {
2    
3   def scout() {
4      val zombiesFound = isZombiesHere();
5      if (zombiesFound) {
6         startShooting();
7      }
8   }
9}

So as I'm typing (at my highest business-ey level of abstraction) and I get to line #4 no method names isZombiesHere exists.  In the java editor, I almost without thinking just hit ctrl+1 and it offers me a quick-fix of "create method isZombiesHere()" which I hit enter, and then it invokes the template allowing me to fill in the param types and names and return types or accept the defaults.  Same would be true of line #6 as well.  Then once I have my high level scout() method, I go flesh out the private helper isZombiesHere() and startShooting() methods.

This is a pretty big deal for me because I just do it all the time, but maybe that's not very typical.  Its only #15 on the lambok list, but like I said-- I think that's mainly because it is worded poorly.

As an FYI: here is the survey its quite comprehensive:
http://www.google.com/url?sa=D&q=https://spreadsheets.google.com/spreadsheet/viewform%3Fformkey%3DdGkxQXVxU3ZDMkpJc0ctd3doSDVyTGc6MQ&usg=AFQjCNHETBxPJCtMOnuyYxlOxTY1yQaegA
Comment 3 Sven Efftinge CLA 2011-11-24 03:10:37 EST
I see. Could you do me a favor and copy your description to a separate ticket.
Comment 4 Steve Ash CLA 2011-11-24 03:54:50 EST
Yep- create Bug 364687
Comment 5 Jan Koehnlein CLA 2012-11-14 04:36:53 EST
First shot commited. Missing parts:
- rename of method parameters
- methods with type parameters
- check parameter order wrt. varargs
Comment 6 Jan Koehnlein CLA 2012-11-14 06:48:04 EST
Parameters renamable, support for type parameters added.

Vararg parameters are handed through as arrays anyway, so I can live without the validation.

Pushed to MASTER
Comment 7 Eclipse Webmaster CLA 2017-10-31 11:06:16 EDT
Requested via bug 522520.

-M.
Comment 8 Eclipse Webmaster CLA 2017-10-31 11:17:37 EDT
Requested via bug 522520.

-M.