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
Iterator e= new ProblemAnnotationIterator(model, false);
		while (e.hasNext()) {
			
			IProblemAnnotation a= (IProblemAnnotation) e.next();
			if (a.hasOverlay() || !a.isProblem())
				continue;
				
			Position p= model.getPosition((Annotation) a);
			if (!p.includes(offset)) {
				
				int currentDistance= 0;
				
				if (forward) {
					currentDistance= p.getOffset() - offset;
					if (currentDistance < 0)
						currentDistance= endOfDocument - offset + p.getOffset();
				} else {
					currentDistance= offset - p.getOffset();
					if (currentDistance < 0)
						currentDistance= offset + endOfDocument - p.getOffset();
				}						
										
				if (nextError == null || currentDistance < distance) {
					distance= currentDistance;
					nextError= a;
					nextErrorPosition= p;
				}
			}
		}