Summary: | NPE in extract method | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Till Bay <till_bay> | ||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
Status: | RESOLVED DUPLICATE | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | akiezun, andreas.krueger, dirk_baeumer | ||||
Version: | 2.0 | ||||||
Target Milestone: | 2.0 F3 | ||||||
Hardware: | PC | ||||||
OS: | Windows 2000 | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Till Bay
2002-06-05 10:55:51 EDT
Created attachment 1263 [details]
code.txt
Till, what is the original context (file, project) for the code snippet This should normally not happen. The problem is that the position returned from code formatter doesn't map to a valid position in the string anymore. i saw the file too - positions were really out of synch (judging by what structured selection said) Till, you still have the file around? sent the file to Dirk This is a formatter problem. Here is the scenario I use: code to format: private void eee(String string, TextBufferEditor tbe, String lineDelimiter, IMember member, String source, IScanner scanner) throws JavaModelException, CoreException{ x(); } Formatter call: String formattedCode= formatter.format(codeToFormat, 0, positions, lineSeparator); positions is [165, 168] lineSeparator is ascii 10 The result is a string of length 183 put the returned positions are [184, 187]. So they lay outside the string which causes the NPE since I don't handle this case. Note that codeToFormat is one string with line delimiters. Added guard code and fixup code if the positions seem to be bogus. Moving to JDT/Core since it is a formatter bug. We did not change this code recently, it should have never work since day one. The problem only occurs if there is a double split of the string. In your example, there is a split on the throws keyword and on the commas in the parameters list. Dirk Baeumer says, over at bug 18997, that that bug is related to this one. *** This bug has been marked as a duplicate of 18997 *** |