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

Bug 103774

Summary: [refactoring] [dcr] New refactoring: create single exit point
Product: [Eclipse Project] JDT Reporter: David Saff <david>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: martinae
Version: 3.1Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description David Saff CLA 2005-07-14 03:35:43 EDT
I sometimes have methods like this:

int findIndex(List<String> list, String entry) {
  for (int i = 0; i < list.size(); i++) {
    if (list.get(i).equals(entry))
      return i;
  }
  return -1;
}

This method doesn't play well with refactorings like Inline Method.  I'd like to
be able to safely, automatically, convert it to a single-entry-point style:

int findIndex(List<String> list, String entry) {
  int returnThis = -1;
  for (int i = 0; i < list.size(); i++) {
    if (list.get(i).equals(entry)) {
      returnThis = i;
      break;
    }
  }
  return returnThis;
}

This is non-trivial to automate, but it's also non-trivial to do by hand, and
can easily be a source of mistakes.
Comment 1 Martin Aeschlimann CLA 2006-06-16 08:06:57 EDT
Not easy to find a good plase for this. A new refactoring is an overkill (we can't add much more refactorings to the menu), so maybe better a quick assist but it would be hard to find by the user.

No plans at the moment, contributions welcome.
Comment 2 David Saff CLA 2006-06-16 09:12:39 EDT
The deferment is understandable, but the reason given is a little confusing.  It looks like you're saying that there's a limit on the number of refactorings and quick assists that can be reasonably added.  Isn't this a problem regardless of whether the Eclipse team or an outside contributor decides to do the implementation?

Is this a good place to have such a discussion?
Comment 3 Martin Aeschlimann CLA 2006-06-16 10:31:29 EDT
I set this one to later as we don't plan to implement this in the near future.

One reason is surely that I don't see clearly we would fit such a 'niche' refactoring in our current structure. A external contributer would surely run into the same problem. I don't have a solution for that at the moment. It's surely an area where things have to be tried out. For example as a quick assist (where we have no problem of increasing the list), but with better visibility so it is detectable by the user.
Comment 4 David Saff CLA 2006-06-16 10:59:50 EDT
Is there any way to reorganize the Refactoring menu so that it could be open to such contributions, "niche" or not?  As much as I enjoy the experience of hitting Control-1 and discovering some new thing I wasn't expecting, it's also nice to have some sort of overview of possible code actions.
Comment 5 Eclipse Webmaster CLA 2009-08-30 02:42:10 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.