Bug 304415 - [organize imports] Organization of static imports in Java is not configurable
Summary: [organize imports] Organization of static imports in Java is not configurable
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-02 15:22 EST by Vance Vagell CLA
Modified: 2010-08-24 14:57 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vance Vagell CLA 2010-03-02 15:22:24 EST
Build Identifier: I20090611-1540

The Java "Organize imports" command (shift-ctrl-o) always pulls static imports out to the top, which breaks the code standards of some teams. 

There should be an option for static imports to be interleaved with other imports, alphabetically.

You can get to the relevant settings screen by:

1) Window -> Preferences
2) Java -> Code Style -> Organize Imports

There are some static import settings there, but nothing about interleaving them with other imports.

The workaround is very tedious: manually cut/paste the static imports back into the import list each time you organize it (or don't use organize imports at all).

Reproducible: Always

Steps to Reproduce:
1. Add several non-static Java imports to a .java file
2. Add several static Java imports to the same file
3. Press ctrl-shift-o to organize imports
4. Notice that the static imports are pulled out of the alphabetic import list, into there own section on top
Comment 1 Markus Keller CLA 2010-03-07 19:19:28 EST
ImportRewrite would have to support this. Low priority for me, since the import order is semantically irrelevant.
Comment 2 Will Horn CLA 2010-03-23 17:05:27 EDT
I need imports in the following format:

import com.example.my.Class; 
import com.example.some.Stuff; 
import static com.example.my.static.Import; 

import org.other.company.Class 
import org.other.some.Stuff; 
import static org.other.static.Import;

Eclipse almost can do this (by creating import groups for the static imports and interleaving with the regular ones), but it adds an extra line between the regular and corresponding static import groups.

Clearly there are so many different styles that Eclipse doesn't want to be hacking in support for every request.  But handling semantically irrelevant issues is an important feature that IDE's provide, allowing developers to ignore them.  So it's critical to be able to customize it to match other IDE's, tools, and company wide style guidelines.

I'll be working on a patch to include static imports at the end of the corresponding import group, and it probably won't be too hard to include them interleaved in alphabetical order.