### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/ToolFactory.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java,v retrieving revision 1.73 diff -u -r1.73 ToolFactory.java --- model/org/eclipse/jdt/core/ToolFactory.java 23 May 2007 13:43:37 -0000 1.73 +++ model/org/eclipse/jdt/core/ToolFactory.java 25 May 2007 11:46:33 -0000 @@ -49,17 +49,31 @@ public class ToolFactory { /** - * If set, this mode tells the default code formatter to honor the options that - * never indent comments on first column. Note that if these options are disabled, - * then they remain disabled even if this mode is set. - * If this mode is not set, these options are ignored, even if they are enabled. + * This mode is used for formatting new code when some formatter options should not be used. + * In particular, options that preserve the indentation of comments are not used. + * In the future, newly added options may be ignored as well. + *
Clients that are formatting new code are recommended to use this mode. + *
+ * + * @see DefaultCodeFormatterConstants#FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN + * @see DefaultCodeFormatterConstants#FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN + * @see #createCodeFormatter(Map, int) + * @since 3.3 + */ + public static final int M_FORMAT_NEW= new Integer(0).intValue(); + + /** + * This mode is used for formatting existing code when all formatter options should be used. + * In particular, options that preserve the indentation of comments are used. + *Clients that are formatting existing code are recommended to use this mode. + *
* * @see DefaultCodeFormatterConstants#FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN * @see DefaultCodeFormatterConstants#FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN * @see #createCodeFormatter(Map, int) * @since 3.3 */ - public static final int M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS = 0x01; + public static final int M_FORMAT_EXISTING = new Integer(1).intValue(); /** * Create an instance of a code formatter. A code formatter implementation can be contributed via the @@ -105,8 +119,8 @@ * ({@link JavaCore#COMPILER_CODEGEN_TARGET_PLATFORM}). * Without these options, it is not possible for the code formatter to know what kind of source it needs to format. *
- * Note this is equivalent to createCodeFormatter(options, 0)
. Thus some code formatter options
- * may be ignored since the corresponding mode is not set.
+ * Note this is equivalent to createCodeFormatter(options, M_FORMAT_NEW)
. Thus some code formatter options
+ * may be ignored. See @{link {@link #M_FORMAT_NEW} for more details.
*
JavaCore#getDefaultOptions()
. If set to null
, then use
@@ -117,7 +131,7 @@
* @since 3.0
*/
public static CodeFormatter createCodeFormatter(Map options){
- return createCodeFormatter(options, 0);
+ return createCodeFormatter(options, M_FORMAT_NEW);
}
/**
@@ -127,10 +141,9 @@
* ({@link JavaCore#COMPILER_CODEGEN_TARGET_PLATFORM}).
* Without these options, it is not possible for the code formatter to know what kind of source it needs to format.
*
- * The given mode is a bitwise value. It is used to determine what options should be enabled when - * formatting the code.
- *The list of bits used to set the mode includes only {@link #M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS}, but - * other bits are left for future use.
+ *The given mode determine what options should be enabled when formatting the code. It can have the following + * values: {@link #M_FORMAT_NEW}, {@link #M_FORMAT_EXISTING}, but other values may be added in the future. + *
* * @param options the options map to use for formatting with the default code formatter. Recognized options * are documented onJavaCore#getDefaultOptions()
. If set to null
, then use
@@ -145,7 +158,7 @@
public static CodeFormatter createCodeFormatter(Map options, int mode) {
if (options == null) options = JavaCore.getOptions();
Map currentOptions = new HashMap(options);
- if ((mode & M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS) == 0) {
+ if (mode == M_FORMAT_NEW) {
// disable the option for not indenting comments starting on first column
currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
Index: formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java,v
retrieving revision 1.82
diff -u -r1.82 DefaultCodeFormatterConstants.java
--- formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 23 May 2007 13:43:37 -0000 1.82
+++ formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 25 May 2007 11:46:33 -0000
@@ -3038,8 +3038,7 @@
* - possible values: { TRUE, FALSE }
* - default: FALSE
*
- * Note that if the formatter is created without {@link ToolFactory#M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS} set,
- * this option is ignored.
+ * Note that this option is ignored if the formatter is created with the mode {@link ToolFactory#M_FORMAT_NEW}.
* @see #TRUE
* @see #FALSE
* @see ToolFactory#createCodeFormatter(Map, int)
@@ -3053,8 +3052,7 @@
* - possible values: { TRUE, FALSE }
* - default: FALSE
*
- * Note that if the formatter is created without {@link ToolFactory#M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS} set,
- * this option is ignored.
+ * Note that this option is ignored if the formatter is created with the mode {@link ToolFactory#M_FORMAT_NEW}.
* @see #TRUE
* @see #FALSE
* @see ToolFactory#createCodeFormatter(Map, int)