Bug 54947 - extract method: convert continue to return when extracting loop body [refactoring]
Summary: extract method: convert continue to return when extracting loop body [refacto...
Status: RESOLVED DUPLICATE of bug 48056
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Dirk Baeumer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-16 04:40 EST by Tom Hofmann CLA
Modified: 2004-03-16 13:01 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2004-03-16 04:40:48 EST
I20040310

I often want to extract a loop body to its own method. If I have "continue"
statements in the loop body, the refactoring will not be allowed. Would
converting them to "return" statements be semantically preserving (if the entire
loop body is extracted, anyway)?

Exp:

<pre>
for (int i= 0; i < 10; i++) {
    if (condition1)
        continue;
    if (condition2)
        continue;

    doStuff();
}
</pre>

Extracting the loop body would produce:

<pre>
for (int i= 0; i < 10; i++) {
    loopBody();
}

// ...

private void loopBody() {
    if (condition1)
        return;
    if (condition2)
        return;

    doStuff();
}

</pre>
Comment 1 Tom Hofmann CLA 2004-03-16 04:41:02 EST
wrong component
Comment 2 Dirk Baeumer CLA 2004-03-16 13:01:09 EST
 

*** This bug has been marked as a duplicate of 48056 ***