Eclipse 에서 File Decorator 로 org.eclipse.ui.decorators extension point 를 확장하고 ILightweightLabelDecorator 을 implements 한 경우 파일에 Warning 이나 Error 가 발생하여도 Package Explorer 에서 Marker 가 보이지 않는 경우가 있다.


 이 경우 ILightweightLabelDecorator 인터페이스 구현 부분을 ILabelDecorator 인터페이스로 바꾸어 재구현하면 위의 현상이 나타나지 않는데, ILabelDecorator 는 ILightweightLabelDecorator 보다 퍼포먼스가 많이 좋지 않기 때문에 완전한 해결책이라고 볼수가 없다.


 이런 현상은 ILightweightLabelDecorator 버그로 bugzilla 에 보고 되어있기도 하다.


 이 경우 Preference 의  File Icon Based On Content Analysis 옵션을 체크 해제하면 문제가 해결되는 경우가 있는데 옵션해제는 다음과 같은 경로로 하면 마커가 제대로 나오는 경우가 있다.

  • Eclipse > Window > Preferences > Genaral > Appearance > Label Decorations > "File Icon Based On Content Analysis" 부분을 해제

File Icon Based On Content Analysis 의 구현은 다음과 같은데 ILightweightLabelDecorator 인터페이스를 구현하고 있는데 이부분에 버그가 있는것 같다.

  • File Icon Based On Content Analysis
    • org.eclipse.ui.ContentTypeDecorator 의 확장점으로 구현
    • public class ContentTypeDecorator implements ILightweightLabelDecorator  
      • ILightweightLabelDecorator 을 implement 하고
    • 파일의 Decoration 으로 파일기본 ContentDescription 이 있다면 이정보를 바탕으로 Decorate


프로그래밍적으로 eclipse 의 Preference 에서 이부분을 uncheck 된 상태로 시작 하려면 다음과 같이 코드를 수정한다.

  • org.eclipse.ui.startup extension point 를 확장하여 워크벤치가 로딩될때 무조건 호출되도록 StartUp class 를 생성
  • 위에서 생성한 StartUp class 에서 다음과 같이 File Icon Based On Content Analysis 부분이 uncheck 되도록 수정한다.
public void earlyStartup() {
    DecoratorDefinition[] definitions = WorkbenchPlugin.getDefault().getDecoratorManager().getAllDecoratorDefinitions();
    for (DecoratorDefinition decoratorDef : definitions) {
        if (decoratorDef.getId().equalsIgnoreCase("org.eclipse.ui.ContentTypeDecorator")) {
            decoratorDef.setEnabled(false);
            break;
        }
    }
}




Posted by leechwin
,