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/JavaDocRegion.java
if (!isLastCode && isCurrentCode)
					document.addPosition(CODE_POSITION_CATEGORY, new Position(index + next.getOffset() + next.getLength()));
				else if (isLastCode && !isCurrentCode)
					document.addPosition(CODE_POSITION_CATEGORY, new Position(index + previous.getOffset()));
			} catch (BadLocationException exception) {
				
			} catch (BadPositionCategoryException exception) {
				
			}
			if (previous.hasAttribute(COMMENT_IMMUTABLE) && next.hasAttribute(COMMENT_IMMUTABLE) && !isLastCode)
				return false;
		}
		return true;
	}
	/*
	 * @see org.eclipse.jdt.internal.ui.text.comment.CommentRegion#finishRegion(java.lang.String)
	 */
	protected void finalizeRegion(final String indentation) {
		final String test= indentation + MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX;
		final StringBuffer buffer= new StringBuffer();
		buffer.append(test);
		buffer.append(' ');
		final String delimiter= buffer.toString();
		try {
			final ILineTracker tracker= new ConfigurableLineTracker(new String[] { getDelimiter()});
			tracker.set(getText(0, getLength()));
			int index= 0;
			String content= null;
			IRegion range= null;
			for (int line= tracker.getNumberOfLines() - 3; line >= 1; line--) {