Bug 21047 code formatter availability inconsistent
Sometimes the hotkey (ctrl-shift-f) and the menu entry for formatting the source code are disabled, while the entry in the context menu is enabled and works as expected. I didn't find any patterns on when this occurs till now.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
}
		
		/*
		 * @see org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean)
		 */
		public void exit(boolean accept) {
			if (accept)
				return;
			
			try {
				final ISourceViewer sourceViewer= getSourceViewer();
				IDocument document= sourceViewer.getDocument();
				document.replace(fOffset, fLength, null);
			} catch (BadLocationException e) {
			}
		}
	}
	
	protected AnnotationType getAnnotationType(String preferenceKey) {
		Iterator e= ANNOTATION_MAP.keySet().iterator();
		while (e.hasNext()) {
			AnnotationType type= (AnnotationType) e.next();
			AnnotationInfo info= (AnnotationInfo) ANNOTATION_MAP.get(type);
			if (info != null) {
				if (preferenceKey.equals(info.fColorPreference) || preferenceKey.equals(info.fEditorPreference) || preferenceKey.equals(info.fOverviewRulerPreference)) 
					return type;
			}
		}
		return null;
	}