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 167278 Details for
Bug 311617
[formatter] provide default tags to enable/disable formatter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 5.40 KB, created by
Frederic Fusier
on 2010-05-06 05:51:01 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-05-06 05:51:01 EDT
Size:
5.40 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.111 >diff -u -r1.111 DefaultCodeFormatterConstants.java >--- formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 6 May 2010 09:30:57 -0000 1.111 >+++ formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 6 May 2010 09:49:19 -0000 >@@ -873,7 +873,7 @@ > * FORMATTER / Option to define the tag to put in a comment to disable the formatting. > * - option id: "org.eclipse.jdt.core.formatter.disabling_tag" > * - possible values: String, with constraints mentioned below >- * - default: "" >+ * - default: "@formatter:off" > * > * See the {@link #FORMATTER_ENABLING_TAG} option to re-enable it. > * </pre> >@@ -962,7 +962,7 @@ > * FORMATTER / Option to define the tag to put in a comment to re-enable the formatting after it has been disabled (see {@link #FORMATTER_DISABLING_TAG}) > * - option id: "org.eclipse.jdt.core.formatter.enabling_tag" > * - possible values: String, with constraints mentioned below >- * - default: "" >+ * - default: "@formatter:on" > * </pre> > * > * <p> >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.106 >diff -u -r1.106 DefaultCodeFormatterOptions.java >--- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 6 May 2010 09:30:57 -0000 1.106 >+++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 6 May 2010 09:49:21 -0000 >@@ -120,6 +120,8 @@ > public boolean use_tags; > public char[] disabling_tag; > public char[] enabling_tag; >+ private final static char[] DEFAULT_DISABLING_TAG = "@formatter:off".toCharArray(); //$NON-NLS-1$ >+ private final static char[] DEFAULT_ENABLING_TAG = "@formatter:on".toCharArray(); //$NON-NLS-1$ > > public boolean indent_statements_compare_to_block; > public boolean indent_statements_compare_to_body; >@@ -1973,7 +1975,7 @@ > if (tag.length() == 0) { > this.disabling_tag = null; > } else { >- this.disabling_tag = tag.toCharArray(); >+ this.disabling_tag = tag.toCharArray(); > } > } > } >@@ -1990,7 +1992,7 @@ > if (tag.length() == 0) { > this.enabling_tag = null; > } else { >- this.enabling_tag = tag.toCharArray(); >+ this.enabling_tag = tag.toCharArray(); > } > } > } >@@ -2306,6 +2308,8 @@ > this.use_tabs_only_for_leading_indentations = false; > this.wrap_before_binary_operator = true; > this.use_tags = false; >+ this.disabling_tag = DEFAULT_DISABLING_TAG; >+ this.enabling_tag = DEFAULT_ENABLING_TAG; > } > > public void setEclipseDefaultSettings() { >@@ -2578,5 +2582,7 @@ > this.use_tabs_only_for_leading_indentations = false; > this.wrap_before_binary_operator = true; > this.use_tags = false; >+ this.disabling_tag = DEFAULT_DISABLING_TAG; >+ this.enabling_tag = DEFAULT_ENABLING_TAG; > } > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java,v >retrieving revision 1.28 >diff -u -r1.28 FormatterBugsTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 6 May 2010 09:27:33 -0000 1.28 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 6 May 2010 09:49:26 -0000 >@@ -6063,4 +6063,50 @@ > ); > } > >+/** >+ * @bug 311617: [formatter] Master switch to enable/disable on/off tags >+ * @test Ensure that the formatter does not take care of formatting tags by default >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311617" >+ */ >+public void testBug0311617() throws JavaModelException { >+ this.formatterPrefs.use_tags = true; >+ String source = >+ "public class X01 {\n" + >+ "\n" + >+ "/* @formatter:off */\n" + >+ "void foo( ) { \n" + >+ " // unformatted comment\n" + >+ "}\n" + >+ "/* @formatter:on */\n" + >+ "void bar( ) { \n" + >+ " // formatted comment\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X01 {\n" + >+ "\n" + >+ "/* @formatter:off */\n" + >+ "void foo( ) { \n" + >+ " // unformatted comment\n" + >+ "}\n" + >+ "/* @formatter:on */\n" + >+ " void bar() {\n" + >+ " // formatted comment\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug0311617b() { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE); >+ String source = >+ "/* @formatter:off */\n" + >+ "public class X01 {\n" + >+ "void foo( ) { \n" + >+ " // unformatted area\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source); >+} >+ > }
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 311617
: 167278