Community
Participate
Working Groups
I'm trying to extract a piece of code into a method. When the Refactoring Wizard pops up, I enter the method name as usual. First weirdness: I hit "next", there is a bit of activity, but then what I see does not change. I'm still on the initial wizard screen that asks me to type in the method name. If I hit next again, this time nothing happens, not even activity. When I hit "Finish", I get an exception. I'll enclose a screen shot. The problem seems to be reproducable, even after I shut down eclipse and start it back up again. I'll save the workspace when I'm done with this bug report, feel free to ask more questions.
Created attachment 1212 [details] Screenshot after producing the bug.
Both F1 and F2. The screenshot above was produced with build 20020602, but the same bug is reproducable with build 20020521 as well.
Is there any information in your .log file? (located in the .metadata directory for your workspace) Moving to JDT/Core for comment. (sorry if this should be JDT/UI)
Created attachment 1251 [details] Relevant part of file .log from .metadata directory.
This bug is related to 19335 but could be caused by different code in the formatter. That's why I keep them separate. The formatter somehow jumbles up the positions. As a result the value of positions[1] is -5 which is definitly not inside the formatted code. Added guard and fixup code to protect code against this. Andreas can you provide example code that caused this exception. It would be really helpful to reproduce the problem in the formatter.
Created attachment 1286 [details] Eclipse project that's rather small and reproduces the problem (see comment in file Make.java).
Remarks on my attachment: The file is a .zip - Archive, but when I downloaded it just to make sure, it arrived here with the name of "showattachment.cgi". Probably a Bugzilla bug. Simply rename to something.zip. When I tried to come up with a small example, I tried to get rid of the function call at the start of where the refactoring is. That made the bug go away.
Andreas, thank you for providing the code. Helped me to verify that this is a formatter bug. The problem is the same as in 19335. The length of the formatted code is 176, the mapped positions are [176, 179] which are outside the string. Calling formattedCode.substring(179 + 1) result in an index out of bounds exception of (-4). Added fixed up code covers this problem as well
Moving to JDT/Core since it is a formatter bug.
It is too risky to fix that now.
*** Bug 19335 has been marked as a duplicate of this bug. ***
Deferring, too risky, and refactoring is protecting itself.
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.