Bug 165783 - [ast rewrite] Import declaration static property can not be set correctly
Summary: [ast rewrite] Import declaration static property can not be set correctly
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-24 09:51 EST by Dmitry Denisov CLA
Modified: 2007-04-28 11:11 EDT (History)
1 user (show)

See Also:


Attachments
Test case illustrating the problem (2.53 KB, text/plain)
2006-11-24 09:52 EST, Dmitry Denisov CLA
no flags Details

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