Bug 44721 Source formatting is very slow
The code formatting of longer java source files in M4 is extremely slow.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingStrategy.java
* @param viewer
	 *                  The source viewer where to apply the formatting strategy
	 */
	public CommentFormattingStrategy(final ContentFormatter formatter, final ISourceViewer viewer) {
		super(viewer);
		fFormatter= formatter;
	}
	/*
	 * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#format()
	 */
	public void format() {
		super.format();
		Assert.isLegal(fPartitions.size() > 0);
		final IDocument document= getViewer().getDocument();
		final TypedPosition position= (TypedPosition)fPartitions.removeFirst();
		try {
			final ITypedRegion partition= TextUtilities.getPartition(document, fFormatter.getDocumentPartitioning(), position.getOffset());
			final String type= partition.getType();
			position.offset= partition.getOffset();
			position.length= partition.getLength();
			final Map preferences= getPreferences();
			final boolean format= preferences.get(PreferenceConstants.FORMATTER_COMMENT_FORMAT) == IPreferenceStore.TRUE;
			final boolean header= preferences.get(PreferenceConstants.FORMATTER_COMMENT_FORMATHEADER) == IPreferenceStore.TRUE;
			if (format && (header || position.getOffset() != 0 || !type.equals(IJavaPartitions.JAVA_DOC))) {
				final CommentRegion region= CommentObjectFactory.createRegion(this, position, TextUtilities.getDefaultLineDelimiter(document));
				final String indentation= getLineIndentation(document, region, position.getOffset());
				final Map partitioners= TextUtilities.removeDocumentPartitioners(document);
				region.format(indentation);
				TextUtilities.addDocumentPartitioners(document, partitioners);
			}