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/ui/text/JavaSourceViewerConfiguration.java
* @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer)
	 */
	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
		return new String[] { 
			IDocument.DEFAULT_CONTENT_TYPE, 
			IJavaPartitions.JAVA_DOC, 
			IJavaPartitions.JAVA_MULTI_LINE_COMMENT, 
			IJavaPartitions.JAVA_SINGLE_LINE_COMMENT,
			IJavaPartitions.JAVA_STRING,
			IJavaPartitions.JAVA_CHARACTER
		};
	}
	
	/*
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
	 */
	public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
		if (fDocumentPartitioning != null)
			return fDocumentPartitioning;
		return super.getConfiguredDocumentPartitioning(sourceViewer);
	}
	
	/*
	 * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
	 */
	public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
		final ContentFormatter2 formatter= new ContentFormatter2();
		formatter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
		IFormattingStrategy strategy= new JavaFormattingStrategy(sourceViewer);
		formatter.setFormattingStrategy(strategy);