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
default:
				return null;
			}						
		}
	}
	
	private class BracketInserter implements VerifyKeyListener, LinkedPositionUI.ExitListener {
		
		private boolean fCloseBrackets= true;
		private boolean fCloseStrings= true;
		
		private int fOffset;
		private int fLength;
		public void setCloseBracketsEnabled(boolean enabled) {
			fCloseBrackets= enabled;
		}
		public void setCloseStringsEnabled(boolean enabled) {
			fCloseStrings= enabled;
		}
		private boolean hasIdentifierToTheRight(IDocument document, int offset) {
			try {
				int end= offset;
				IRegion endLine= document.getLineInformationOfOffset(end);
				int maxEnd= endLine.getOffset() + endLine.getLength();
				while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
					++end;
				return end != maxEnd && Character.isJavaIdentifierPart(document.getChar(end));
			} catch (BadLocationException e) {
				
				return true;