Community
Participate
Eclipse IDE
(RC3) Consider a class: public class B<T> extends A {} We create an ASTRewrite and getListRewrite (lrw) for a node corresponding to the type B and the TypeDeclaration.TYPE_PARAMETERS_PROPERTY. Then we remove all the nodes from the list: List list = lrw.getOriginalList(); for (Iterator it = list.iterator(); it.hasNext(); ) { lrw.remove((ASTNode)it.next(), null); } and then we apply changes (rewrite the AST). The following code results: public class Bextends A {} which is wrong. The only thing I found out is that rewriteAst() generates two consecutive DeleteEdits of length two. Everything is OK if there is no "extends" clause.
Martin, can you please investigate. May be a candidate for 3.1.1 ?
Created attachment 24541 [details] patch for jdt.core
Created attachment 24542 [details] patch for jdt.core.tests.model
Philippe, can you please decide if you want this in 3.1.1? The rewriter in 3.1 can create non-compilable code when all type parameters or arguments are removed. It currently always starts removing from the opening bracket ('<') and removes until the token after the closing bracket ('>'). The following examples fail: class A<T>extends X -> class Aextends X class A<T> extends X -> class Aextends X public<T>void foo -> publicvoid foo public<T> void foo -> publicvoid foo new<T>MyClass() -> newMyClass() The fix makes sure that for these 3 cases at least a space is added when the opening bracket is right after the last token. Test cases have been added for the problematic scenarios.
I would fix it for 3.1.1 as the symptoms look bad. David - pls review the change
Martin's patch seems very good.
released in 3.1.1 and 3.2 streams > 20050712
Verified in M20050804-1200 and I20050808-2000.
*** Bug 108209 has been marked as a duplicate of this bug. ***