Community
Participate
Working Groups
I'am trying to create a class in runtime using packageFragment.createCompilationUnit and the when I am trying to create static import with : compilationUnit.createImport(importName, null, Flags.AccStatic, null); all I get is normal import instead of static one.. when I dig into the code I can see that class org.eclipse.jdt.internal.core.CompilationUnit has a method public IImportDeclaration createImport(String importName, IJavaElement sibling, int flags, IProgressMonitor monitor) throws JavaModelException { // TODO (jerome) - consult flags to create static imports CreateImportOperation op = new CreateImportOperation(importName, this); if (sibling != null) { op.createBefore(sibling); } op.runOperation(monitor); return getImport(importName); } which as You can see doesn't use the flags parameter..
Created attachment 42606 [details] Proposed fix This patch is also fixing the fact that the check for duplicate imports doesn't work as expected.
Created attachment 42607 [details] Regression tests
Jérôme, please review the patch. Setting as 3.2.1 as the API needs to be fixed.
Created attachment 44909 [details] Improved fix and regression tests
Fix and tests released for 3.3M1 in HEAD and released for 3.2.1 in TARGET_321 branch.
Verified for 3.3 M1 using build I20060807-0010.
Verified for 3.2.1 using build M20060908-1655.