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 159275 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 + Marking obsolete code deprecated
v01.txt (text/plain), 56.55 KB, created by
Frederic Fusier
on 2010-02-17 03:37:18 EST
(
hide
)
Description:
Proposed patch + Marking obsolete code deprecated
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-02-17 03:37:18 EST
Size:
56.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java,v >retrieving revision 1.225 >diff -u -r1.225 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 12 Feb 2010 09:51:08 -0000 1.225 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 17 Feb 2010 08:33:36 -0000 >@@ -117,7 +117,6 @@ > import org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil; > import org.eclipse.jdt.internal.formatter.align.Alignment; > import org.eclipse.jdt.internal.formatter.align.AlignmentException; >-import org.eclipse.jdt.internal.formatter.comment.CommentRegion; > import org.eclipse.jface.text.IRegion; > import org.eclipse.text.edits.TextEdit; > >@@ -886,38 +885,6 @@ > } > > /** >- * @see org.eclipse.jdt.core.formatter.CodeFormatter#format(int, String, int, int, int, String) >- */ >- public TextEdit format(String string, CommentRegion region) { >- // reset the scribe >- this.scribe.reset(); >- >- if (region == null) { >- return failedToFormat(); >- } >- >- long startTime = 0; >- if (DEBUG){ >- startTime = System.currentTimeMillis(); >- } >- >- final char[] compilationUnitSource = string.toCharArray(); >- >- this.scribe.initializeScanner(compilationUnitSource); >- >- TextEdit result = null; >- try { >- result = region.format(this.preferences.initial_indentation_level, true); >- } catch(AbortFormatting e){ >- return failedToFormat(); >- } >- if (DEBUG){ >- System.out.println("Formatting time: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$ >- } >- return result; >- } >- >- /** > * @param source the source of the comment to format > */ > public void formatComment(int kind, String source, int start, int end, int indentationLevel) { >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 17 Feb 2010 08:33:36 -0000 >@@ -28,15 +28,10 @@ > import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; > import org.eclipse.jdt.internal.compiler.util.Util; > import org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil; >-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 +51,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; > >@@ -77,15 +63,19 @@ > * @return a new comment region for the comment region range in the > * document > * @since 3.1 >+ * >+ * @deprecated Since version 3.4, CommentRegion are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This method will be removed from 3.6 version... > */ >- public static CommentRegion createRegion(int kind, IDocument document, Position range, CodeFormatterVisitor formatter) { >+ public static org.eclipse.jdt.internal.formatter.comment.CommentRegion createRegion(int kind, IDocument document, Position range, CodeFormatterVisitor formatter) { > switch (kind & K_MASK) { > case K_SINGLE_LINE_COMMENT: >- return new CommentRegion(document, range, formatter); >+ return new org.eclipse.jdt.internal.formatter.comment.CommentRegion(document, range, formatter); > case K_MULTI_LINE_COMMENT: >- return new MultiCommentRegion(document, range, formatter); >+ return new org.eclipse.jdt.internal.formatter.comment.MultiCommentRegion(document, range, formatter); > case K_JAVA_DOC: >- return new JavaDocRegion(document, range, formatter); >+ return new org.eclipse.jdt.internal.formatter.comment.JavaDocRegion(document, range, formatter); > } > return null; > } >@@ -174,17 +164,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 +183,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 +204,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 +254,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 +269,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 +377,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 +385,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 +397,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 +411,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 +457,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 +467,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 >Index: formatter/org/eclipse/jdt/internal/formatter/comment/CommentLine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/CommentLine.java,v >retrieving revision 1.7 >diff -u -r1.7 CommentLine.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/CommentLine.java 7 Mar 2009 01:08:08 -0000 1.7 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/CommentLine.java 17 Feb 2010 08:33:36 -0000 >@@ -19,6 +19,10 @@ > * General comment line in a comment region. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public abstract class CommentLine implements IBorderAttributes { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/CommentRange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/CommentRange.java,v >retrieving revision 1.8 >diff -u -r1.8 CommentRange.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/CommentRange.java 7 Mar 2009 01:08:08 -0000 1.8 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/CommentRange.java 17 Feb 2010 08:33:37 -0000 >@@ -22,6 +22,10 @@ > * Range in a comment region in comment region coordinates. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public class CommentRange extends Position implements ICommentAttributes, IHtmlTagDelimiters { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/CommentRegion.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/CommentRegion.java,v >retrieving revision 1.10 >diff -u -r1.10 CommentRegion.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/CommentRegion.java 7 Mar 2009 01:08:08 -0000 1.10 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/CommentRegion.java 17 Feb 2010 08:33:37 -0000 >@@ -35,6 +35,10 @@ > * Comment region in a source code document. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public class CommentRegion extends Position implements IHtmlTagDelimiters, IBorderAttributes, ICommentAttributes { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/IBorderAttributes.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/IBorderAttributes.java,v >retrieving revision 1.6 >diff -u -r1.6 IBorderAttributes.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/IBorderAttributes.java 7 Mar 2009 01:08:08 -0000 1.6 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/IBorderAttributes.java 17 Feb 2010 08:33:37 -0000 >@@ -15,6 +15,10 @@ > * Comment region border attributes. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public interface IBorderAttributes { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/ICommentAttributes.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/ICommentAttributes.java,v >retrieving revision 1.6 >diff -u -r1.6 ICommentAttributes.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/ICommentAttributes.java 7 Mar 2009 01:08:08 -0000 1.6 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/ICommentAttributes.java 17 Feb 2010 08:33:37 -0000 >@@ -15,6 +15,10 @@ > * General comment range attributes. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public interface ICommentAttributes { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/IHtmlTagDelimiters.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/IHtmlTagDelimiters.java,v >retrieving revision 1.8 >diff -u -r1.8 IHtmlTagDelimiters.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/IHtmlTagDelimiters.java 7 Mar 2009 01:08:08 -0000 1.8 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/IHtmlTagDelimiters.java 17 Feb 2010 08:33:37 -0000 >@@ -15,6 +15,10 @@ > * Html tag constants. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public interface IHtmlTagDelimiters { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocLine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocLine.java,v >retrieving revision 1.6 >diff -u -r1.6 JavaDocLine.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocLine.java 7 Mar 2009 01:08:08 -0000 1.6 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocLine.java 17 Feb 2010 08:33:37 -0000 >@@ -15,6 +15,10 @@ > * Javadoc comment line in a comment region. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public class JavaDocLine extends MultiCommentLine { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocRegion.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocRegion.java,v >retrieving revision 1.11 >diff -u -r1.11 JavaDocRegion.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocRegion.java 27 Jun 2008 16:03:57 -0000 1.11 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/JavaDocRegion.java 17 Feb 2010 08:33:37 -0000 >@@ -34,6 +34,10 @@ > * Javadoc region in a source code document. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public class JavaDocRegion extends MultiCommentRegion { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentLine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentLine.java,v >retrieving revision 1.8 >diff -u -r1.8 MultiCommentLine.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentLine.java 7 Mar 2009 01:08:08 -0000 1.8 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentLine.java 17 Feb 2010 08:33:37 -0000 >@@ -22,6 +22,10 @@ > * Multi-line comment line in a comment region. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public class MultiCommentLine extends CommentLine implements ICommentAttributes, IHtmlTagDelimiters, IJavaDocTagConstants { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentRegion.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentRegion.java,v >retrieving revision 1.10 >diff -u -r1.10 MultiCommentRegion.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentRegion.java 7 Mar 2009 01:08:08 -0000 1.10 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/MultiCommentRegion.java 17 Feb 2010 08:33:37 -0000 >@@ -23,6 +23,10 @@ > * Multi-comment region in a source code document. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public class MultiCommentRegion extends CommentRegion implements IJavaDocTagConstants { > >Index: formatter/org/eclipse/jdt/internal/formatter/comment/SingleCommentLine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/SingleCommentLine.java,v >retrieving revision 1.6 >diff -u -r1.6 SingleCommentLine.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/SingleCommentLine.java 7 Mar 2009 01:08:08 -0000 1.6 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/SingleCommentLine.java 17 Feb 2010 08:33:37 -0000 >@@ -15,6 +15,10 @@ > * Single-line comment line in a comment region. > * > * @since 3.0 >+ * >+ * @deprecated Since version 3.4, comment regions are no longer used by >+ * the formatter to format comments.<br> >+ * <b>WARNING</b>: This class will be removed from 3.6 version... > */ > public class SingleCommentLine extends CommentLine { > >#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 17 Feb 2010 08:33:45 -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 17 Feb 2010 08:33:52 -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 17 Feb 2010 08:33:52 -0000 >@@ -19,9 +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; > > public class JavaDocTestCase extends CommentTestCase { >@@ -30,11 +27,14 @@ > // TESTS_NAMES = new String[] { "test109636_2" } ; > } > >- protected static final String INFIX= MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; >+ /** @deprecated */ >+ protected static final String INFIX= org.eclipse.jdt.internal.formatter.comment.MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; > >- protected static final String POSTFIX= MultiCommentLine.MULTI_COMMENT_END_PREFIX; >+ /** @deprecated */ >+ protected static final String POSTFIX= org.eclipse.jdt.internal.formatter.comment.MultiCommentLine.MULTI_COMMENT_END_PREFIX; > >- protected static final String PREFIX= JavaDocLine.JAVADOC_START_PREFIX; >+ /** @deprecated */ >+ protected static final String PREFIX= org.eclipse.jdt.internal.formatter.comment.JavaDocLine.JAVADOC_START_PREFIX; > > public static Test suite() { > return buildTestSuite(JavaDocTestCase.class); >@@ -698,7 +698,7 @@ > > String expected = "/**" + DELIMITER + > " * <pre>" + DELIMITER + >- (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT ? " * " + DELIMITER : "") + >+ " * " + DELIMITER + > " * </pre>" + DELIMITER + > " * " + DELIMITER + > " * " + DELIMITER + >@@ -876,23 +876,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 +925,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 17 Feb 2010 08:33:52 -0000 >@@ -17,18 +17,18 @@ > > import junit.framework.Test; > >-import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; >-import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; >- > public class MultiLineTestCase extends CommentTestCase { > static { > // TESTS_NAMES = new String[] { "test170580" } ; > } >- protected static final String INFIX= MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; >+ /** @deprecated */ >+ protected static final String INFIX= org.eclipse.jdt.internal.formatter.comment.MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; > >- protected static final String POSTFIX= MultiCommentLine.MULTI_COMMENT_END_PREFIX; >+ /** @deprecated */ >+ protected static final String POSTFIX= org.eclipse.jdt.internal.formatter.comment.MultiCommentLine.MULTI_COMMENT_END_PREFIX; > >- protected static final String PREFIX= MultiCommentLine.MULTI_COMMENT_START_PREFIX; >+ /** @deprecated */ >+ protected static final String PREFIX= org.eclipse.jdt.internal.formatter.comment.MultiCommentLine.MULTI_COMMENT_START_PREFIX; > > public static Test suite() { > return buildTestSuite(MultiLineTestCase.class); >@@ -116,13 +116,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 17 Feb 2010 08:33:52 -0000 >@@ -16,11 +16,9 @@ > 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 { >- protected static final String PREFIX= SingleCommentLine.SINGLE_COMMENT_PREFIX; >+ /** @deprecated */ >+ protected static final String PREFIX= org.eclipse.jdt.internal.formatter.comment.SingleCommentLine.SINGLE_COMMENT_PREFIX; > > static { > // TESTS_NAMES = new String[] { "test109581" } ; >@@ -42,9 +40,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 +48,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 +56,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 +75,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 +109,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 +160,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