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 58078 Details for
Bug 49412
[formatting] Offer comment formatting options per comment type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix for the JDT/UI side
patch_49412_ui.txt (text/plain), 18.12 KB, created by
Olivier Thomann
on 2007-02-01 20:30:54 EST
(
hide
)
Description:
Proposed fix for the JDT/UI side
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-02-01 20:30:54 EST
Size:
18.12 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java,v >retrieving revision 1.25 >diff -u -r1.25 ProfileVersioner.java >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java 20 Sep 2006 09:48:45 -0000 1.25 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java 2 Feb 2007 01:29:22 -0000 >@@ -36,8 +36,9 @@ > private static final int VERSION_8= 8; // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=89739 > private static final int VERSION_9= 9; // after storing project profile names in preferences > private static final int VERSION_10= 10; // splitting options for annotation types >+ private static final int VERSION_11= 11; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49412 > >- private static final int CURRENT_VERSION= VERSION_10; >+ private static final int CURRENT_VERSION= VERSION_11; > > public int getFirstVersion() { > return VERSION_1; >@@ -88,6 +89,9 @@ > case VERSION_8: > case VERSION_9: > version9to10(oldSettings); >+ >+ case VERSION_10 : >+ version10to11(oldSettings); > > default: > for (final Iterator iter= oldSettings.keySet().iterator(); iter.hasNext(); ) { >@@ -555,7 +559,7 @@ > } > > private static void version6to7(Map oldSettings) { >- checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMAT, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT); >+ checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMAT, FORMATTER_COMMENT_FORMAT2); > checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMATHEADER, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER); > checkAndReplace(oldSettings, FORMATTER_COMMENT_FORMATSOURCE, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE); > checkAndReplace(oldSettings, FORMATTER_COMMENT_INDENTPARAMETERDESCRIPTION, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION); >@@ -567,7 +571,6 @@ > checkAndReplaceBooleanWithINSERT(oldSettings, FORMATTER_COMMENT_NEWLINEFORPARAMETER, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER); > checkAndReplaceBooleanWithINSERT(oldSettings, FORMATTER_COMMENT_SEPARATEROOTTAGS, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS); > } >- > > private static void version9to10(Map oldSettings) { > duplicate(oldSettings, >@@ -578,7 +581,15 @@ > DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER); > } > >- >+ private static void version10to11(Map oldSettings) { >+ checkAndReplace(oldSettings, >+ FORMATTER_COMMENT_FORMAT2, >+ new String[] { >+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, >+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, >+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT >+ }); >+ } > > /* old format constant values */ > >@@ -655,6 +666,7 @@ > private static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_THROWS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_throws"; //$NON-NLS-1$ > private static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_THROWS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_throws"; //$NON-NLS-1$ > private static final String FORMATTER_NO_ALIGNMENT = "0";//$NON-NLS-1$ >+ private static final String FORMATTER_COMMENT_FORMAT2= JavaCore.PLUGIN_ID + ".formatter.comment.format_comments"; //$NON-NLS-1$ > > // Old comment formatter constants > private static final String FORMATTER_COMMENT_FORMATSOURCE= "comment_format_source_code"; //$NON-NLS-1$ >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java,v >retrieving revision 1.17 >diff -u -r1.17 FormatterMessages.java >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 21 Nov 2006 09:59:10 -0000 1.17 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 2 Feb 2007 01:29:21 -0000 >@@ -343,7 +343,9 @@ > public static String CodingStyleConfigurationBlock_preview_title; > > public static String CommentsTabPage_group1_title; >- public static String CommentsTabPage_enable_comment_formatting; >+ public static String commentsTabPage_enable_javadoc_comment_formatting; >+ public static String CommentsTabPage_enable_line_comment_formatting; >+ public static String CommentsTabPage_enable_block_comment_formatting; > public static String CommentsTabPage_format_header; > public static String CommentsTabPage_format_html; > public static String CommentsTabPage_format_code_snippets; >@@ -354,6 +356,7 @@ > public static String CommentsTabPage_indent_description_after_param; > public static String CommentsTabPage_new_line_after_param_tags; > public static String CommentsTabPage_group3_title; >+ public static String CommentsTabPage_group4_title; > public static String CommentsTabPage_line_width; > public static String ControlStatementsTabPage_preview_header; > public static String ControlStatementsTabPage_general_group_title; >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/CommentsTabPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/CommentsTabPage.java,v >retrieving revision 1.17 >diff -u -r1.17 CommentsTabPage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/CommentsTabPage.java 20 Nov 2006 16:15:11 -0000 1.17 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/CommentsTabPage.java 2 Feb 2007 01:29:21 -0000 >@@ -48,12 +48,12 @@ > }; > > >- private final static class Controller implements Observer { >+ private final static class AndController implements Observer { > > private final Collection fMasters; > private final Collection fSlaves; > >- public Controller(Collection masters, Collection slaves) { >+ public AndController(Collection masters, Collection slaves) { > fMasters= masters; > fSlaves= slaves; > for (final Iterator iter= fMasters.iterator(); iter.hasNext();) { >@@ -80,6 +80,37 @@ > } > } > >+ private final static class OrController implements Observer { >+ >+ private final Collection fMasters; >+ private final Collection fSlaves; >+ >+ public OrController(Collection masters, Collection slaves) { >+ fMasters= masters; >+ fSlaves= slaves; >+ for (final Iterator iter= fMasters.iterator(); iter.hasNext();) { >+ ((CheckboxPreference)iter.next()).addObserver(this); >+ } >+ update(null, null); >+ } >+ >+ public void update(Observable o, Object arg) { >+ boolean enabled= false; >+ >+ for (final Iterator iter= fMasters.iterator(); iter.hasNext();) { >+ enabled |= ((CheckboxPreference)iter.next()).getChecked(); >+ } >+ >+ for (final Iterator iter = fSlaves.iterator(); iter.hasNext();) { >+ final Object obj= iter.next(); >+ if (obj instanceof Preference) { >+ ((Preference)obj).setEnabled(enabled); >+ } else if (obj instanceof Control) { >+ ((Group)obj).setEnabled(enabled); >+ } >+ } >+ } >+ } > > private final String PREVIEW= > createPreviewHeader("An example for comment formatting. This example is meant to illustrate the various possibilities offered by <i>Eclipse</i> in order to format comments.") + //$NON-NLS-1$ >@@ -93,7 +124,15 @@ > " * These possibilities include:\n" + //$NON-NLS-1$ > " * <ul><li>Formatting of header comments.</li><li>Formatting of Javadoc tags</li></ul>\n" + //$NON-NLS-1$ > " */\n" + //$NON-NLS-1$ >- " int bar();" + //$NON-NLS-1$ >+ " int bar();\n" + //$NON-NLS-1$ >+ " /*\n" + //$NON-NLS-1$ >+ " *\n" + //$NON-NLS-1$ >+ " * These possibilities include:\n" + //$NON-NLS-1$ >+ " * <ul><li>Formatting of header comments.</li><li>Formatting of Javadoc tags</li></ul>\n" + //$NON-NLS-1$ >+ " */\n" + //$NON-NLS-1$ >+ " int bar2();" + //$NON-NLS-1$ >+ " // This is a long comment that should be split in multiple line comments in case the line comment formatting is enabled\n" + //$NON-NLS-1$ >+ " int foo2();" + //$NON-NLS-1$ > " /**\n" + //$NON-NLS-1$ > " * The following is some sample code which illustrates source formatting within javadoc comments:\n" + //$NON-NLS-1$ > " * <pre>public class Example {final int a= 1;final boolean b= true;}</pre>\n" + //$NON-NLS-1$ >@@ -116,17 +155,22 @@ > > // global group > final Group globalGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group1_title); >- final CheckboxPreference global= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_enable_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT); >- final CheckboxPreference header= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_format_header, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER); >- final CheckboxPreference html= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_format_html, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML); >- final CheckboxPreference code= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_format_code_snippets, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE); >+ final CheckboxPreference javadoc= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.commentsTabPage_enable_javadoc_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT); >+ final CheckboxPreference blockComment= createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_enable_block_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT); >+ createPrefTrueFalse(globalGroup, numColumns, FormatterMessages.CommentsTabPage_enable_line_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT); > >- // blank lines group >+ // javadoc comment formatting settings > final Group settingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group2_title); >- final CheckboxPreference blankComments= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_clear_blank_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES); >+ final CheckboxPreference header= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_header, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER); >+ final CheckboxPreference html= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_html, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML); >+ final CheckboxPreference code= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_code_snippets, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE); > final CheckboxPreference blankJavadoc= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_blank_line_before_javadoc_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS); > final CheckboxPreference indentJavadoc= createPrefTrueFalse(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_javadoc_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS); > >+ // javadoc and block comment settings >+ final Group javadocAndBlockSettingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group4_title); >+ final CheckboxPreference blankLines= createPrefTrueFalse(javadocAndBlockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_clear_blank_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES); >+ > final CheckboxPreference indentDesc= createCheckboxPref(settingsGroup, numColumns , FormatterMessages.CommentsTabPage_indent_description_after_param, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION, FALSE_TRUE); > ((GridData)indentDesc.getControl().getLayoutData()).horizontalIndent= fPixelConverter.convertWidthInCharsToPixels(4); > final CheckboxPreference nlParam= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_line_after_param_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER); >@@ -137,29 +181,37 @@ > Collection masters, slaves; > > masters= new ArrayList(); >- masters.add(global); >+ masters.add(javadoc); > > slaves= new ArrayList(); > slaves.add(settingsGroup); > slaves.add(header); > slaves.add(html); > slaves.add(code); >- slaves.add(blankComments); > slaves.add(blankJavadoc); > slaves.add(indentJavadoc); > slaves.add(nlParam); > slaves.add(lineWidth); > >- new Controller(masters, slaves); >+ new AndController(masters, slaves); > > masters= new ArrayList(); >- masters.add(global); >+ masters.add(javadoc); > masters.add(indentJavadoc); > > slaves= new ArrayList(); > slaves.add(indentDesc); > >- new Controller(masters, slaves); >+ new AndController(masters, slaves); >+ >+ masters= new ArrayList(); >+ masters.add(javadoc); >+ masters.add(blockComment); >+ >+ slaves= new ArrayList(); >+ slaves.add(blankLines); >+ >+ new OrController(masters, slaves); > } > > protected void initializePage() { >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties,v >retrieving revision 1.64 >diff -u -r1.64 FormatterMessages.properties >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 21 Nov 2006 09:59:10 -0000 1.64 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 2 Feb 2007 01:29:22 -0000 >@@ -386,7 +386,9 @@ > CodingStyleConfigurationBlock_preview_title=A sample source file for the code formatter preview > > CommentsTabPage_group1_title=General settings >-CommentsTabPage_enable_comment_formatting=Enable &comment formatting >+commentsTabPage_enable_javadoc_comment_formatting=Enable &javadoc comment formatting >+CommentsTabPage_enable_line_comment_formatting=Enable &line comment formatting >+CommentsTabPage_enable_block_comment_formatting=Enable &block comment formatting > CommentsTabPage_format_header=Format &header comment > CommentsTabPage_format_html=Format HTML ta&gs > CommentsTabPage_format_code_snippets=Format &Java code snippets >@@ -400,6 +402,7 @@ > CommentsTabPage_group3_title=Line width > CommentsTabPage_line_width=Ma&ximum line width for comments: > >+CommentsTabPage_group4_title=Javadoc and block comment settings > > ControlStatementsTabPage_preview_header=If...else > ControlStatementsTabPage_general_group_title=General >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.7 >diff -u -r1.7 CommentFormatFix.java >--- ui/org/eclipse/jdt/internal/ui/fix/CommentFormatFix.java 12 Jan 2007 15:50:46 -0000 1.7 >+++ ui/org/eclipse/jdt/internal/ui/fix/CommentFormatFix.java 2 Feb 2007 01:29:21 -0000 >@@ -106,8 +106,12 @@ > 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))) >- preferences.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT, DefaultCodeFormatterConstants.TRUE); >+ 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); > >Index: ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingContext.java,v >retrieving revision 1.16 >diff -u -r1.16 CommentFormattingContext.java >--- ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingContext.java 19 Apr 2005 12:47:31 -0000 1.16 >+++ ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingContext.java 2 Feb 2007 01:29:22 -0000 >@@ -27,7 +27,9 @@ > */ > public String[] getPreferenceKeys() { > return new String[] { >- DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT, >+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, >+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, >+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, > DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, > DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, > DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION,
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 49412
:
58077
|
58078
|
58079
|
58113