Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 159206 Details for
Bug 236406
[formatter] The comments flags should work for all kind of snippet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 41.32 KB, created by
Frederic Fusier
on 2010-02-16 11:19:44 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-02-16 11:19:44 EST
Size:
41.32 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java,v >retrieving revision 1.79 >diff -u -r1.79 DefaultCodeFormatter.java >--- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 13 Jan 2010 15:13:44 -0000 1.79 >+++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 16 Feb 2010 16:01:21 -0000 >@@ -31,12 +31,10 @@ > import org.eclipse.jdt.internal.formatter.comment.CommentRegion; > import org.eclipse.jdt.internal.formatter.comment.JavaDocRegion; > import org.eclipse.jdt.internal.formatter.comment.MultiCommentRegion; >-import org.eclipse.jface.text.Document; > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.IRegion; > import org.eclipse.jface.text.Position; > import org.eclipse.jface.text.Region; >-import org.eclipse.text.edits.MultiTextEdit; > import org.eclipse.text.edits.TextEdit; > > public class DefaultCodeFormatter extends CodeFormatter { >@@ -56,15 +54,6 @@ > | K_MULTI_LINE_COMMENT > | K_JAVA_DOC; > >- /* >- * Temporary internal statics to enable new comments formatter >- * see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 >- * see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=227043 >- * TODO (frederic) remove in 3.5 >- */ >- private final static String NEW_COMMENTS_FORMAT = System.getProperty("org.eclipse.jdt.core.formatter.comments.new"); //$NON-NLS-1$ >- public static boolean ENABLE_NEW_COMMENTS_FORMAT = !JavaCore.DISABLED.equals(NEW_COMMENTS_FORMAT); >- > // Scanner use to probe the kind of the source given to the formatter > private static Scanner PROBING_SCANNER; > >@@ -174,17 +163,11 @@ > case K_JAVA_DOC : > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 > // use the integrated comment formatter to format comment >- if (ENABLE_NEW_COMMENTS_FORMAT) { >- return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)}); >- } >+ return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)}); > // $FALL-THROUGH$ - fall through next case when old comment formatter is activated > case K_MULTI_LINE_COMMENT : > case K_SINGLE_LINE_COMMENT : >- if (ENABLE_NEW_COMMENTS_FORMAT) { >- return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)}); >- } >- this.codeSnippetParsingUtil = new CodeSnippetParsingUtil(); >- return formatComment(kind, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)}, false); >+ return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)}); > } > > return format(kind, source, new IRegion[] {new Region(offset, length)}, indentationLevel, lineSeparator); >@@ -199,18 +182,17 @@ > } > > this.codeSnippetParsingUtil = new CodeSnippetParsingUtil(); >+ boolean includeComments = (kind & F_INCLUDE_COMMENTS) != 0; > switch(kind & K_MASK) { > case K_CLASS_BODY_DECLARATIONS : >- return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, regions); >+ return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, regions, includeComments); > case K_COMPILATION_UNIT : >- boolean includeComments = (kind & F_INCLUDE_COMMENTS) != 0; // || FORCE_NEW_COMMENTS_FORMAT; > return formatCompilationUnit(source, indentationLevel, lineSeparator, regions, includeComments); > case K_EXPRESSION : >- return formatExpression(source, indentationLevel, lineSeparator, regions); >+ return formatExpression(source, indentationLevel, lineSeparator, regions, includeComments); > case K_STATEMENTS : >- return formatStatements(source, indentationLevel, lineSeparator, regions); >+ return formatStatements(source, indentationLevel, lineSeparator, regions, includeComments); > case K_UNKNOWN : >- includeComments = (kind & F_INCLUDE_COMMENTS) != 0; // || FORCE_NEW_COMMENTS_FORMAT; > return probeFormatting(source, indentationLevel, lineSeparator, regions, includeComments); > case K_JAVA_DOC : > case K_MULTI_LINE_COMMENT : >@@ -221,14 +203,14 @@ > return null; > } > >- private TextEdit formatClassBodyDeclarations(String source, int indentationLevel, String lineSeparator, IRegion[] regions) { >+ private TextEdit formatClassBodyDeclarations(String source, int indentationLevel, String lineSeparator, IRegion[] regions, boolean includeComments) { > ASTNode[] bodyDeclarations = this.codeSnippetParsingUtil.parseClassBodyDeclarations(source.toCharArray(), getDefaultCompilerOptions(), true); > > if (bodyDeclarations == null) { > // a problem occurred while parsing the source > return null; > } >- return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, regions); >+ return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, regions, includeComments); > } > > /* >@@ -271,55 +253,6 @@ > return null; > } > >- /** >- * Returns the resulting text edit after formatting the given comment. >- * >- * @param kind the given kind >- * @param source the given source >- * @param indentationLevel the given indentation level >- * @param lineSeparator the given line separator >- * @param regions the given regions >- * @param includeComments TODO >- * @return the resulting text edit >- */ >- private TextEdit formatComment(int kind, String source, int indentationLevel, String lineSeparator, IRegion[] regions, boolean includeComments) { >- Object oldOption = oldCommentFormatOption(); >- boolean isFormattingComments = false; >- if (oldOption == null) { >- switch (kind & K_MASK) { >- case K_SINGLE_LINE_COMMENT: >- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(this.options.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT)); >- break; >- case K_MULTI_LINE_COMMENT: >- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(this.options.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT)); >- break; >- case K_JAVA_DOC: >- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(this.options.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT)); >- } >- } else { >- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(oldOption); >- } >- if (isFormattingComments) { >- if (lineSeparator != null) { >- this.preferences.line_separator = lineSeparator; >- } else { >- this.preferences.line_separator = Util.LINE_SEPARATOR; >- } >- this.preferences.initial_indentation_level = indentationLevel; >- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, null, includeComments); >- >- IRegion coveredRegion = getCoveredRegion(regions); >- int offset = coveredRegion.getOffset(); >- int length = coveredRegion.getLength(); >- >- final CommentRegion region = createRegion(kind, new Document(source), new Position(offset, length), this.newCodeFormatter); >- if (region != null) { >- return this.newCodeFormatter.format(source, region); >- } >- } >- return new MultiTextEdit(); >- } >- > private TextEdit formatCompilationUnit(String source, int indentationLevel, String lineSeparator, IRegion[] regions, boolean includeComments) { > CompilationUnitDeclaration compilationUnitDeclaration = this.codeSnippetParsingUtil.parseCompilationUnit(source.toCharArray(), getDefaultCompilerOptions(), true); > >@@ -335,24 +268,24 @@ > return this.newCodeFormatter.format(source, compilationUnitDeclaration); > } > >- private TextEdit formatExpression(String source, int indentationLevel, String lineSeparator, IRegion[] regions) { >+ private TextEdit formatExpression(String source, int indentationLevel, String lineSeparator, IRegion[] regions, boolean includeComments) { > Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true); > > if (expression == null) { > // a problem occurred while parsing the source > return null; > } >- return internalFormatExpression(source, indentationLevel, lineSeparator, expression, regions); >+ return internalFormatExpression(source, indentationLevel, lineSeparator, expression, regions, includeComments); > } > >- private TextEdit formatStatements(String source, int indentationLevel, String lineSeparator, IRegion[] regions) { >+ private TextEdit formatStatements(String source, int indentationLevel, String lineSeparator, IRegion[] regions, boolean includeComments) { > ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true, false); > > if (constructorDeclaration.statements == null) { > // a problem occured while parsing the source > return null; > } >- return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, regions); >+ return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, regions, includeComments); > } > > private IRegion getCoveredRegion(IRegion[] regions) { >@@ -443,7 +376,7 @@ > return this.defaultCompilerOptions; > } > >- private TextEdit internalFormatClassBodyDeclarations(String source, int indentationLevel, String lineSeparator, ASTNode[] bodyDeclarations, IRegion[] regions) { >+ private TextEdit internalFormatClassBodyDeclarations(String source, int indentationLevel, String lineSeparator, ASTNode[] bodyDeclarations, IRegion[] regions, boolean includeComments) { > if (lineSeparator != null) { > this.preferences.line_separator = lineSeparator; > } else { >@@ -451,11 +384,11 @@ > } > this.preferences.initial_indentation_level = indentationLevel; > >- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, false); >+ this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, includeComments); > return this.newCodeFormatter.format(source, bodyDeclarations); > } > >- private TextEdit internalFormatExpression(String source, int indentationLevel, String lineSeparator, Expression expression, IRegion[] regions) { >+ private TextEdit internalFormatExpression(String source, int indentationLevel, String lineSeparator, Expression expression, IRegion[] regions, boolean includeComments) { > if (lineSeparator != null) { > this.preferences.line_separator = lineSeparator; > } else { >@@ -463,13 +396,13 @@ > } > this.preferences.initial_indentation_level = indentationLevel; > >- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, false); >+ this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, includeComments); > > TextEdit textEdit = this.newCodeFormatter.format(source, expression); > return textEdit; > } > >- private TextEdit internalFormatStatements(String source, int indentationLevel, String lineSeparator, ConstructorDeclaration constructorDeclaration, IRegion[] regions) { >+ private TextEdit internalFormatStatements(String source, int indentationLevel, String lineSeparator, ConstructorDeclaration constructorDeclaration, IRegion[] regions, boolean includeComments) { > if (lineSeparator != null) { > this.preferences.line_separator = lineSeparator; > } else { >@@ -477,7 +410,7 @@ > } > this.preferences.initial_indentation_level = indentationLevel; > >- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, false); >+ this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, includeComments); > > return this.newCodeFormatter.format(source, constructorDeclaration); > } >@@ -523,13 +456,7 @@ > break; > } > if (kind != -1) { >- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=227043 >- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 >- // use the integrated comment formatter to format comment >- if (ENABLE_NEW_COMMENTS_FORMAT /*|| FORCE_NEW_COMMENTS_FORMAT*/) { >- return formatComment(kind, source, indentationLevel, lineSeparator, regions); >- } >- return formatComment(kind, source, indentationLevel, lineSeparator, regions, includeComments); >+ return formatComment(kind, source, indentationLevel, lineSeparator, regions); > } > } catch (InvalidInputException e) { > // ignore >@@ -539,19 +466,19 @@ > // probe for expression > Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true); > if (expression != null) { >- return internalFormatExpression(source, indentationLevel, lineSeparator, expression, regions); >+ return internalFormatExpression(source, indentationLevel, lineSeparator, expression, regions, includeComments); > } > > // probe for body declarations (fields, methods, constructors) > ASTNode[] bodyDeclarations = this.codeSnippetParsingUtil.parseClassBodyDeclarations(source.toCharArray(), getDefaultCompilerOptions(), true); > if (bodyDeclarations != null) { >- return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, regions); >+ return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, regions, includeComments); > } > > // probe for statements > ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true, false); > if (constructorDeclaration.statements != null) { >- return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, regions); >+ return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, regions, includeComments); > } > > // this has to be a compilation unit >#P org.eclipse.jdt.core.tests.model >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.52 >diff -u -r1.52 FormatterCommentsBugsTest.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 14 Feb 2010 15:57:04 -0000 1.52 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 16 Feb 2010 16:01:28 -0000 >@@ -2200,8 +2200,6 @@ > " return null;\n" + > " }\n" + > "}\n"; >- // TODO (frederic) line comment should be formatted when F_INCLUDE_COMMENTS >- // flag will work for all snippet kinds > formatSource(source, > "/**\n" + > " * Need a javadoc comment before to get the exception.\n" + >@@ -2213,7 +2211,7 @@ > " * If there is an authority, it is:\n" + > " * \n" + > " * <pre>\n" + >- " * //class body snippet\n" + >+ " * // class body snippet\n" + > " * public class X {\n" + > " * }\n" + > " * </pre>\n" + >@@ -2265,6 +2263,142 @@ > } > > /** >+ * @bug 236406: [formatter] Formatting qualified invocations can be broken when the Line Wrapping policy forces element to be on a new line >+ * @test Verify that wrapping policies forcing the first element to be on a new line are working again... >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=236406" >+ */ >+public void testBug236406_CDB1() { >+ String source = >+ "/** Javadoc comment */void foo1() {System.out.println();}\n" + >+ "// Line comment \n" + >+ "void foo2() {System.out.println();}\n" + >+ "/* Block comment */\n" + >+ "void foo3() {\n" + >+ "/* statement Block comment */\n" + >+ "System.out.println();}\n"; >+ formatSource(source, >+ "/** Javadoc comment */\n" + >+ "void foo1() {\n" + >+ " System.out.println();\n" + >+ "}\n" + >+ "\n" + >+ "// Line comment \n" + >+ "void foo2() {\n" + >+ " System.out.println();\n" + >+ "}\n" + >+ "\n" + >+ "/* Block comment */\n" + >+ "void foo3() {\n" + >+ " /* statement Block comment */\n" + >+ " System.out.println();\n" + >+ "}", >+ CodeFormatter.K_CLASS_BODY_DECLARATIONS >+ ); >+} >+public void testBug236406_CDB2() { >+ String source = >+ "/** Javadoc comment */void foo1() {System.out.println();}\n" + >+ "// Line comment \n" + >+ "void foo2() {System.out.println();}\n" + >+ "/* Block comment */\n" + >+ "void foo3() {\n" + >+ "/* statement Block comment */\n" + >+ "System.out.println();}\n"; >+ formatSource(source, >+ "/** Javadoc comment */\n" + >+ "void foo1() {\n" + >+ " System.out.println();\n" + >+ "}\n" + >+ "\n" + >+ "// Line comment\n" + >+ "void foo2() {\n" + >+ " System.out.println();\n" + >+ "}\n" + >+ "\n" + >+ "/* Block comment */\n" + >+ "void foo3() {\n" + >+ " /* statement Block comment */\n" + >+ " System.out.println();\n" + >+ "}", >+ CodeFormatter.K_CLASS_BODY_DECLARATIONS | CodeFormatter.F_INCLUDE_COMMENTS >+ ); >+} >+public void testBug236406_EX1() { >+ String source = >+ "// Line comment \n" + >+ "i = \n" + >+ "/** Javadoc comment */\n" + >+ "1 + (/* Block comment*/++a)\n"; >+ formatSource(source, >+ "// Line comment \n" + >+ "i =\n" + >+ "/** Javadoc comment */\n" + >+ "1 + (/* Block comment*/++a)", >+ CodeFormatter.K_EXPRESSION >+ ); >+} >+public void testBug236406_EX2() { >+ String source = >+ "// Line comment \n" + >+ "i = \n" + >+ "/** Javadoc comment */\n" + >+ "1 + (/* Block comment*/++a)\n"; >+ formatSource(source, >+ "// Line comment\n" + >+ "i =\n" + >+ "/** Javadoc comment */\n" + >+ "1 + (/* Block comment */++a)", >+ CodeFormatter.K_EXPRESSION | CodeFormatter.F_INCLUDE_COMMENTS >+ ); >+} >+public void testBug236406_ST1() { >+ String source = >+ "/** Javadoc comment */foo1();\n" + >+ "// Line comment \n" + >+ "foo2();\n" + >+ "/* Block comment */\n" + >+ "foo3(); {\n" + >+ "/* indented Block comment */\n" + >+ "System.out.println();}\n"; >+ formatSource(source, >+ "/** Javadoc comment */\n" + >+ "foo1();\n" + >+ "// Line comment \n" + >+ "foo2();\n" + >+ "/* Block comment */\n" + >+ "foo3();\n" + >+ "{\n" + >+ " /* indented Block comment */\n" + >+ " System.out.println();\n" + >+ "}", >+ CodeFormatter.K_STATEMENTS >+ ); >+} >+public void testBug236406_ST2() { >+ String source = >+ "/** Javadoc comment */foo1();\n" + >+ "// Line comment \n" + >+ "foo2();\n" + >+ "/* Block comment */\n" + >+ "foo3(); {\n" + >+ "/* indented Block comment */\n" + >+ "System.out.println();}\n"; >+ formatSource(source, >+ "/** Javadoc comment */\n" + >+ "foo1();\n" + >+ "// Line comment\n" + >+ "foo2();\n" + >+ "/* Block comment */\n" + >+ "foo3();\n" + >+ "{\n" + >+ " /* indented Block comment */\n" + >+ " System.out.println();\n" + >+ "}", >+ CodeFormatter.K_STATEMENTS | CodeFormatter.F_INCLUDE_COMMENTS >+ ); >+} >+ >+/** > * @bug 237051: [formatter] Formatter insert blank lines after javadoc if javadoc contains Commons Attributes @@ annotations > * @test Ensure that Commons Attributes @@ annotations do not screw up the comment formatter > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=237051" >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java,v >retrieving revision 1.254 >diff -u -r1.254 FormatterRegressionTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 14 Oct 2009 15:50:54 -0000 1.254 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 16 Feb 2010 16:01:35 -0000 >@@ -239,6 +239,10 @@ > void formatSource(String source, String formattedOutput) { > formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, true /*repeat formatting twice*/); > } >+ >+ void formatSource(String source, String formattedOutput, int kind) { >+ formatSource(source, formattedOutput, kind, 0, true /*repeat formatting twice*/); >+ } > > void formatSource(String source, String formattedOutput, boolean repeat) { > formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, repeat); >Index: src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java,v >retrieving revision 1.21 >diff -u -r1.21 JavaDocTestCase.java >--- src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 27 Jun 2008 16:02:41 -0000 1.21 >+++ src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 16 Feb 2010 16:01:36 -0000 >@@ -19,7 +19,6 @@ > import org.eclipse.jdt.core.formatter.CodeFormatter; > import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; > >-import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; > import org.eclipse.jdt.internal.formatter.comment.JavaDocLine; > import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; > import org.eclipse.text.edits.TextEdit; >@@ -698,7 +697,7 @@ > > String expected = "/**" + DELIMITER + > " * <pre>" + DELIMITER + >- (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT ? " * " + DELIMITER : "") + >+ " * " + DELIMITER + > " * </pre>" + DELIMITER + > " * " + DELIMITER + > " * " + DELIMITER + >@@ -876,23 +875,8 @@ > " * </code>" + DELIMITER + > " */"; > >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? input // do not change as <code> is an immutable tag >- : "/**" + DELIMITER + >- " * <code>" + DELIMITER + >- " * <pre>" + DELIMITER + >- " * setLeadingComment("/* traditional comment */"); // correct" + DELIMITER + >- " * setLeadingComment("missing comment delimiters"); // wrong" + DELIMITER + >- " * setLeadingComment("/* unterminated traditional comment "); // wrong" + DELIMITER + >- " * setLeadingComment("/* broken\\n traditional comment */"); // correct" + DELIMITER + >- " * setLeadingComment("// end-of-line comment\\n"); // correct" + DELIMITER + >- " * setLeadingComment("// end-of-line comment without line terminator"); // correct" + DELIMITER + >- " * setLeadingComment("// broken\\n end-of-line comment\\n"); // wrong" + DELIMITER + >- " * </pre>" + DELIMITER + >- " * </code>" + DELIMITER + >- " */"; > String result=testFormat(input, options); >- assertEquals(expected, result); >+ assertEquals(input, result); > } > > public void test109636_2() { >@@ -940,37 +924,35 @@ > } > > public void test109636_4() { >- if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) { >- Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ >+ String input = >+ "/**" + DELIMITER + >+ " * <pre>" + DELIMITER + >+ " * setLeadingComment(\"/* traditional comment */\"); // correct" + DELIMITER + >+ " * setLeadingComment(\"missing comment delimiters\"); // wrong" + DELIMITER + >+ " * setLeadingComment(\"/* unterminated traditional comment \"); // wrong" + DELIMITER + >+ " * setLeadingComment(\"/* broken\\n traditional comment */\"); // correct" + DELIMITER + >+ " * setLeadingComment(\"// end-of-line comment\\n\"); // correct" + DELIMITER + >+ " * setLeadingComment(\"// end-of-line comment without line terminator\"); // correct" + DELIMITER + >+ " * setLeadingComment(\"// broken\\n end-of-line comment\\n\"); // wrong" + DELIMITER + >+ " * </pre>" + DELIMITER + >+ " */"; > >- String input = >- "/**" + DELIMITER + >- " * <pre>" + DELIMITER + >- " * setLeadingComment(\"/* traditional comment */\"); // correct" + DELIMITER + >- " * setLeadingComment(\"missing comment delimiters\"); // wrong" + DELIMITER + >- " * setLeadingComment(\"/* unterminated traditional comment \"); // wrong" + DELIMITER + >- " * setLeadingComment(\"/* broken\\n traditional comment */\"); // correct" + DELIMITER + >- " * setLeadingComment(\"// end-of-line comment\\n\"); // correct" + DELIMITER + >- " * setLeadingComment(\"// end-of-line comment without line terminator\"); // correct" + DELIMITER + >- " * setLeadingComment(\"// broken\\n end-of-line comment\\n\"); // wrong" + DELIMITER + >- " * </pre>" + DELIMITER + >- " */"; >- >- String expected = >- "/**" + DELIMITER + >- " * <pre>" + DELIMITER + >- " * setLeadingComment("/* traditional comment */"); // correct" + DELIMITER + >- " * setLeadingComment("missing comment delimiters"); // wrong" + DELIMITER + >- " * setLeadingComment("/* unterminated traditional comment "); // wrong" + DELIMITER + >- " * setLeadingComment("/* broken\\n traditional comment */"); // correct" + DELIMITER + >- " * setLeadingComment("// end-of-line comment\\n"); // correct" + DELIMITER + >- " * setLeadingComment("// end-of-line comment without line terminator"); // correct" + DELIMITER + >- " * setLeadingComment("// broken\\n end-of-line comment\\n"); // wrong" + DELIMITER + >- " * </pre>" + DELIMITER + >- " */"; >- String result=testFormat(input, options); >- assertEquals(expected, result); >- } >+ String expected = >+ "/**" + DELIMITER + >+ " * <pre>" + DELIMITER + >+ " * setLeadingComment("/* traditional comment */"); // correct" + DELIMITER + >+ " * setLeadingComment("missing comment delimiters"); // wrong" + DELIMITER + >+ " * setLeadingComment("/* unterminated traditional comment "); // wrong" + DELIMITER + >+ " * setLeadingComment("/* broken\\n traditional comment */"); // correct" + DELIMITER + >+ " * setLeadingComment("// end-of-line comment\\n"); // correct" + DELIMITER + >+ " * setLeadingComment("// end-of-line comment without line terminator"); // correct" + DELIMITER + >+ " * setLeadingComment("// broken\\n end-of-line comment\\n"); // wrong" + DELIMITER + >+ " * </pre>" + DELIMITER + >+ " */"; >+ String result=testFormat(input, options); >+ assertEquals(expected, result); > } > > /** >Index: src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java,v >retrieving revision 1.13 >diff -u -r1.13 MultiLineTestCase.java >--- src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java 27 Jun 2008 16:02:41 -0000 1.13 >+++ src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java 16 Feb 2010 16:01:36 -0000 >@@ -17,7 +17,6 @@ > > import junit.framework.Test; > >-import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; > import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; > > public class MultiLineTestCase extends CommentTestCase { >@@ -116,13 +115,9 @@ > " * Member comment\n" +//$NON-NLS-1$ > " */";//$NON-NLS-1$ > String result= testFormat(input, 0, input.length(), CodeFormatter.K_MULTI_LINE_COMMENT , 2); >- String expectedOutput = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? "/**\n" + >- " * Member comment\n" + >- " */" >- : "/***********************************************************************\n" + >- " * Member comment\n" + >- " */"; >+ String expectedOutput = "/**\n" + >+ " * Member comment\n" + >+ " */"; > assertEquals("Different output", expectedOutput, result); > } > >Index: src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java,v >retrieving revision 1.9 >diff -u -r1.9 SingleLineTestCase.java >--- src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java 27 Jun 2008 16:02:40 -0000 1.9 >+++ src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java 16 Feb 2010 16:01:36 -0000 >@@ -16,7 +16,6 @@ > import org.eclipse.jdt.core.formatter.CodeFormatter; > import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; > >-import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; > import org.eclipse.jdt.internal.formatter.comment.SingleCommentLine; > > public class SingleLineTestCase extends CommentTestCase { >@@ -42,9 +41,7 @@ > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE); > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE); >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test" >- : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >+ String expected =PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ > } > >@@ -52,9 +49,7 @@ > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE); > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE); >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + DELIMITER + PREFIX + "test" >- : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >+ String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("//test\t\ttest" + DELIMITER + PREFIX + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ > } > >@@ -62,23 +57,17 @@ > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE); > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE); >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" >- : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >+ String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + PREFIX + "test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ > } > > public void testCommentBegin1() { >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test" >- : PREFIX + "test" + DELIMITER; >+ String expected = PREFIX + "test"; > assertEquals(expected, testFormat("//test")); //$NON-NLS-1$ //$NON-NLS-2$ > } > > public void testCommentBegin2() { >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test" >- : PREFIX + "test" + DELIMITER; >+ String expected = PREFIX + "test"; > assertEquals(expected, testFormat(PREFIX + "test")); //$NON-NLS-1$ //$NON-NLS-2$ > } > >@@ -87,14 +76,12 @@ > } > > public void testCommentDelimiter1() { >- String expected = PREFIX + "test" + DELIMITER; >- if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected += DELIMITER; >+ String expected = PREFIX + "test" + DELIMITER + DELIMITER; > assertEquals(expected, testFormat("//\t\ttest " + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ > } > > public void testCommentDelimiter2() { >- String expected = PREFIX + "test" + DELIMITER; >- if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected += DELIMITER ; >+ String expected = PREFIX + "test" + DELIMITER + DELIMITER ; > assertEquals(expected, testFormat(PREFIX + "test " + DELIMITER + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ > } > >@@ -123,47 +110,35 @@ > } > > public void testCommentSpace1() { >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test test" >- : PREFIX + "test test" + DELIMITER; >+ String expected = PREFIX + "test test"; > assertEquals(expected, testFormat("//test\t \t test")); //$NON-NLS-1$ //$NON-NLS-2$ > } > > public void testCommentSpace2() { >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test test" >- : PREFIX + "test test" + DELIMITER; >+ String expected = PREFIX + "test test"; > assertEquals(expected, testFormat("//test test")); //$NON-NLS-1$ //$NON-NLS-2$ > } > > public void testCommentSpace3() { >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test test" >- : PREFIX + "test test" + DELIMITER; >+ String expected = PREFIX + "test test"; > assertEquals(expected, testFormat(PREFIX + "test \t \t test")); //$NON-NLS-1$ //$NON-NLS-2$ > } > > public void testCommentWrapping1() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test" + DELIMITER + PREFIX + "test" >- : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >+ String expected = PREFIX + "test" + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } > > public void testCommentWrapping2() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$ >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test" + DELIMITER + PREFIX + "test" >- : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >+ String expected = PREFIX + "test" + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } > > public void testCommentWrapping3() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "32"); //$NON-NLS-1$ >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test test" >- : PREFIX + "test test" + DELIMITER; >+ String expected = PREFIX + "test test"; > assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } > >@@ -186,58 +161,48 @@ > public void testHeaderComment1() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE); > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$ >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" >- : PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER; >+ String expected = PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test"; > assertEquals(expected, testFormat("//test\t\t\t\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ > } > > public void testHeaderComment2() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE); > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "24"); //$NON-NLS-1$ >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? "// test" + DELIMITER + PREFIX + "test test test test" + DELIMITER >- : PREFIX + "test test test test" + DELIMITER + PREFIX + "test" + DELIMITER; >+ String expected = "// test" + DELIMITER + PREFIX + "test test test test" + DELIMITER; > assertEquals(expected, testFormat("//test\t\t\t" + DELIMITER + PREFIX + "test test test test" + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ > } > > public void testIllegalLineLength1() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$ >- String expected =PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >- if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); >+ String expected =PREFIX + "test" + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } > > public void testIllegalLineLength2() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "-16"); //$NON-NLS-1$ >- String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >- if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); >+ String expected = PREFIX + "test" + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat(PREFIX + "\t\t test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } > > public void testMultipleComments1() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ >- String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >- if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); >+ String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("//test test" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ > } > > public void testMultipleComments2() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$ >- String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT >- ? "// test test" + DELIMITER + >- "// test" + DELIMITER + >- "// " + DELIMITER + >- "// test test" + DELIMITER + >- "// test test" >- : PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test" + DELIMITER; >+ String expected = "// test test" + DELIMITER + >+ "// test" + DELIMITER + >+ "// " + DELIMITER + >+ "// test test" + DELIMITER + >+ "// test test"; > assertEquals(expected, testFormat("//test test\ttest" + DELIMITER + PREFIX + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ > } > > public void testMultipleComments3() { > setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "11"); //$NON-NLS-1$ >- String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; >- if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); >+ String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test"; > assertEquals(expected, testFormat("// test\t\t\ttest\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 236406
:
159206
|
159275
|
159416