Bug 43228 Encoding Support for Java editor broken
I20030916 This has been broken with the introduction of ExtendedTextEditor.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
} catch (BadLocationException exception) {
					
				}
			}
			viewer.setSelectedRange(offset, length);
			viewer.doOperation(ISourceViewer.FORMAT);
			viewer.restoreSelection();
		}
		/*
		 * @see org.eclipse.jface.action.IAction#run()
		 */
		public void run() {
			final JavaSourceViewer viewer= (JavaSourceViewer)getSourceViewer();
			if (viewer.isEditable()) {
				final IDocument document= viewer.getDocument();
				final Point selection= viewer.getSelectedRange();
				try {
					if (selection.y == 0) {
						final String type= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, selection.x);
						if (type.equals(IJavaPartitions.JAVA_DOC) || type.equals(IJavaPartitions.JAVA_MULTI_LINE_COMMENT) || type.equals(IJavaPartitions.JAVA_SINGLE_LINE_COMMENT)) {
							final ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, selection.x);
							format(viewer, partition.getOffset(), partition.getLength(), false);
						} else if (type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
							try {
								final IJavaElement element= getElementAt(selection.x, true);
								if (element != null && element.exists()) {
									ISourceRange range= null;
									final int kind= element.getElementType();
									if (kind == IJavaElement.TYPE || kind == IJavaElement.METHOD || kind == IJavaElement.INITIALIZER) {
										final ISourceReference reference= (ISourceReference)element;