Skip to content

[organize imports] Add preferences to keep existing star imports and to disable collapsing#3056

Open
m-froehlich wants to merge 1 commit into
eclipse-jdt:masterfrom
m-froehlich:feature/organize-imports-keep-ondemand
Open

[organize imports] Add preferences to keep existing star imports and to disable collapsing#3056
m-froehlich wants to merge 1 commit into
eclipse-jdt:masterfrom
m-froehlich:feature/organize-imports-keep-ondemand

Conversation

@m-froehlich

Copy link
Copy Markdown

Add two Organize Imports preferences, wired through CodeStyleConfiguration to the new ImportRewrite options:

  • "Keep existing star (.*) imports" (default off): existing on-demand imports are preserved instead of being expanded into single imports.

  • "Collapse single imports into star (.*) imports when the threshold is reached" (default on): when unchecked, the on-demand thresholds are ignored and no new on-demand import is created from single imports.

The two checkboxes are shown next to the on-demand threshold fields on the Organize Imports preference page. The default values reproduce the current behaviour.

Note: this depends on the new ImportRewrite API in eclipse.jdt.core (setKeepExistingOnDemandImports / setCollapseSingleImportsToOnDemand).

What it does

How to test

Author checklist

…to disable collapsing

Add two Organize Imports preferences, wired through CodeStyleConfiguration
to the new ImportRewrite options:

- "Keep existing star (.*) imports" (default off): existing on-demand
  imports are preserved instead of being expanded into single imports.

- "Collapse single imports into star (.*) imports when the threshold is
  reached" (default on): when unchecked, the on-demand thresholds are
  ignored and no new on-demand import is created from single imports.

The two checkboxes are shown next to the on-demand threshold fields on the
Organize Imports preference page. The default values reproduce the current
behaviour.

Note: this depends on the new ImportRewrite API in eclipse.jdt.core
(setKeepExistingOnDemandImports / setCollapseSingleImportsToOnDemand).

Signed-off-by: m-froehlich <108868519+m-froehlich@users.noreply.github.com>
@m-froehlich

Copy link
Copy Markdown
Author

This PR depends on eclipse-jdt/eclipse.jdt.core#5175, which adds the new ImportRewrite API used here (setKeepExistingOnDemandImports and setCollapseSingleImportsToOnDemand).

The current build failure is expected: org.eclipse.jdt.core.manipulation compiles against that new API, which is not yet part of the target platform. It should resolve once #5175 is merged and picked up by a build. Suggested order: review/merge #5175 first, then re-trigger this build.

The tests of the changed bundle itself already pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant