Community
Participate
Working Groups
I20060725-0800 public class Try { public static void main(String[] args) { new Runnable() { public void run() { //extract method on "xx", extract to class Try System.out.println("xx"); } }; } } The extracted method is nonstatic, which results in a compile error.
Created attachment 142821 [details] patch+testcases This fixes bugs related to adding static modifiers where neccesarry. In addition it looses the restriction that you cannot extract code from an inner static class to an outer class (see test 1053)
Thanks, released to HEAD. It's interesting that you test the enclosingBodyDeclaration != null in the while loop, but after the loop you unconditionally access the same variable ;-) I added an instanceof check for added safety. A problem I saw was that the 'static' modifier in the preview of the dialog was not updated when the user changed the destination. Fixed in ExtractMethodInputPage.
(In reply to comment #2) > Thanks, released to HEAD. > > It's interesting that you test the enclosingBodyDeclaration != null in the while > loop, but after the loop you unconditionally access the same variable ;-) I > added an instanceof check for added safety. Four eyes see more then two ;-) I just wonder, this should be flagged by the compiler in my eyes. > > A problem I saw was that the 'static' modifier in the preview of the dialog was > not updated when the user changed the destination. Fixed in > ExtractMethodInputPage. Oh, missed that one. Thanks. I had in mind that I introduced that update but that was for another patch which is not yet attached to any bug ;)
Verified for 3.6 M1 using I20090803-1800