Skip to content

Shorten fully qualified type names to simple names with imports - #94

Merged
bnaudts merged 2 commits into
develfrom
shorten-qualified-names
Nov 4, 2026
Merged

bnaudts merged 2 commits into
develfrom
shorten-qualified-names

Conversation

@tomtourwe

Copy link
Copy Markdown

Replaces type names written out in full in the code by their simple name plus an import, for example
java.util.List<String> list = new java.util.ArrayList<>() becomes List<String> list = new ArrayList<>()
with import java.util.ArrayList; and import java.util.List;. The change is mechanical, made with an automated
import refactoring.

The two commits

  1. Imports cleaned up (da48dee3): unused imports are removed, and import blocks that were in no consistent order are
    sorted. No code line changes.
  2. Qualified names shortened (cbed5c20): a type name written in full becomes its simple name and the import is
    added. A nested type keeps its enclosing type (java.util.Map.Entry becomes Map.Entry, importing
    java.util.Map); a static member keeps its class (java.util.Collections.emptyList() becomes
    Collections.emptyList()); no static import is added. Comments, javadoc and string literals are left as they are.

A name stays qualified where its simple name would mean another type in that file: another type of that simple
name is imported, declared or written in the file, or two on-demand imports would both provide it.

Verification

  • Every Java source set compiles.
  • ./gradlew test passes, with no failures.

Where qualified names are kept

Each link points to a line where a type name is still written in full, because its simple name already means another
type in that file (for example org.slf4j.Logger beside an import of ch.qos.logback.classic.Logger).

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


Tom Tourwe seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@bnaudts
bnaudts merged commit b791eee into devel Nov 4, 2026
1 check failed
@bnaudts
bnaudts deleted the shorten-qualified-names branch November 4, 2026 17:04
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants