Bug 44035 [formatting] Error in formatting parts of java code snippets in comment
This is for build I20030930. The Java code formatter options are set to Format java code snippets. Taking the following comment: /** * The following is a Java snipet. * * <pre> * while ((size = availableSize(stream, size)) > 0) { * System.out.println("available"); * } * </pre> */ public void test() { } And trying to format it here is what we got: /** * The following is a Java snipet. * * <pre> * while ((size = availableSize(stream, size)) > 0) { * System.out.println("available"); } * </pre> */ public void test() { }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingStrategy.java
* @param region
	 *                  Comment region which owns the line
	 * @param offset
	 *                  Offset where to determine the indentation
	 * @return The indentation of the line
	 */
	public static String getLineIndentation(final IDocument document, final CommentRegion region, final int offset) {
		String result= ""; 
		try {
			final IRegion line= document.getLineInformationOfOffset(offset);
			final int begin= line.getOffset();
			final int end= Math.min(offset, line.getOffset() + line.getLength());
			boolean useTab= JavaCore.TAB.equals(JavaCore.getOption(JavaCore.FORMATTER_TAB_CHAR));
			result= region.stringToIndent(document.get(begin, end - begin), useTab);
		} catch (BadLocationException exception) {
			
		}
		return result;
	}
	/**
	 * Content formatter with which this formatting strategy has been
	 * registered
	 */
	private final ContentFormatter2 fFormatter;
	
	private final LinkedList fPartitions= new LinkedList();
	/**
	 * Creates a new comment formatting strategy.
	 * 
	 * @param formatter