### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java,v retrieving revision 1.7 diff -u -r1.7 CleanUpMessages.java --- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java 24 Jan 2007 08:49:54 -0000 1.7 +++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java 2 Feb 2007 15:38:55 -0000 @@ -29,10 +29,6 @@ public static String CleanUpProfileManager_save_participant_profileName; - public static String CodeFormatingTabPage_CheckboxName_FormatComments; - public static String CodeFormatingTabPage_CheckboxName_FormatJavadocComments; - public static String CodeFormatingTabPage_CheckboxName_FormatMultiLineComments; - public static String CodeFormatingTabPage_CheckboxName_FormatSingleLineComments; public static String CodeFormatingTabPage_CheckboxName_FormatSourceCode; public static String CodeFormatingTabPage_FormatterSettings_Description; public static String CodeFormatingTabPage_GroupName_Formatter; Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties,v retrieving revision 1.9 diff -u -r1.9 CleanUpMessages.properties --- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties 24 Jan 2007 08:49:54 -0000 1.9 +++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties 2 Feb 2007 15:38:55 -0000 @@ -14,12 +14,8 @@ CodeFormatingTabPage_CheckboxName_FormatSourceCode=F&ormat source code CodeFormatingTabPage_FormatterSettings_Description=The settings for the Formatter can be changed on the Formatter preference page. CodeFormatingTabPage_OrganizeImports_CheckBoxLable=Organize i&mports -CodeFormatingTabPage_CheckboxName_FormatComments=Form&at comments -CodeFormatingTabPage_CheckboxName_FormatJavadocComments=Java&doc CodeFormatingTabPage_RemoveTrailingWhitespace_all_radio=&All lines -CodeFormatingTabPage_CheckboxName_FormatMultiLineComments=Mul&ti line comments CodeFormatingTabPage_OrganizeImportsSettings_Description=The settings for organizing imports can be changed on the Organize Imports preference page. -CodeFormatingTabPage_CheckboxName_FormatSingleLineComments=&Single line comments CodeFormatingTabPage_SortMembers_GroupName=Members CodeFormatingTabPage_SortMembers_CheckBoxLabel=Sort members CodeFormatingTabPage_SortMembers_Description=The settings for sorting members can be changed on the Members Sort Order preference page. Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java,v retrieving revision 1.6 diff -u -r1.6 CodeFormatingTabPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java 24 Jan 2007 08:49:54 -0000 1.6 +++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java 2 Feb 2007 15:38:55 -0000 @@ -63,30 +63,6 @@ createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatSourceCode, CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpModifyDialog.FALSE_TRUE); } - final CheckboxPreference formatCommentsPref= createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatComments, CleanUpConstants.FORMAT_COMMENT, CleanUpModifyDialog.FALSE_TRUE); - - indent(group); - final CheckboxPreference javadocPref= createCheckboxPref(group, numColumns - 1, CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatJavadocComments, CleanUpConstants.FORMAT_JAVADOC, CleanUpModifyDialog.FALSE_TRUE); - - indent(group); - final CheckboxPreference multiLinePref= createCheckboxPref(group, numColumns - 1, CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatMultiLineComments, CleanUpConstants.FORMAT_MULTI_LINE_COMMENT, CleanUpModifyDialog.FALSE_TRUE); - - indent(group); - final CheckboxPreference singleLinePref= createCheckboxPref(group, numColumns - 1, CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatSingleLineComments, CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT, CleanUpModifyDialog.FALSE_TRUE); - - formatCommentsPref.addObserver(new Observer() { - public void update(Observable o, Object arg) { - javadocPref.setEnabled(formatCommentsPref.getChecked()); - multiLinePref.setEnabled(formatCommentsPref.getChecked()); - singleLinePref.setEnabled(formatCommentsPref.getChecked()); - } - - }); - - javadocPref.setEnabled(formatCommentsPref.getChecked()); - multiLinePref.setEnabled(formatCommentsPref.getChecked()); - singleLinePref.setEnabled(formatCommentsPref.getChecked()); - final CheckboxPreference whiteSpace= createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_checkbox_text, CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES, CleanUpModifyDialog.FALSE_TRUE); Composite sub= new Composite(group, SWT.NONE); Index: ui/org/eclipse/jdt/internal/ui/fix/CommentFormatCleanUp.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/CommentFormatCleanUp.java,v retrieving revision 1.5 diff -u -r1.5 CommentFormatCleanUp.java --- ui/org/eclipse/jdt/internal/ui/fix/CommentFormatCleanUp.java 22 Dec 2006 16:50:21 -0000 1.5 +++ ui/org/eclipse/jdt/internal/ui/fix/CommentFormatCleanUp.java 2 Feb 2007 15:38:55 -0000 @@ -10,14 +10,15 @@ *******************************************************************************/ package org.eclipse.jdt.internal.ui.fix; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; import org.eclipse.jdt.internal.corext.fix.IFix; @@ -38,8 +39,16 @@ if (compilationUnit == null) return null; - boolean formatComment= isEnabled(CleanUpConstants.FORMAT_COMMENT); - return CommentFormatFix.createCleanUp(compilationUnit, formatComment && isEnabled(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT), formatComment && isEnabled(CleanUpConstants.FORMAT_MULTI_LINE_COMMENT), formatComment && isEnabled(CleanUpConstants.FORMAT_JAVADOC)); + if (!isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE)) + return null; + + HashMap preferences= new HashMap(compilationUnit.getJavaProject().getOptions(true)); + + boolean singleLineComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT)); + boolean blockComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT)); + boolean javaDoc= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT)); + + return CommentFormatFix.createCleanUp(compilationUnit, singleLineComment, blockComment, javaDoc, preferences); } /** @@ -74,14 +83,7 @@ * {@inheritDoc} */ public String[] getDescriptions() { - List result= new ArrayList(); - if (isEnabled(CleanUpConstants.FORMAT_COMMENT) && isEnabled(CleanUpConstants.FORMAT_MULTI_LINE_COMMENT)) - result.add(MultiFixMessages.CommentFormatCleanUp_multiLineComments); - if (isEnabled(CleanUpConstants.FORMAT_COMMENT) && isEnabled(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT)) - result.add(MultiFixMessages.CommentFormatCleanUp_singleLineComments); - if (isEnabled(CleanUpConstants.FORMAT_COMMENT) && isEnabled(CleanUpConstants.FORMAT_JAVADOC)) - result.add(MultiFixMessages.CommentFormatCleanUp_javadocComments); - return (String[])result.toArray(new String[result.size()]); + return null; } public String getPreview() { @@ -96,7 +98,17 @@ buf.append("*/\n"); //$NON-NLS-1$ buf.append("\n"); //$NON-NLS-1$ buf.append("//A single line comment\n"); //$NON-NLS-1$ - return CommentFormatFix.format(buf.toString(), isEnabled(CleanUpConstants.FORMAT_COMMENT) && isEnabled(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT), isEnabled(CleanUpConstants.FORMAT_COMMENT) && isEnabled(CleanUpConstants.FORMAT_MULTI_LINE_COMMENT), isEnabled(CleanUpConstants.FORMAT_COMMENT) && isEnabled(CleanUpConstants.FORMAT_JAVADOC)); + + if (!isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE)) + return buf.toString(); + + HashMap preferences= new HashMap(JavaCore.getOptions()); + + boolean singleLineComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT)); + boolean blockComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT)); + boolean javaDoc= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT)); + + return CommentFormatFix.format(buf.toString(), singleLineComment, blockComment, javaDoc); } /** Index: ui/org/eclipse/jdt/internal/ui/fix/CommentFormatFix.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/CommentFormatFix.java,v retrieving revision 1.8 diff -u -r1.8 CommentFormatFix.java --- ui/org/eclipse/jdt/internal/ui/fix/CommentFormatFix.java 2 Feb 2007 14:48:01 -0000 1.8 +++ ui/org/eclipse/jdt/internal/ui/fix/CommentFormatFix.java 2 Feb 2007 15:38:55 -0000 @@ -38,7 +38,6 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.internal.corext.fix.IFix; import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange; @@ -52,12 +51,11 @@ public class CommentFormatFix implements IFix { - public static IFix createCleanUp(ICompilationUnit unit, boolean singleLine, boolean multiLine, boolean javaDoc) throws CoreException { + public static IFix createCleanUp(ICompilationUnit unit, boolean singleLine, boolean multiLine, boolean javaDoc, HashMap preferences) throws CoreException { if (!singleLine && !multiLine && !javaDoc) return null; String content= unit.getBuffer().getContents(); - HashMap preferences= new HashMap(unit.getJavaProject().getOptions(true)); Document document= new Document(content); final List edits= format(document, singleLine, multiLine, javaDoc, preferences); @@ -106,13 +104,6 @@ private static List format(IDocument document, boolean singleLine, boolean multiLine, boolean javaDoc, HashMap preferences) { final List edits= new ArrayList(); - if (DefaultCodeFormatterConstants.FALSE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT))) - preferences.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, DefaultCodeFormatterConstants.TRUE); - if (DefaultCodeFormatterConstants.FALSE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT))) - preferences.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, DefaultCodeFormatterConstants.TRUE); - if (DefaultCodeFormatterConstants.FALSE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT))) - preferences.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE); - JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); String content= document.get(); Index: core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java,v retrieving revision 1.17 diff -u -r1.17 CleanUpConstants.java --- core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java 24 Jan 2007 08:49:54 -0000 1.17 +++ core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java 2 Feb 2007 15:38:55 -0000 @@ -17,6 +17,8 @@ import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; + import org.eclipse.jdt.internal.ui.preferences.cleanup.CleanUpProfileVersioner; public class CleanUpConstants { @@ -61,6 +63,7 @@ * @see #TRUE * @see #FALSE * @since 3.3 + * @deprecated replaced by {@link #FORMAT_SOURCE_CODE} */ public static final String FORMAT_COMMENT= "cleanup.format_comment"; //$NON-NLS-1$ @@ -75,6 +78,7 @@ * @see #TRUE * @see #FALSE * @since 3.3 + * @deprecated replaced by {@link DefaultCodeFormatterConstants#FORMATTER_COMMENT_FORMAT_LINE_COMMENT} */ public static final String FORMAT_SINGLE_LINE_COMMENT= "cleanup.format_single_line_comment"; //$NON-NLS-1$ @@ -89,6 +93,7 @@ * @see #TRUE * @see #FALSE * @since 3.3 + * @deprecated replaced by {@link DefaultCodeFormatterConstants#FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT} */ public static final String FORMAT_MULTI_LINE_COMMENT= "cleanup.format_multi_line_comment"; //$NON-NLS-1$ @@ -103,6 +108,7 @@ * @see #TRUE * @see #FALSE * @since 3.3 + * @deprecated replaced by {@link DefaultCodeFormatterConstants#FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT} */ public static final String FORMAT_JAVADOC= "cleanup.format_javadoc"; //$NON-NLS-1$ @@ -1139,10 +1145,6 @@ //Code Organising result.put(FORMAT_SOURCE_CODE, FALSE); - result.put(FORMAT_COMMENT, FALSE); - result.put(FORMAT_SINGLE_LINE_COMMENT, FALSE); - result.put(FORMAT_MULTI_LINE_COMMENT, FALSE); - result.put(FORMAT_JAVADOC, TRUE); result.put(FORMAT_REMOVE_TRAILING_WHITESPACES, FALSE); result.put(FORMAT_REMOVE_TRAILING_WHITESPACES_ALL, TRUE); result.put(FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY, FALSE); @@ -1219,10 +1221,6 @@ //Code Organising result.put(FORMAT_SOURCE_CODE, FALSE); - result.put(FORMAT_COMMENT, FALSE); - result.put(FORMAT_SINGLE_LINE_COMMENT, FALSE); - result.put(FORMAT_MULTI_LINE_COMMENT, FALSE); - result.put(FORMAT_JAVADOC, TRUE); result.put(FORMAT_REMOVE_TRAILING_WHITESPACES, FALSE); result.put(FORMAT_REMOVE_TRAILING_WHITESPACES_ALL, TRUE); result.put(FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY, FALSE); #P org.eclipse.jdt.ui.tests Index: performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java,v retrieving revision 1.24 diff -u -r1.24 CleanUpPerfTest.java --- performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java 24 Jan 2007 08:49:42 -0000 1.24 +++ performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java 2 Feb 2007 15:38:58 -0000 @@ -250,11 +250,6 @@ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpConstants.TRUE); node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_COMMENT, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_JAVADOC, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_MULTI_LINE_COMMENT, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpConstants.TRUE); node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.TRUE); Index: ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java,v retrieving revision 1.82 diff -u -r1.82 CleanUpTest.java --- ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java 2 Feb 2007 10:47:56 -0000 1.82 +++ ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java 2 Feb 2007 15:39:03 -0000 @@ -4110,8 +4110,6 @@ buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", buf.toString(), false, null); - enable(CleanUpConstants.FORMAT_COMMENT); - enable(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT); enable(CleanUpConstants.FORMAT_SOURCE_CODE); Hashtable options= TestOptions.getDefaultOptions(); Index: ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java,v retrieving revision 1.15 diff -u -r1.15 CleanUpStressTest.java --- ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 24 Jan 2007 08:49:42 -0000 1.15 +++ ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 2 Feb 2007 15:39:01 -0000 @@ -84,6 +84,10 @@ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE); + JavaCore.setOptions(options); IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); @@ -5333,11 +5337,6 @@ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpConstants.TRUE); node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_COMMENT, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_JAVADOC, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_MULTI_LINE_COMMENT, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT, CleanUpConstants.TRUE); - node.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpConstants.TRUE); node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.TRUE);