apache / apache/netbeans

Java Formatting Import option

Open
#8,861 0 comments 2 reactions 0 assignees View on GitHub
Java kind:feature needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Description

An option to combine imports with different Java packages together, separated from other imports.

### Use case/motivation

According to the Checkstyle I need to group Java packages: `java.*` and `javax.*` together, without blank line between them.
The import layout I need:
1. import static ...;
2. (blank line);
3. import java.\*;
4. import javax.\*;
5. (blank line);
6. import org.*;

The way I try to organize imports is specifying groups inside section "Import Layout" (Tools - Options - Editor - Formatting):
- all other imports (static);
- java., javax.;
- all other imports.

_(with checked options "Separate Groups" and "Separate Static Imports")_

After applying changes, Netbeans splits "java., javax." into two different lines, so it's not possible to combine them together.

### Related issues

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by locating the Java formatter's Import Layout implementation and its existing import-grouping tests. Done means allowing java.* and javax.* to remain in one group without a blank line, while preserving separate static and other-import groups.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.