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 159410 Details for
Bug 150741
[formatter] Add option: "add new line after label"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v01.txt (text/plain), 8.48 KB, created by
Frederic Fusier
on 2010-02-18 05:35:39 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-02-18 05:35:39 EST
Size:
8.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: buildnotes_jdt-core.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v >retrieving revision 1.7302 >diff -u -r1.7302 buildnotes_jdt-core.html >--- buildnotes_jdt-core.html 17 Feb 2010 15:05:51 -0000 1.7302 >+++ buildnotes_jdt-core.html 18 Feb 2010 09:31:35 -0000 >@@ -48,6 +48,46 @@ > <br>Project org.eclipse.jdt.core v_A36 > (<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_A36">cvs</a>). > <h2>What's new in this drop</h2> >+<ul> >+<li> >+Added a new formatter preferences to insert a new line after a label. >+<p> >+This new preference is controlled with the option:<br> >+<code>DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_LABEL</code> >+<pre> >+/** >+ * FORMATTER / Option to insert a new line after a label >+ * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_after_label" >+ * - possible values: { INSERT, DO_NOT_INSERT } >+ * - default: INSERT >+ * >+ * @see JavaCore#INSERT >+ * @see JavaCore#DO_NOT_INSERT >+ * @since 3.6 >+ */ >+</pre> >+</p> >+For example, the following snippet: >+<pre> >+public class X { >+ void foo() { >+ LABEL:for (int i = 0; i < 10; i++) { >+ } >+ } >+} >+</pre> >+formatted with this preference activated, will produce the following output: >+<pre> >+public class X { >+ void foo() { >+ LABEL: >+ for (int i = 0; i < 10; i++) { >+ } >+ } >+} >+</pre> >+</li> >+</ul> > > <h3>Problem Reports Fixed</h3> > <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=295619">295619</a> >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.98 >diff -u -r1.98 DefaultCodeFormatterConstants.java >--- formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 27 Aug 2009 15:27:02 -0000 1.98 >+++ formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 18 Feb 2010 09:31:37 -0000 >@@ -1155,6 +1155,18 @@ > public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_in_empty_type_declaration"; //$NON-NLS-1$ > /** > * <pre> >+ * FORMATTER / Option to insert a new line after a label >+ * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_after_label" >+ * - possible values: { INSERT, DO_NOT_INSERT } >+ * - default: INSERT >+ * </pre> >+ * @see JavaCore#INSERT >+ * @see JavaCore#DO_NOT_INSERT >+ * @since 3.6 >+ */ >+ public static final String FORMATTER_INSERT_NEW_LINE_AFTER_LABEL = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_label"; //$NON-NLS-1$ >+ /** >+ * <pre> > * FORMATTER / Option to insert a space after and in wilcard > * - option id: "org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" > * - possible values: { INSERT, DO_NOT_INSERT } >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 18 Feb 2010 09:31:39 -0000 >@@ -4012,6 +4012,9 @@ > if (this.preferences.insert_space_after_colon_in_labeled_statement) { > this.scribe.space(); > } >+ if (this.preferences.insert_new_line_after_label) { >+ this.scribe.printNewLine(); >+ } > final Statement statement = labeledStatement.statement; > statement.traverse(this, scope); > if (statement instanceof Expression) { >Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java,v >retrieving revision 1.94 >diff -u -r1.94 DefaultCodeFormatterOptions.java >--- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 8 Dec 2008 15:54:27 -0000 1.94 >+++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 18 Feb 2010 09:31:41 -0000 >@@ -139,6 +139,7 @@ > public boolean insert_new_line_in_empty_enum_declaration; > public boolean insert_new_line_in_empty_method_body; > public boolean insert_new_line_in_empty_type_declaration; >+ public boolean insert_new_line_after_label; > public boolean insert_space_after_and_in_type_parameter; > public boolean insert_space_after_assignment_operator; > public boolean insert_space_after_at_in_annotation; >@@ -418,6 +419,7 @@ > options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION, this.insert_new_line_in_empty_enum_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); > options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, this.insert_new_line_in_empty_method_body? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); > options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, this.insert_new_line_in_empty_type_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_LABEL, this.insert_new_line_after_label? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); > options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER, this.insert_space_after_and_in_type_parameter? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); > options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, this.insert_space_after_assignment_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); > options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION, this.insert_space_after_at_in_annotation? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); >@@ -1192,6 +1194,10 @@ > if (insertNewLineInEmptyTypeDeclarationOption != null) { > this.insert_new_line_in_empty_type_declaration = JavaCore.INSERT.equals(insertNewLineInEmptyTypeDeclarationOption); > } >+ final Object insertNewLineAfterLabelOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_LABEL); >+ if (insertNewLineAfterLabelOption != null) { >+ this.insert_new_line_after_label = JavaCore.INSERT.equals(insertNewLineAfterLabelOption); >+ } > final Object insertSpaceAfterAndInWildcardOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER); > if (insertSpaceAfterAndInWildcardOption != null) { > this.insert_space_after_and_in_type_parameter = JavaCore.INSERT.equals(insertSpaceAfterAndInWildcardOption); >#P org.eclipse.jdt.core.tests.model >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 18 Feb 2010 09:31:51 -0000 >@@ -10622,4 +10622,27 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); > runTest(codeFormatter, "test723", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=150741 >+public void test724() { >+ this.formatterPrefs.insert_new_line_after_label = true; >+ String source = >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " LABEL:for (int i = 0; i < 10; i++) {\n" + >+ " }\n" + >+ " }\n" + >+ "\n" + >+ "}\n" + >+ ""; >+ formatSource(source, >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " LABEL:\n" + >+ " for (int i = 0; i < 10; i++) {\n" + >+ " }\n" + >+ " }\n" + >+ "\n" + >+ "}\n" >+ ); >+} > }
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
Flags:
frederic_fusier
:
iplog+
frederic_fusier
:
review+
Actions:
View
|
Diff
Attachments on
bug 150741
:
87246
|
110309
|
159312
|
159313
| 159410