### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03.java --- workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03.java 13 May 2008 17:06:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,14 +0,0 @@ -package b231297; - -public class X03 { - - /** - * @return an inline tag: - * {@link String inline tag - * description on more than - * one line } - */ - public String foo() { - return null; - } -} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X02.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X02.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/default/X02.java --- workspace/FormatterJavadoc/test/bugs/b231297/out/default/X02.java 13 May 2008 17:06:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,13 +0,0 @@ -package b231297; - -public class X02 { - - /** - * @return an inline tag: - * {@link String inline tag - * description} - */ - public String foo() { - return null; - } -} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/default/X.java --- workspace/FormatterJavadoc/test/bugs/b231297/out/default/X.java 13 May 2008 17:06:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,13 +0,0 @@ -package b231297; - -public class X { - - /** - * @return an inline tag: - * {@link String} inside the - * description. - */ - public String foo() { - return null; - } -} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03b.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03b.java --- workspace/FormatterJavadoc/test/bugs/b231297/out/default/X03b.java 13 May 2008 17:06:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,14 +0,0 @@ -package b231297; - -public class X03b { - - /** - * @return an inline tag: - * {@link String inline tag - * description on more than - * one line } - */ - public String foo() { - return null; - } -} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X01.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/default/X01.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/default/X01.java --- workspace/FormatterJavadoc/test/bugs/b231297/out/default/X01.java 13 May 2008 17:06:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,12 +0,0 @@ -package b231297; - -public class X01 { - - /** - * @return tag: - * {@link java.lang.String} - */ - public String foo() { - return null; - } -} Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java,v retrieving revision 1.16 diff -u -r1.16 FormatterCommentsMassiveTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java 14 May 2008 16:59:26 -0000 1.16 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java 15 May 2008 13:20:37 -0000 @@ -18,7 +18,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.StringTokenizer; import junit.framework.AssertionFailedError; import junit.framework.ComparisonFailure; @@ -34,7 +33,6 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.parser.Scanner; -import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; import org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil; import org.eclipse.jdt.internal.core.util.SimpleDocument; import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; @@ -134,7 +132,7 @@ boolean hasSpaceFailure; private final static boolean DEBUG_TESTS = "true".equals(System.getProperty("debugTests")); private final static String DIR = System.getProperty("dir"); //$NON-NLS-1$ - private final static boolean COMPARE = DefaultCodeFormatterConstants.TRUE.equals(System.getProperty("compare")); //$NON-NLS-1$ + private final static String COMPARE = System.getProperty("compare"); //$NON-NLS-1$ private final static int IGNORE_SPACES; private final static int ALL_SPACES = 1; // ignore all spaces private final static int LINES_LEADING_SPACES = 2; // ignore all spaces at the beginning of all lines @@ -266,7 +264,7 @@ int seFailures = this.expectedFailures.size(); int swFailures = this.whitespacesFailures.size(); int slwFailures = this.leadingWhitespacesFailures.size(); - String failuresType = COMPARE ? "than old formatter" : "when reformatting"; + String failuresType = COMPARE != null ? "than old formatter" : "when reformatting"; System.out.println(); if (sFailures > 0) { System.out.println(sFailures+" files has still different output while reformatting!"); @@ -328,9 +326,9 @@ } } catch (ComparisonFailure cf) { - if (COMPARE) { - String trimmedExpected; - String trimmedActual; + if ("true".equals(COMPARE)) { + String trimmedExpected = expected; + String trimmedActual = actual; switch (IGNORE_SPACES) { case ALL_SPACES: trimmedExpected = ModelTestsUtil.removeWhiteSpace(expected); @@ -354,14 +352,6 @@ return; } break; - default: - trimmedExpected = filterFormattingInComments(expected); - trimmedActual= filterFormattingInComments(actual); - if (trimmedExpected.equals(trimmedActual)) { - this.whitespacesFailures.add(this.path); - return; - } - break; } if (DEBUG_TESTS && ASSERT_EQUALS_STRINGS) { assertEquals(message, trimmedExpected, trimmedActual); @@ -387,10 +377,21 @@ DefaultCodeFormatter codeFormatter = codeFormatter(); String source = new String(org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.file, null)); try { - String actualResult = runFormatter(codeFormatter, source, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, 0, source.length(), null); - if (!this.hasSpaceFailure && COMPARE) { - String expectedResult = expectedFormattedSource(source); - assertLineEquals(actualResult, source, expectedResult, false); + if ("comments".equals(COMPARE)) { + String[] oldFormattedComments = formattedComments(source, true); + String[] newFormattedComments = formattedComments(source, false); + int length = oldFormattedComments == null ? 0 : oldFormattedComments.length; + this.abortOnFailure = false; + assumeEquals("Unexpected number of comments!", length, newFormattedComments == null ? 0 : newFormattedComments.length); + for (int i=0; i 0) { - // Trim leading whitespaces - if (IGNORE_SPACES > 0) { - while (lineStart < length && ScannerHelper.isWhitespace(line.charAt(lineStart))) { - lineStart++; +private String[] formattedComments(String source, boolean old) { + boolean enableNewCommentFormatter = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT; + try { + DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT = !old; + DefaultCodeFormatter codeFormatter = codeFormatter(); + Scanner scanner = new Scanner(true, true, false/*nls*/, ClassFileConstants.JDK1_4/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); + CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil(); + CompilationUnitDeclaration compilationUnitDeclaration = codeSnippetParsingUtil.parseCompilationUnit(source.toCharArray(), getDefaultCompilerOptions(), true); + final TypeDeclaration[] types = compilationUnitDeclaration.types; + int headerEndPosition = types == null ? compilationUnitDeclaration.sourceEnd : types[0].declarationSourceStart; + scanner.setSource(source.toCharArray()); + scanner.lineEnds = codeSnippetParsingUtil.recordedParsingInformation.lineEnds; + int[][] commentsPositions = compilationUnitDeclaration.comments; + int length = commentsPositions == null ? 0 : commentsPositions.length; + String[] formattedComments = new String[length]; + for (int i=0; i 0) { // block comments have positive start position + commentKind = CodeFormatter.K_MULTI_LINE_COMMENT; + } else { + commentStart = -commentStart; + commentKind = CodeFormatter.K_SINGLE_LINE_COMMENT; } } - // Search if a comment starts - int commentKind = 0; - int idx = line.indexOf('/', lineStart); - if (idx >= 0 && (idx+1) < length) { - idx++; - char ch = line.charAt(idx++); - switch (ch) { - case '/': - commentKind = 1; // line comment - break; - case '*': - commentKind = 2; // block comment - if (idx < length && line.charAt(idx) == '*') { - commentKind = 3; // javadoc comment - idx++; - } - break; - } - if (commentKind != 0) { - // Enter a comment - switch (IGNORE_SPACES) { - case ALL_COMMENTS_SPACES: - switch (commentKind) { - case 1: - int start = idx; - buffer.append(line.substring(0, start).trim()); - while (true) { - if (start < length) { - while (start < length && ScannerHelper.isWhitespace(line.charAt(start))) { - start++; - } - buffer.append(ModelTestsUtil.removeWhiteSpace(line.substring(start))); - } - line = tokenizer.nextToken(); - length = line.length(); - start = 0; - while (start < length && ScannerHelper.isWhitespace(line.charAt(start))) { - start++; - } - if (start > length+1 || line.charAt(start) != '/' || line.charAt(start+1) != '/') { - buffer.append('\n'); - skipToken = true; - // only gate to break the loop - continue lineLoop; - } - start += 2; - } - case 2: - case 3: - buffer.append(line.substring(0, idx).trim()); - int endComment = line.indexOf("*/"); - if (endComment > 0) { - buffer.append(ModelTestsUtil.removeWhiteSpace(line.substring(0, endComment + 2))); - line = line.substring(endComment+2); - skipToken = true; - continue lineLoop; - } - while (endComment < 0) { - buffer.append(ModelTestsUtil.removeWhiteSpace(line)); - line = tokenizer.nextToken(); - endComment = line.indexOf("*/"); - } - buffer.append(ModelTestsUtil.removeWhiteSpace(line.substring(0, endComment + 2))); - buffer.append('\n'); - continue; - } - break; - case ALL_COMMENTS_LINES_LEADING_SPACES: - switch (commentKind) { - case 1: - int start = idx; - buffer.append(line.substring(0, start).trim()); - while (true) { - if (start < length) { - while (start < length && ScannerHelper.isWhitespace(line.charAt(start))) { - start++; - } - if (start < length) { - buffer.append(line.substring(start)); - } - } - line = tokenizer.nextToken(); - length = line.length(); - start = 0; - while (start < length && ScannerHelper.isWhitespace(line.charAt(start))) { - start++; - } - if (start < length && (line.charAt(start) != '/' || line.charAt(start+1) != '/')) { - buffer.append('\n'); - skipToken = true; - // only gate to break the loop - continue lineLoop; - } - buffer.append(' '); - start += 2; // skip next line starting comment - } - case 3: - case 2: - start = idx; - int endComment = line.indexOf("*/"); - if (endComment > 0) { - buffer.append(line.substring(0, endComment + 2)); - line = line.substring(endComment+2); - skipToken = true; - continue lineLoop; - } - buffer.append(line.substring(0, start).trim()); - while (endComment < 0) { - if (start < length) { - while (start < length && ScannerHelper.isWhitespace(line.charAt(start))) { - start++; - } - if (start < length && ch == '*') { - start++; - while (start < length && ScannerHelper.isWhitespace(line.charAt(start))) { - start++; - } - } - if (start < length) { - buffer.append(line.substring(start)); - } - } - line = tokenizer.nextToken(); - length = line.length(); - endComment = line.indexOf("*/"); - start = 0; - buffer.append(' '); - } - buffer.append(line.substring(0, endComment + 2)); - buffer.append('\n'); - continue; - } - } - } + if (commentStart >= headerEndPosition) { + int indentationLevel = getIndentationLevel(scanner, commentStart); + formattedComments[i] = runFormatter(codeFormatter, source.substring(commentStart, commentEnd), commentKind, indentationLevel, 0, commentEnd - commentStart, LINE_SEPARATOR); } } - if (length > 0 && lineStart > 0 && lineStart < length) { - buffer.append(line.substring(lineStart).trim()); - } else { - buffer.append(line); - } - buffer.append('\n'); + return formattedComments; + } + finally { + DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT = enableNewCommentFormatter; } - return buffer.toString(); } private int getIndentationLevel(Scanner scanner, int position) { @@ -760,7 +637,7 @@ String result = org.eclipse.jdt.internal.core.util.Util.editedString(source, edit); int count = 1; - if (!COMPARE && length == source.length()) { + if (COMPARE == null && length == source.length()) { String previousResult = result; while (count++ < FORMAT_REPEAT) { edit = codeFormatter.format(kind, result, 0, result.length(), indentationLevel, lineSeparator);//$NON-NLS-1$ @@ -793,15 +670,6 @@ return previousResult; } break; - default: - trimmedExpected = filterFormattingInComments(previousResult); - trimmedActual= filterFormattingInComments(result); - if (trimmedExpected.equals(trimmedActual)) { - this.whitespacesFailures.add(this.path); - this.hasSpaceFailure = true; - return previousResult; - } - break; } if (!isExpectedFailure()) { String counterString = counterToString(count); Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v retrieving revision 1.1 diff -u -r1.1 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 13 May 2008 17:06:12 -0000 1.1 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 15 May 2008 13:20:37 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.formatter; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.formatter.CodeFormatter; @@ -17,6 +19,7 @@ public class FormatterCommentsBugsTest extends FormatterCommentsTests { + private static final IPath OUTPUT_FOLDER = new Path("out"); public static Test suite() { return buildModelTestSuite(FormatterCommentsBugsTest.class); @@ -26,6 +29,13 @@ super(name); } +/* (non-Javadoc) + * @see org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests#getOutputFolder() + */ +IPath getOutputFolder() { + return OUTPUT_FOLDER; +} + /** * @bug 228652: [formatter] New line inserted while formatting a region of a compilation unit. * @test Insure that no new line is inserted before the formatted region @@ -109,4 +119,50 @@ formatUnit("bugs.b231297", "X03b.java"); } +/** + * @bug 232138: [formatter] Javadoc header/footer formatting is different than 3.3 + * @test Insure that new formatter do not add/remove stars in header and footer + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=232138" + */ +public void testBug232138a() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X01.java"); +} +public void testBug232138b() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X01b.java"); +} +public void testBug232138c() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X01c.java"); +} +public void testBug232138d() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X01d.java"); +} +public void testBug232138e() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X01e.java"); +} +public void testBug232138f() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X01f.java"); +} +public void testBug232138g() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X02.java"); +} +public void testBug232138h() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X03.java"); +} +public void testBug232138i() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X04.java"); +} +public void testBug232138j() throws JavaModelException { + this.preferences.comment_line_length = 40; + formatUnit("bugs.b232138", "X04b.java"); +} + } Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java,v retrieving revision 1.3 diff -u -r1.3 FormatterCommentsClearBlankLinesTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java 6 May 2008 19:47:34 -0000 1.3 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java 15 May 2008 13:20:37 -0000 @@ -15,6 +15,8 @@ import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; /** @@ -28,6 +30,8 @@ */ public class FormatterCommentsClearBlankLinesTests extends FormatterCommentsTests { +private static final IPath OUTPUT_FOLDER = new Path("out").append("clear_blank_lines"); + public static Test suite() { // Get all superclass tests TestSuite suite = new Suite(FormatterCommentsClearBlankLinesTests.class.getName()); @@ -36,7 +40,6 @@ suite.addTest((Test)tests.get(index)); } return suite; - } public FormatterCommentsClearBlankLinesTests(String name) { @@ -55,7 +58,10 @@ return codeFormatter; } -String getOutputFolder() { - return "clear_blank_lines"; +/* (non-Javadoc) + * @see org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests#getOutputFolder() + */ +IPath getOutputFolder() { + return OUTPUT_FOLDER; } } Index: src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java,v retrieving revision 1.3 diff -u -r1.3 FormatterJavadocDontIndentTagsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java 6 May 2008 19:47:34 -0000 1.3 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java 15 May 2008 13:20:37 -0000 @@ -15,6 +15,8 @@ import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; /** @@ -26,6 +28,8 @@ */ public class FormatterJavadocDontIndentTagsTests extends FormatterCommentsTests { + private static final IPath OUTPUT_FOLDER = new Path("out").append("dont_indent_tags"); + public static Test suite() { // Get all superclass tests TestSuite suite = new Suite(FormatterJavadocDontIndentTagsTests.class.getName()); @@ -51,8 +55,11 @@ return codeFormatter; } -String getOutputFolder() { - return "dont_indent_tags"; +/* (non-Javadoc) + * @see org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests#getOutputFolder() + */ +IPath getOutputFolder() { + return OUTPUT_FOLDER; } } Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java,v retrieving revision 1.17 diff -u -r1.17 FormatterCommentsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 14 May 2008 16:07:10 -0000 1.17 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 15 May 2008 13:20:37 -0000 @@ -20,6 +20,7 @@ import junit.framework.Test; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; @@ -52,6 +53,8 @@ */ public class FormatterCommentsTests extends FormatterRegressionTests { + private static final IPath OUTPUT_FOLDER = new Path("out").append("default"); + public static List ALL_TEST_SUITES = null; DefaultCodeFormatterOptions preferences; @@ -319,7 +322,6 @@ private String getOutputSource(ICompilationUnit unit) throws JavaModelException { IPath outputPath = JAVA_PROJECT.getProject().getLocation().removeLastSegments(1) .append(unit.getParent().getPath()) - .append("out") .append(getOutputFolder()) .append(unit.getElementName()); File outputFile = outputPath.toFile(); @@ -345,8 +347,8 @@ } -String getOutputFolder() { - return "default"; +IPath getOutputFolder() { + return OUTPUT_FOLDER; } /* @@ -1105,9 +1107,6 @@ // 1) fixed wrong max length with '*' formatUnit("wksp.eclipse", "X33.java"); } -public void testWkspEclipse33b() throws JavaModelException { - formatUnit("wksp.eclipse", "X33b.java"); -} public void testWkspEclipse34() throws JavaModelException { // Difference with old formatter: // 1) fixed wrong max length with immutable tags Index: src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java,v retrieving revision 1.3 diff -u -r1.3 FormatterJavadocDontIndentTagsDescriptionTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java 6 May 2008 19:47:34 -0000 1.3 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java 15 May 2008 13:20:37 -0000 @@ -15,6 +15,8 @@ import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; /** @@ -26,6 +28,8 @@ */ public class FormatterJavadocDontIndentTagsDescriptionTests extends FormatterCommentsTests { + private static final IPath OUTPUT_FOLDER = new Path("out").append("dont_indent_descr"); + public static Test suite() { // Get all superclass tests TestSuite suite = new Suite(FormatterJavadocDontIndentTagsDescriptionTests.class.getName()); @@ -51,8 +55,11 @@ return codeFormatter; } -String getOutputFolder() { - return "dont_indent_descr"; +/* (non-Javadoc) + * @see org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests#getOutputFolder() + */ +IPath getOutputFolder() { + return OUTPUT_FOLDER; } } Index: workspace/FormatterJavadoc/test/bugs/b231263/out/default/BadFormattingSample.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231263/out/default/BadFormattingSample.java diff -N workspace/FormatterJavadoc/test/bugs/b231263/out/default/BadFormattingSample.java --- workspace/FormatterJavadoc/test/bugs/b231263/out/default/BadFormattingSample.java 13 May 2008 17:06:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ -package b231263; - -public class BadFormattingSample { - - /** - * @param fields - * the {@link IVariableBinding}'s container to add fields. - * @param typeBinding - * the {@link ITypeBinding} to get fields from. - * @param visibilityMask - * the mask of JDT {@link Modifier} flags, to limit fields - * visibility. If zzzzz yy {@link Modifier#PRIVATE} is included, - * it will be used only for given {@link ITypeBinding}, but not - * for its super classes. - * - * @return the {@link IVariableBinding} for all fields in given - * {@link ITypeBinding} and its super classes. - */ - public void foo() { - } -} Index: workspace/FormatterJavadoc/test/bugs/b231263/out/default/X.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231263/out/default/X.java diff -N workspace/FormatterJavadoc/test/bugs/b231263/out/default/X.java --- workspace/FormatterJavadoc/test/bugs/b231263/out/default/X.java 13 May 2008 17:06:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,16 +0,0 @@ -package b231263; - -public class X { - - /** - * @param str - * the string with a - * description on 2 - * lines. - * - * @return the return description - * which is also on 2 lines - */ - public void foo() { - } -} Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X33b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X33b.java diff -N workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X33b.java --- workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X33b.java 8 May 2008 19:01:55 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,10 +0,0 @@ -package test.wksp.eclipse; - -public class X33b { - - void foo() { - if (true) { - /** ** \r and \n are not valid in string literals *** */ - } - } -} Index: workspace/FormatterJavadoc/test/wksp/eclipse/X33b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/X33b.java diff -N workspace/FormatterJavadoc/test/wksp/eclipse/X33b.java --- workspace/FormatterJavadoc/test/wksp/eclipse/X33b.java 13 May 2008 17:06:12 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,10 +0,0 @@ -package test.wksp.eclipse; - -public class X33b { - - void foo() { - if (true) { - /**** \r and \n are not valid in string literals ****/ - } - } -} Index: workspace/FormatterJavadoc/test/bugs/b232138/X02.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X02.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X02.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X02.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X02 { + + /** + ** + ** Returns true + **/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X04.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X04.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X04.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X04.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +public class X04 { + + void foo() { + if (true) { + /**** string literals ****/ + } + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X03.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X03.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X03.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X03.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +public class X03 { + + /** + ** + ** Returns true if the operator + * expects... + **/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/X03b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/X03b.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/X03b.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b231297/out/X03b.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +package b231297; + +public class X03b { + + /** + * @return an inline tag: + * {@link String inline tag + * description on more than + * one line } + */ + public String foo() { + return null; + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X01e.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X01e.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X01e.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X01e.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +public class X01e { + + /** + * + * Test header/footer. + * + *****************************************/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b231263/out/X.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231263/out/X.java diff -N workspace/FormatterJavadoc/test/bugs/b231263/out/X.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b231263/out/X.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ +package b231263; + +public class X { + + /** + * @param str + * the string with a + * description on 2 + * lines. + * + * @return the return description + * which is also on 2 lines + */ + public void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X01f.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X01f.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X01f.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X01f.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +public class X01f { + + /***************************************** + * + * Returns true + * + *****************************************/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X02.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X02.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X02.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X02.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X02 { + + /** + ** + ** Returns true + **/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/X01.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/X01.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/X01.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b231297/out/X01.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +package b231297; + +public class X01 { + + /** + * @return tag: + * {@link java.lang.String} + */ + public String foo() { + return null; + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X01d.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X01d.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X01d.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X01d.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X01d { + + /** + * + * Test header/footer. + ***/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/X03.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/X03.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/X03.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b231297/out/X03.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +package b231297; + +public class X03 { + + /** + * @return an inline tag: + * {@link String inline tag + * description on more than + * one line } + */ + public String foo() { + return null; + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X01.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X01.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X01.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X01.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X01 { + + /** + * + * Returns true if the operator expects... + **/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X01d.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X01d.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X01d.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X01d.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X01d { + + /** + * + * Test header/footer. + ***/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/X02.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/X02.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/X02.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b231297/out/X02.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +package b231297; + +public class X02 { + + /** + * @return an inline tag: + * {@link String inline tag + * description} + */ + public String foo() { + return null; + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X01e.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X01e.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X01e.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X01e.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +public class X01e { + + /** + * + * Test header/footer. + * + *****************************************/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X01c.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X01c.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X01c.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X01c.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X01c { + + /***************************************** + * + * Test header/footer. + */ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X04.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X04.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X04.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X04.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +public class X04 { + + void foo() { + if (true) { + /**** string literals ****/ + } + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X01f.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X01f.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X01f.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X01f.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +public class X01f { + + /***************************************** + * + * Returns true + * + *****************************************/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b231263/out/BadFormattingSample.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231263/out/BadFormattingSample.java diff -N workspace/FormatterJavadoc/test/bugs/b231263/out/BadFormattingSample.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b231263/out/BadFormattingSample.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,21 @@ +package b231263; + +public class BadFormattingSample { + + /** + * @param fields + * the {@link IVariableBinding}'s container to add fields. + * @param typeBinding + * the {@link ITypeBinding} to get fields from. + * @param visibilityMask + * the mask of JDT {@link Modifier} flags, to limit fields + * visibility. If zzzzz yy {@link Modifier#PRIVATE} is included, + * it will be used only for given {@link ITypeBinding}, but not + * for its super classes. + * + * @return the {@link IVariableBinding} for all fields in given + * {@link ITypeBinding} and its super classes. + */ + public void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X01b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X01b.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X01b.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X01b.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X01b { + + /*** + * + * Test header/footer. + */ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b231297/out/X.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b231297/out/X.java diff -N workspace/FormatterJavadoc/test/bugs/b231297/out/X.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b231297/out/X.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +package b231297; + +public class X { + + /** + * @return an inline tag: + * {@link String} inside the + * description. + */ + public String foo() { + return null; + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X01c.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X01c.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X01c.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X01c.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X01c { + + /***************************************** + * + * Test header/footer. + */ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X01.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X01.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X01.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X01.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +public class X01 { + + /** + * + * Returns true if the operator + * expects... + **/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/out/X04b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/out/X04b.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/out/X04b.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/out/X04b.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +public class X04b { + + void foo() { + if (true) { + /**** + * \r and \n are not valid + * in string literals + ****/ + } + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X03.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X03.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X03.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X03.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X03 { + + /** + ** + ** Returns true if the operator expects... + **/ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X04b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X04b.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X04b.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X04b.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +public class X04b { + + void foo() { + if (true) { + /**** \r and \n are not valid in string literals ****/ + } + } +} Index: workspace/FormatterJavadoc/test/bugs/b232138/X01b.java =================================================================== RCS file: workspace/FormatterJavadoc/test/bugs/b232138/X01b.java diff -N workspace/FormatterJavadoc/test/bugs/b232138/X01b.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/bugs/b232138/X01b.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +public class X01b { + + /*** + * + * Test header/footer. + */ + void foo() { + } +} #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java,v retrieving revision 1.74 diff -u -r1.74 AbstractCommentParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 8 May 2008 19:01:53 -0000 1.74 +++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 15 May 2008 13:20:39 -0000 @@ -157,6 +157,9 @@ char nextCharacter = 0; if (realStart == javadocStart) { nextCharacter = readChar(); // second '*' + while (peekChar() == '*') { + nextCharacter = readChar(); // read all contiguous '*' + } this.javadocTextStart = this.index; } this.lineEnd = (this.linePtr == this.lastLinePtr) ? this.javadocEnd: this.scanner.getLineEnd(this.linePtr) - 1; @@ -333,14 +336,16 @@ break; case '*' : // Store the star position as text start while formatting - this.starPosition = previousPosition; - if (isDomParser || isFormatterParser) { - if (lineHasStar && !this.lineStarted) { - this.lineStarted = true; - this.textStart = previousPosition; - } - if (!this.lineStarted) { - lineHasStar = true; + if (previousChar != '*') { + this.starPosition = previousPosition; + if (isDomParser || isFormatterParser) { + if (lineHasStar && !this.lineStarted) { + this.lineStarted = true; + this.textStart = previousPosition; + } + if (!this.lineStarted) { + lineHasStar = true; + } } } break;