Bug 165783

Summary: [ast rewrite] Import declaration static property can not be set correctly
Product: [Eclipse Project] JDT Reporter: Dmitry Denisov <ddenisov>
Component: CoreAssignee: Martin Aeschlimann <martinae>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: marcelop
Version: 3.3   
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Test case illustrating the problem none

Description Dmitry Denisov CLA 2006-11-24 09:51:19 EST
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).
Comment 1 Dmitry Denisov CLA 2006-11-24 09:52:24 EST
Created attachment 54481 [details]
Test case illustrating the problem
Comment 2 Martin Aeschlimann CLA 2007-04-27 12:22:02 EDT
fixed > 20070427
Comment 3 Frederic Fusier CLA 2007-04-27 13:55:31 EDT
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
Comment 4 Frederic Fusier CLA 2007-04-28 10:54:07 EDT
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.
Comment 5 Olivier Thomann CLA 2007-04-28 11:11:54 EDT
Regression test added in org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingTypeDeclTest.testImportDeclaration()