> --__--__--
> From: "Valentin Kipiatkov" <[EMAIL PROTECTED]>
> Subject: Re: [Eap-list] Extract Method with multiple exit points

> > 1. When extracting method which contains a "continue" statement and
> > returns "void" - change the continue to return (it shouldn't work if
the
> > statement is "continue <label>").
> 
> It should work in this way if the replacement is correct. Could you
provide
> any example where it does not work?

Ok, now it works.. I used to need this in 5XX build.
But while I tried to make a test case I found another bug:

public class TestInlineMethod {
    int rs, negativeResults = 0;

    void test(){
        randsgn();
        System.out.println(Math.pow(rs, negativeResults));
    }

    void randsgn(){
        if (Math.random()<0.5) { rs=1; return; }
        else rs = -1;
        negativeResults++;
    }
}


when I inline randsgn() i get:

    void test(){
        if (Math.random()<0.5) { rs=1; return; }
        else rs = -1;
        negativeResults++;
        System.out.println(Math.pow(rs, negativeResults));
    }

It's not the same...

So what about my previous suggestion?
> 2. This is somewhat ugly, but is stil usefull while refactoring: When
inlining method which has 
>   "void" return type and multiple exit points, wrap the method in a
"do{<method_body_here>}while (false)" 
>   and replace each return with break. This especially combined with
the new code inspections could make use.

This would work in all cases and should be very easy to be refactored
into acceptable code.

--dimiter


_______________________________________________
Eap-list mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-list

Reply via email to