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 85645 Details for
Bug 213283
[formatter] AIOOBE when formatting region
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
[proposed patch + test cases] on top v830 - all jdt.core tests OK
patch_for_bug213283_top_HEAD(v830)_v02.txt (text/plain), 16.21 KB, created by
Eric Jodet
on 2007-12-20 06:55:39 EST
(
hide
)
Description:
[proposed patch + test cases] on top v830 - all jdt.core tests OK
Filename:
MIME Type:
Creator:
Eric Jodet
Created:
2007-12-20 06:55:39 EST
Size:
16.21 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.111 >diff -u -r1.111 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 26 Nov 2007 16:05:56 -0000 1.111 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 20 Dec 2007 07:35:13 -0000 >@@ -130,7 +130,7 @@ > int lowerBound = 0; > boolean upperFound = false; > int regionEnd = offset + length; >- for (int j = 0, max2 = this.editsIndex; j < max2; j++) { >+ for (int j = 0, max2 = this.editsIndex; j <= max2; j++) { > // search for lower bound > int editOffset = this.edits[j].offset; > if (upperFound && lowerBound == 0) { >@@ -146,11 +146,22 @@ > } > // search for upper bound > } else { >- if (this.edits[j + 1].offset < offset) { >+ int next = j+1; >+ if (next == max2) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213284 >+ // checked all edits, no upper bound found: leave the loop >+ break; >+ } >+ if (this.edits[next].offset < offset) { > continue; > } else { > upperBound = editOffset; > upperFound = true; >+ // verify if region end is at EOF >+ if (this.scannerEndPosition == regionEnd + 1) { >+ lowerBound = this.scannerEndPosition; >+ break; >+ } > } > } > } >@@ -737,19 +748,28 @@ > * @return boolean true if line should be adapted, false otherwhise > */ > private boolean isAdaptableRegion(int offset, int length) { >- int regionEnd = offset + length + this.lineSeparator.length() - 1; >+ int regionEnd = offset + length; >+ > // first check region width > if (regionEnd > this.pageWidth) { > return false; > } >+ > int numberOfLineEnds = this.lineEnds != null && this.lineEnds.length > 0 ? this.lineEnds.length : 0; >+ if (this.line == numberOfLineEnds + 1) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213283 >+ return true; // last line of the CU >+ } >+ > if (this.line > 1 && numberOfLineEnds > 0) { // CU has more than one line > int lineNumber = Util.getLineNumber(offset, this.lineEnds, 0, this.line); > int lineEnd = this.getLineEnd(lineNumber); > if (regionEnd > lineEnd) { > // if more than one line selected, check whether selection is at line end > for (int i = lineNumber + 1 ; i <= numberOfLineEnds ; i++) { >- if (regionEnd == this.getLineEnd(i)) { >+ int nextLineEnd = this.getLineEnd(i); >+ // accept both line ends and line starts >+ if (regionEnd == nextLineEnd || regionEnd == nextLineEnd + 1) { > return true; > } > } >#P org.eclipse.jdt.core.tests.model >Index: workspace/Formatter/test688/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test688/A_out.java,v >retrieving revision 1.2 >diff -u -r1.2 A_out.java >--- workspace/Formatter/test688/A_out.java 23 Nov 2007 14:46:59 -0000 1.2 >+++ workspace/Formatter/test688/A_out.java 20 Dec 2007 07:35:51 -0000 >@@ -1,3 +1,3 @@ > public class A { > int i = 1; >-} >+} >\ No newline at end of file >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.221 >diff -u -r1.221 FormatterRegressionTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 26 Nov 2007 16:06:04 -0000 1.221 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 20 Dec 2007 07:35:51 -0000 >@@ -9618,7 +9618,7 @@ > } > > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 >- public void test688() { >+ public void test688a() { > final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); > DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >@@ -9628,6 +9628,16 @@ > runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ > } > >+ public void test688b() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(18, 49) >+ }; >+ runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 > public void test689() { > final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >@@ -9695,4 +9705,112 @@ > }; > runTest(codeFormatter, "test693", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ > } >+ >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213283 >+ public void test694a() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(33, 32) >+ }; >+ runTest(codeFormatter, "test694", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213283 >+ public void test694b() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(33, 33) >+ }; >+ runTest(codeFormatter, "test694", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213284 >+ public void test695() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(59, 1) >+ }; >+ runTest(codeFormatter, "test695", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // variation on bugs 208541, 213283, 213284 >+ public void test696a() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(17, 56) >+ }; >+ runTest(codeFormatter, "test696a", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // variation on bugs 208541, 213283, 213284 >+ public void test696b() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(17, 57) >+ }; >+ runTest(codeFormatter, "test696b", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // variation on bugs 208541, 213283, 213284 >+ public void test697a() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(17, 55) // end of line selection >+ }; >+ runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // variation on bugs 208541, 213283, 213284 >+ public void test697b() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(17, 56) // end of line selection + 1 >+ }; >+ runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // variation on bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 >+// public void testONLY_698() { >+// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+// preferences.line_separator = "\n";//$NON-NLS-1$ >+// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+// IRegion[] regions = new IRegion[] { >+// new Region(17, 40) // partial line selection >+// }; >+// runTest(codeFormatter, "test698", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+// } >+ >+ // variation on bugs 208541, 213283, 213284 >+ public void test699() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.line_separator = "\n";//$NON-NLS-1$ >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(0, 78) // nothing selected --> format all >+ }; >+ runTest(codeFormatter, "test699", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+ } > } >Index: workspace/Formatter/test696b/A_out.java >=================================================================== >RCS file: workspace/Formatter/test696b/A_out.java >diff -N workspace/Formatter/test696b/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test696b/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+public class A { >+ >+ int i = 1; >+} >Index: workspace/Formatter/test696a/A_out.java >=================================================================== >RCS file: workspace/Formatter/test696a/A_out.java >diff -N workspace/Formatter/test696a/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test696a/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+public class A { >+ >+ int i = 1; >+} >Index: workspace/Formatter/test696a/A_in.java >=================================================================== >RCS file: workspace/Formatter/test696a/A_in.java >diff -N workspace/Formatter/test696a/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test696a/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+public class A { >+ >+ >+ >+ int i = 1; >+} >Index: workspace/Formatter/test696b/A_in.java >=================================================================== >RCS file: workspace/Formatter/test696b/A_in.java >diff -N workspace/Formatter/test696b/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test696b/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+public class A { >+ >+ >+ >+ int i = 1; >+} >Index: workspace/Formatter/test694/A_in.java >=================================================================== >RCS file: workspace/Formatter/test694/A_in.java >diff -N workspace/Formatter/test694/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test694/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+package test1; >+public class A { >+ >+ public int field; >+} >Index: workspace/Formatter/test695/A_in.java >=================================================================== >RCS file: workspace/Formatter/test695/A_in.java >diff -N workspace/Formatter/test695/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test695/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+package test1; >+public class A { >+ >+ public int field; >+ >+ >+} >Index: workspace/Formatter/test697/A_in.java >=================================================================== >RCS file: workspace/Formatter/test697/A_in.java >diff -N workspace/Formatter/test697/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test697/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+public class A { >+ >+ >+ >+ int i = 1; >+ >+ >+ >+} >Index: workspace/Formatter/test698/A_in.java >=================================================================== >RCS file: workspace/Formatter/test698/A_in.java >diff -N workspace/Formatter/test698/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test698/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+public class A { >+ >+ >+ >+ int i = 1; >+ >+ >+ >+} >Index: workspace/Formatter/test699/A_in.java >=================================================================== >RCS file: workspace/Formatter/test699/A_in.java >diff -N workspace/Formatter/test699/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test699/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+public class A { >+ >+ >+ >+ int i = 1; >+ >+ >+ >+} >Index: workspace/Formatter/test699/A_out.java >=================================================================== >RCS file: workspace/Formatter/test699/A_out.java >diff -N workspace/Formatter/test699/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test699/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+public class A { >+ >+ int i = 1; >+ >+} >Index: workspace/Formatter/test698/A_out.java >=================================================================== >RCS file: workspace/Formatter/test698/A_out.java >diff -N workspace/Formatter/test698/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test698/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+public class A { >+ >+ int i = 1; >+ >+} >Index: workspace/Formatter/test697/A_out.java >=================================================================== >RCS file: workspace/Formatter/test697/A_out.java >diff -N workspace/Formatter/test697/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test697/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+public class A { >+ >+ int i = 1; >+ >+} >Index: workspace/Formatter/test695/A_out.java >=================================================================== >RCS file: workspace/Formatter/test695/A_out.java >diff -N workspace/Formatter/test695/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test695/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+package test1; >+public class A { >+ >+ public int field; >+ >+ >+} >Index: workspace/Formatter/test694/A_out.java >=================================================================== >RCS file: workspace/Formatter/test694/A_out.java >diff -N workspace/Formatter/test694/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test694/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+package test1; >+public class A { >+ >+ public int field; >+}
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 213283
: 85645