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
}
				
				try {		
					ITypedRegion partition= document.getPartition(offset);
					if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && partition.getOffset() != offset)
						return;
					final char character= event.character;
					final char closingCharacter= getPeerCharacter(character);		
					final StringBuffer buffer= new StringBuffer();
					buffer.append(character);
					buffer.append(closingCharacter);
					document.replace(offset, length, buffer.toString());
					LinkedPositionManager manager= new LinkedPositionManager(document);
					manager.addPosition(offset + 1, 0);
					fOffset= offset;
					fLength= 2;
			
					LinkedPositionUI editor= new LinkedPositionUI(sourceViewer, manager);
					editor.setCancelListener(this);
					editor.setExitPolicy(new ExitPolicy(closingCharacter));
					editor.setFinalCaretOffset(offset + 2);
					editor.enter();
					IRegion newSelection= editor.getSelectedRegion();
					sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
	
					event.doit= false;
				} catch (BadLocationException e) {
				}
				break;	
			}