Fixing Eclipse 'Organize Imports' Annoyance For Static Imports

Static import 문에 대한 이클립스의 ‘Organize Import’ 문제 해결하기

CTRL+SHIFT+O is probably the most pressed shortcut in Eclipse JDT. It cleans up any unused imports, expands ugly asterisks, and reorganizes the import statements in order. It was very nice until asterisks were considered ugly. Since static imports are introduced in Java 5, things have been changed dramatically. Who will ever want his or her static import statement with an asterisk to be expanded? Unfortunately, Eclipse JDT gets rid of the asterisks in static imports mercilessly.

CTRL+SHIFT+O는 아마도 이클립스 JDT에서 가장 많이 눌리는 단축키일 것입니다. 이 단축키를 누르면 더이상 쓰이지 않는 import 문은 사라지고, 보기 흉한 별표 import 문은 전개되고, import문은 순서에 맞게 재정렬됩니다. 별표 import 문이 보기 흉하다고 생각될 때까지는 참 좋았지요. Static import 문이 Java 5에 등장한 이후로 상황이 완전히 바뀌었습니다. 누가 별표 static import 문이 전개되길 상상이나 했겠어요? 안타깝게도 이클립스 JDT는 무자비하게 static import 문의 별표까지 없애버립니다.

What is fortunate though is that there’s an option that changes this default behavior.

그나마 다행스러운 것은 이 디폴트 값을 바꾸는 옵션이 있다는 겁니다.

  1. Choose ‘Window -> Preferences…’ menu.
  2. Choose ‘Java -> Code Style -> Organize Imports’ in the left pane.
  3. Set the ‘Number of static imports needed for .*’ to ‘1’ in the right pane.
  4. Click ‘OK’ button.
  1. ‘Window -> Preferences…’ 메뉴를 선택합니다.
  2. 왼쪽에서 ‘Java -> Code Style -> Organize Imports’를 선택합니다.
  3. 오른쪽에서 ‘Number of static imports needed for .*’를 ‘1’로 설정합니다.
  4. ‘OK’ 버튼을 누릅니다.

4 Comments Fixing Eclipse 'Organize Imports' Annoyance For Static Imports

Comments are closed.