Community
Participate
Working Groups
Using ASTRewrite, I am unable to set/remove static flag of import declaration correctly. Example import declarations: import static org.eclipse.ClassA.A; import org.eclipse.ClassB.B; I am trying to make second import static, first non-static using the following code: rewriter.set(importDeclaration1, ImportDeclaration.STATIC_PROPERTY, false, null); rewriter.set(importDeclaration2, ImportDeclaration.STATIC_PROPERTY, true, null); The output after rewrite: import static org.eclipse.ClassA.A; static import org.eclipse.ClassB.B; "static" keyword is not removed from first import declaration and is added incorrectly to the second import declaration. According to JLS 3, "static" keyword should follow "import" keyword (http://java.sun.com/docs/books/jls/third_edition/html/packages.html#26741).
Created attachment 54481 [details] Test case illustrating the problem
fixed > 20070427
Martin, I can't run the test as I got a compilation error and didn't see a test in our model tests corresponding to this bug. May you verify it for us, please? Thanks
I finally found how to fix the compilation error (replace the false/true parameter value with Boolean.FALSE/Boolean.TRUE objects). Verified for 3.3 M7 using build I20070427-0800.
Regression test added in org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingTypeDeclTest.testImportDeclaration()