Bug 243653

Summary: ASTRewrite is incorrectly documented
Product: [Eclipse Project] JDT Reporter: Roland Illig <roland.illig>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jerome_lanneluc, Olivier_Thomann
Version: 3.5   
Target Milestone: 3.5 M2   
Hardware: All   
OS: All   
URL: http://help.eclipse.org/stable/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/rewrite/ASTRewrite.html
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description Roland Illig CLA 2008-08-09 06:36:06 EDT
Build ID: N/A

Steps To Reproduce:
1. Visit http://help.eclipse.org/stable/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/rewrite/ASTRewrite.html
2. Copy the example code
3. Try to use it


More information:
The variable names "doc" and "document" should be unified.

The "assert" line should be changed as follows:
- assert "import java.util.List;\nimport java.util.Set;\nclass X {}".equals(doc.get().toCharArray());
+ assert "import java.util.List;\nimport java.util.Set;\nclass X {}\n".equals(doc.get());

And, while you're there, you could also add a try-catch block around the call to edits.apply.
Comment 1 Olivier Thomann CLA 2008-08-11 10:43:53 EDT
Created attachment 109666 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2008-08-11 10:44:29 EDT
Released for 3.5M2.
Rolland, please verify that this corresponds to your expectations.
Comment 3 Roland Illig CLA 2008-08-11 16:57:46 EDT
Looks great. I didn't expect the MalformedTreeException to be mentioned (since it's a RuntimeException), but it seems to be useful.

Roland
Comment 4 Olivier Thomann CLA 2008-08-11 17:48:55 EDT
I added the MalformedTreeException exception so that users that get accustomed with this API realize that this is a possible exception. 
Comment 5 Jerome Lanneluc CLA 2008-09-15 08:55:21 EDT
Verified for 3.5M2 using I20080914-2000