Community
Participate
Working Groups
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.
Created attachment 109666 [details] Proposed fix
Released for 3.5M2. Rolland, please verify that this corresponds to your expectations.
Looks great. I didn't expect the MalformedTreeException to be mentioned (since it's a RuntimeException), but it seems to be useful. Roland
I added the MalformedTreeException exception so that users that get accustomed with this API realize that this is a possible exception.
Verified for 3.5M2 using I20080914-2000