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 160798 Details for
Bug 304529
[formatter] NPE when either the disabling or the enabling tag is not defined
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 5.16 KB, created by
Frederic Fusier
on 2010-03-03 11:30:48 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-03-03 11:30:48 EST
Size:
5.16 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v >retrieving revision 1.197 >diff -u -r1.197 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 3 Mar 2010 11:17:30 -0000 1.197 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 3 Mar 2010 16:27:54 -0000 >@@ -1298,8 +1298,14 @@ > this.disablingTag = preferences.disabling_tag; > this.enablingTag = preferences.enabling_tag; > char[][] taskTags; >- if (this.disablingTag == null && this.enablingTag == null) { >- taskTags = null; >+ if (this.disablingTag == null) { >+ if (this.enablingTag == null) { >+ taskTags = null; >+ } else { >+ taskTags = new char[][] { this.enablingTag }; >+ } >+ } else if (this.enablingTag == null) { >+ taskTags = new char[][] { this.disablingTag }; > } else { > taskTags = new char[][] { this.disablingTag, this.enablingTag }; > } >@@ -4742,10 +4748,10 @@ > */ > private void setEditsEnabled(int count, int previous) { > for (int i=previous; i<count; i++) { >- if (CharOperation.equals(this.scanner.foundTaskTags[i], this.disablingTag)) { >+ if (this.disablingTag != null && CharOperation.equals(this.scanner.foundTaskTags[i], this.disablingTag)) { > this.editsEnabled = false; > } >- if (CharOperation.equals(this.scanner.foundTaskTags[i], this.enablingTag)) { >+ if (this.enablingTag != null && CharOperation.equals(this.scanner.foundTaskTags[i], this.enablingTag)) { > this.editsEnabled = true; > } > } >#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.24 >diff -u -r1.24 FormatterBugsTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 2 Mar 2010 18:29:02 -0000 1.24 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 3 Mar 2010 16:27:56 -0000 >@@ -5275,4 +5275,102 @@ > ); > } > >+/** >+ * @bug 304529: [formatter] NPE when either the disabling or the enabling tag is not defined >+ * @test Verify that having an empty disabling or enabling is now accepted by the formatter >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304529" >+ */ >+public void testBug304529() { >+ this.formatterPrefs.disabling_tag = "off".toCharArray(); >+ this.formatterPrefs.enabling_tag = null; >+ String source = >+ "/* off */\n" + >+ "public class X01 {\n" + >+ "void foo( ) { \n" + >+ " // unformatted area\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source); >+} >+public void testBug304529b() { >+ this.formatterPrefs.disabling_tag = null; >+ this.formatterPrefs.enabling_tag = "on".toCharArray(); >+ String source = >+ "/* on */\n" + >+ "public class X01 {\n" + >+ "void foo( ) { \n" + >+ " // formatted area\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source, >+ "/* on */\n" + >+ "public class X01 {\n" + >+ " void foo() {\n" + >+ " // formatted area\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug304529c() { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "off"); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, ""); >+ String source = >+ "/* off */\n" + >+ "public class X01 {\n" + >+ "void foo( ) { \n" + >+ " // unformatted area\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source); >+} >+public void testBug304529d() { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, ""); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, "on"); >+ String source = >+ "/* on */\n" + >+ "public class X01 {\n" + >+ "void foo( ) { \n" + >+ " // formatted area\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source, >+ "/* on */\n" + >+ "public class X01 {\n" + >+ " void foo() {\n" + >+ " // formatted area\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug304529e() { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "off"); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, "on"); >+ String source = >+ "public class X01 {\n" + >+ "/* off */\n" + >+ "void foo( ) { \n" + >+ " // unformatted area\n" + >+ "}\n" + >+ "/* on */\n" + >+ "void bar( ) { \n" + >+ " // formatted area\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X01 {\n" + >+ "/* off */\n" + >+ "void foo( ) { \n" + >+ " // unformatted area\n" + >+ "}\n" + >+ "/* on */\n" + >+ " void bar() {\n" + >+ " // formatted area\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
Actions:
View
|
Diff
Attachments on
bug 304529
: 160798