Add import module support to ImportRewrite#4309
Conversation
- keep a map of modules and exported packages - when deciding whether an import is needed, check the module package lists - fixes eclipse-jdt#4298
|
Hi @iloveeclipse This PR is need to get Organize imports working with import module. If you could review this in conjunction with eclipse-jdt/eclipse.jdt.ui#2431 that would be great. I couldn't get an ImportRewrite specific test working due to some set up issues (creating the AST can't find java.lang.object...etc..). My local Eclipse is running Java 22. My UI test set up a Java 24 project with a new RT_STUBS24 and it works fine. If you are ok with getting this in for 2025-09, that would be great or if you want to wait until RC1 or 2025-12 M1, that's ok too. |
|
Sorry Jeff, I'm away of PC till the end of the month |
|
@stephan-herrmann Any objections to merging this patch? It adds support for import module and works in conjunction with a JDT UI patch which adds support to Organize Imports. |
I don't have the time to review this in time for M3, but wouldn't it much better match the branch BETA_JAVA25? Module imports will be a standard feature only in 25. Shifting to the branch will also give us a bit more time. WDYT? |
|
@stephan-herrmann Adding it to the BETA_JAVA25 branch is a good idea, but it has been in preview for a while so it would be nice to offer it as it would also help to know any cleanups/quick-fixes that don't do the right thing. Current behavior is pretty sketchy. An end user recently opened a bug on the compact main support because of it. I'll work on getting a test case ready and try to submit it for 2025-12 M1. |
FYI, development in BETA_JAVA25 will end before 2025-12 M1 :), i.e., we will release the final patch feature for 25 on or near Java 25 GA (Sept 16), and then merge the branch back to master. |
|
Issue labels tell me that this is a bug enhancement. That's an interesting concept :) |
|
This feature was shipped via #4313 |
What it does
Adds support for import module statements to ImportRewrite
How to test
Will require corresponding changes to OrganizeImportsOperation for users to test. A new test is being worked on but at this point, the test is not able to generate an AST when done via an ICompilationUnit.
Author checklist