Summary: | Refactor / Extract Method produces Exception "string index out of range" | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Andreas Krüger <andreas.krueger> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED WONTFIX | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | dirk_baeumer, till_bay |
Version: | 2.0 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: | |||
Attachments: |
Description
Andreas Krüger
2002-06-04 07:25:47 EDT
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. |