Bug 243653 - ASTRewrite is incorrectly documented
Summary: ASTRewrite is incorrectly documented
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL: http://help.eclipse.org/stable/topic/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-09 06:36 EDT by Roland Illig CLA
Modified: 2009-05-07 03:32 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (2.41 KB, patch)
2008-08-11 10:43 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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