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 68309 Details for
Bug 185928
New Formatter Option "Never indent comments on first column" breaks formatting of auto generated bodies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for ToolFactory
185928.patch (text/plain), 6.39 KB, created by
Martin Aeschlimann
on 2007-05-23 06:15:17 EDT
(
hide
)
Description:
patch for ToolFactory
Filename:
MIME Type:
Creator:
Martin Aeschlimann
Created:
2007-05-23 06:15:17 EDT
Size:
6.39 KB
patch
obsolete
>### 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.72 >diff -u -r1.72 ToolFactory.java >--- model/org/eclipse/jdt/core/ToolFactory.java 29 Sep 2006 17:13:57 -0000 1.72 >+++ model/org/eclipse/jdt/core/ToolFactory.java 23 May 2007 10:12:09 -0000 >@@ -13,14 +13,20 @@ > import java.io.File; > import java.io.IOException; > import java.io.InputStream; >+import java.util.HashMap; > import java.util.Map; > import java.util.zip.ZipEntry; > import java.util.zip.ZipFile; > > import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Plugin; > import org.eclipse.jdt.core.compiler.IScanner; > import org.eclipse.jdt.core.formatter.CodeFormatter; >+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; > import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; > import org.eclipse.jdt.core.util.ClassFormatException; > import org.eclipse.jdt.core.util.IClassFileReader; >@@ -45,8 +51,42 @@ > * @since 2.0 > */ > 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. >+ * <p>See also {@link #M_FORMAT_NEW} and {@link #M_REFORMAT} that combine all flags that are typically used for formatting >+ * new or existing source</p> >+ * >+ * @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 int M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS = 0x01; > > /** >+ * This constant combines all modes to be used for formatting new code. In particular, options that preserve the indentation >+ * of comments are not used. Clients that are formatting new code are recommended to use this flag over the specific ones. >+ * >+ * @see #M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS >+ * @see #createCodeFormatter(Map, int) >+ * @since 3.3 >+ */ >+ public static int M_FORMAT_NEW= new Integer(0).intValue(); >+ >+ >+ /** >+ * This constant combines all modes to be used for (re-) formatting existing code. In particular, options that preserve the indentation >+ * of comments are used. Clients that are (re-) formatting existing code are recommended to use this flag over the specific flags. >+ * >+ * @see #M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS >+ * @see #createCodeFormatter(Map, int) >+ * @since 3.3 >+ */ >+ public static int M_REFORMAT = new Integer(M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS).intValue(); >+ >+ /** > * Create an instance of a code formatter. A code formatter implementation can be contributed via the > * extension point "org.eclipse.jdt.core.codeFormatter". If unable to find a registered extension, the factory > * will default to using the default code formatter. >@@ -89,6 +129,9 @@ > * the compiler compliance level ({@link JavaCore#COMPILER_COMPLIANCE}) and the target platform > * ({@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. >+ * </p><p> >+ * Note this is equivalent to <code>createCodeFormatter(options, M_FORMAT_NEW)</code>. Thus some code formatter options >+ * may be ignored since the corresponding mode is not set. > * </p> > * @param options - the options map to use for formatting with the default code formatter. Recognized options > * are documented on <code>JavaCore#getDefaultOptions()</code>. If set to <code>null</code>, then use >@@ -99,8 +142,41 @@ > * @since 3.0 > */ > public static CodeFormatter createCodeFormatter(Map options){ >+ return createCodeFormatter(options, 0); >+ } >+ >+ /** >+ * Create an instance of the built-in code formatter. >+ * <p>The given options should at least provide the source level ({@link JavaCore#COMPILER_SOURCE}), >+ * the compiler compliance level ({@link JavaCore#COMPILER_COMPLIANCE}) and the target platform >+ * ({@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. >+ * </p> >+ * <p>The given mode is a bitwise value. It is used to determine what options should be enabled when >+ * formatting the code.</p> >+ * <p>The list of bits used to set the mode includes {@link #M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS}, but >+ * other bits are left for future use. {@link #M_FORMAT_NEW} and {@link #M_REFORMAT} combine the flags to be used when formatting >+ * new or when formatting existing code.</p> >+ * >+ * @param options the options map to use for formatting with the default code formatter. Recognized options >+ * are documented on <code>JavaCore#getDefaultOptions()</code>. If set to <code>null</code>, then use >+ * the current settings from <code>JavaCore#getOptions</code>. >+ * @param mode the given mode to modify the given options. >+ * >+ * @return an instance of the built-in code formatter >+ * @see CodeFormatter >+ * @see JavaCore#getOptions() >+ * @since 3.3 >+ */ >+ public static CodeFormatter createCodeFormatter(Map options, int mode) { > if (options == null) options = JavaCore.getOptions(); >- return new DefaultCodeFormatter(options); >+ Map currentOptions = new HashMap(options); >+ if ((mode & M_FORMAT_HONOR_NEVER_INDENT_COMMENT_OPTIONS) == 0) { >+ // 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); >+ } >+ return new DefaultCodeFormatter(currentOptions); > } > > /**
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 185928
:
67413
|
68172
|
68309
|
68330
|
68753