Bug 51451 [formatting] unstable comment formatting
- open TestCase - in the editor set the carret in a method declaration's name (e.g., ru|n()) - press CTRL-SHIFT-F multiple times -> the formatting changes in each `format'
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaFormattingStrategy.java
* If the number of lines is reduced, <code>partition</code> is also trimmed off its last
	 * (emtpy) line.
	 * 
	 * @param document the document to format
	 * @param toFormat the position describing the range to be formatted
	 * @param partition the position describing the original range
	 * @throws BadLocationException
	 */
	private void stripTrailingWS(final IDocument document, Position toFormat, Position partition) throws BadLocationException {
		
		int offset= toFormat.getOffset();
		int length= toFormat.getLength();
		int line= document.getLineOfOffset(offset + length);
		for (int i= length; i > 0; i--) {
			if (!Character.isWhitespace(document.getChar(offset + i - 1)))
				break;
			toFormat.length--;
		}
		if (document.getLineOfOffset(toFormat.length + toFormat.offset) != line) {
			IRegion region= document.getLineInformation(line - 1);
			int endOfLine= region.getOffset() + region.getLength();
			partition.setLength(endOfLine - partition.offset);
		}
	}
	/**
	 * Returns the offset of the line in <code>document</code> that is the
	 * <code>leadingEmptyLine</code>th empty line before any non-WS comes in
	 * <code>document</code>.
	 * 
	 * @param leadingEmptyLines the number of empty lines to leave