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

Bug 71772

Summary: Add "Introduce return value" refactoring [refactoring]
Product: [Eclipse Project] JDT Reporter: Oyvind Harboe <oyvind.harboe>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 Keywords: helpwanted
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Oyvind Harboe CLA 2004-08-11 07:42:16 EDT
I.e.

foo();

void foo()
{
   x=5;
}

"x" -> return value

=>

x=foo();

int foo()
{
   return 5;
}
Comment 1 Olivier Thomann CLA 2004-08-11 11:01:55 EDT
Move to JDT/UI
Comment 2 Markus Keller CLA 2004-08-11 12:06:28 EDT
Do you have an example where this would really be useful and worth to be
implemented? 

Looks more like a quick fix than a refactoring.
Comment 3 Oyvind Harboe CLA 2004-08-11 14:22:05 EDT
>Do you have an example where this would really be useful and worth to be
>implemented? 

Refactoring is not only about changing existing code. I use it all the time 
when I write new code.

E.g. I don't write methods anymore. I write the code I need inline, then I 
extract a method.

The idea is to write code for a specific case, and then use refactoring to 
generalize. It lets me focus on one thing at the time.

In the particular case I was working on, I wrote an inline piece of code, but 
when it came time to extract a method, I "discovered" that I had modified 
fields in the object and that there was no way to change the modification of a 
field to a return code.

>Looks more like a quick fix than a refactoring.

"x" in the example is a field in the class, and hence there is no error. I 
thought "quick fixes" only exists for errors?

In practical terms there is little difference between "quick fix" and "small 
refactoring" for me. Both rewrite the program in the fashion I'd like to have 
it rewritten.

Øyvind
Comment 4 Dirk Baeumer CLA 2004-09-14 13:22:15 EDT
Given the current planning this will not happen for 3.1 without external help.
Comment 5 Denis Roy CLA 2009-08-30 02:20:43 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.