Skip to content

Add import module support to ImportRewrite#4309

Closed
jjohnstn wants to merge 3 commits into
eclipse-jdt:masterfrom
jjohnstn:moduleimportrewriter
Closed

Add import module support to ImportRewrite#4309
jjohnstn wants to merge 3 commits into
eclipse-jdt:masterfrom
jjohnstn:moduleimportrewriter

Conversation

@jjohnstn
Copy link
Copy Markdown
Contributor

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

- keep a map of modules and exported packages
- when deciding whether an import is needed, check the module
  package lists
- fixes eclipse-jdt#4298
@jjohnstn jjohnstn self-assigned this Aug 13, 2025
@jjohnstn jjohnstn added bug Something isn't working enhancement New feature or request labels Aug 13, 2025
@jjohnstn
Copy link
Copy Markdown
Contributor Author

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.

@iloveeclipse
Copy link
Copy Markdown
Member

Sorry Jeff, I'm away of PC till the end of the month

@jjohnstn
Copy link
Copy Markdown
Contributor Author

@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.

@stephan-herrmann
Copy link
Copy Markdown
Contributor

@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?

@jjohnstn
Copy link
Copy Markdown
Contributor Author

@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.

@stephan-herrmann
Copy link
Copy Markdown
Contributor

@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.

@stephan-herrmann
Copy link
Copy Markdown
Contributor

Issue labels tell me that this is a bug enhancement. That's an interesting concept :)

@stephan-herrmann
Copy link
Copy Markdown
Contributor

This feature was shipped via #4313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants