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 101455 Details for
Bug 233228
[formatter] line comments which contains \\u are not correctly formatted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 12.75 KB, created by
Frederic Fusier
on 2008-05-22 05:39:16 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2008-05-22 05:39:16 EDT
Size:
12.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: workspace/FormatterJavadoc/test/comments/block/out/default/X05db.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/comments/block/out/default/X05db.java,v >retrieving revision 1.1 >diff -u -r1.1 X05db.java >--- workspace/FormatterJavadoc/test/comments/block/out/default/X05db.java 23 Apr 2008 10:13:39 -0000 1.1 >+++ workspace/FormatterJavadoc/test/comments/block/out/default/X05db.java 22 May 2008 09:37:19 -0000 >@@ -3,6 +3,6 @@ > public class X05db { > > /* >- * 3. "This" >+ * 3. "This " > */ > } >Index: workspace/FormatterJavadoc/test/comments/block/out/default/X05dc.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/comments/block/out/default/X05dc.java,v >retrieving revision 1.1 >diff -u -r1.1 X05dc.java >--- workspace/FormatterJavadoc/test/comments/block/out/default/X05dc.java 23 Apr 2008 10:13:39 -0000 1.1 >+++ workspace/FormatterJavadoc/test/comments/block/out/default/X05dc.java 22 May 2008 09:37:19 -0000 >@@ -5,7 +5,7 @@ > } > > /* >- * Text "String" >+ * Text "String " > */ >-class Y05 { >+class Y05dc { > } >\ No newline at end of file >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v >retrieving revision 1.5 >diff -u -r1.5 FormatterCommentsBugsTest.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 21 May 2008 14:17:44 -0000 1.5 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 22 May 2008 09:37:19 -0000 >@@ -180,12 +180,30 @@ > * @test Insure that new formatter do not add/remove stars in header and footer > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=232466" > */ >-public void testBug233466a() throws JavaModelException { >+public void testBug232466a() throws JavaModelException { > this.preferences.comment_line_length = 40; > formatUnit("bugs.b232466", "X01.java"); > } >-public void testBug233466b() throws JavaModelException { >+public void testBug232466b() throws JavaModelException { > this.preferences.comment_line_length = 40; > formatUnit("bugs.b232466", "X02.java"); > } >+ >+/** >+ * @bug 233228: [formatter] References of inlined tags are still split in certain circumstances >+ * @test Insure that new formatter do not add/remove stars in header and footer >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=233228" >+ */ >+public void testBug233228a() throws JavaModelException { >+ formatUnit("bugs.b233228", "X01.java"); >+} >+public void testBug233228b() throws JavaModelException { >+ formatUnit("bugs.b233228", "X01b.java"); >+} >+public void testBug233228c() throws JavaModelException { >+ formatUnit("bugs.b233228", "X01c.java"); >+} >+public void testBug233228d() throws JavaModelException { >+ formatUnit("bugs.b233228", "X02.java"); >+} > } >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java,v >retrieving revision 1.19 >diff -u -r1.19 FormatterCommentsTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 20 May 2008 13:12:48 -0000 1.19 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 22 May 2008 09:37:19 -0000 >@@ -965,7 +965,7 @@ > public void testWkspEclipse11c() throws JavaModelException { > formatUnit("wksp.eclipse", "X11c.java"); > } >-public void testWkspEclipse12() throws JavaModelException { >+public void testONLY_WkspEclipse12() throws JavaModelException { > // Difference with old formatter: > // 1) fixed wrong max length with immutable tags > // TODO the string is now put on 2 lines >Index: workspace/FormatterJavadoc/test/comments/block/X05dc.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/comments/block/X05dc.java,v >retrieving revision 1.1 >diff -u -r1.1 X05dc.java >--- workspace/FormatterJavadoc/test/comments/block/X05dc.java 23 Apr 2008 10:13:39 -0000 1.1 >+++ workspace/FormatterJavadoc/test/comments/block/X05dc.java 22 May 2008 09:37:19 -0000 >@@ -9,5 +9,5 @@ > * "String > * " > */ >-class Y05 { >+class Y05dc { > } >\ No newline at end of file >Index: workspace/FormatterJavadoc/test/bugs/b233228/X01.java >=================================================================== >RCS file: workspace/FormatterJavadoc/test/bugs/b233228/X01.java >diff -N workspace/FormatterJavadoc/test/bugs/b233228/X01.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/FormatterJavadoc/test/bugs/b233228/X01.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+public class X01 { >+ // handle the \\u case manually into comment >+} >Index: workspace/FormatterJavadoc/test/bugs/b233228/X02.java >=================================================================== >RCS file: workspace/FormatterJavadoc/test/bugs/b233228/X02.java >diff -N workspace/FormatterJavadoc/test/bugs/b233228/X02.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/FormatterJavadoc/test/bugs/b233228/X02.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,15 @@ >+public class X02 { >+ void foo() { >+ if (true) { >+ if (true) { >+ /* >+ "If we are about to consider an unchecked exception handler, potential inits may have occured inside >+ the try block that need to be detected , e.g. >+ try { x = 1; throwSomething();} catch(Exception e){ x = 2} " >+ "(uncheckedExceptionTypes notNil and: [uncheckedExceptionTypes at: index]) >+ ifTrue: [catchInits addPotentialInitializationsFrom: tryInits]." >+ */ >+ } >+ } >+ } >+} >Index: workspace/FormatterJavadoc/test/bugs/b233228/out/X02.java >=================================================================== >RCS file: workspace/FormatterJavadoc/test/bugs/b233228/out/X02.java >diff -N workspace/FormatterJavadoc/test/bugs/b233228/out/X02.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/FormatterJavadoc/test/bugs/b233228/out/X02.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,16 @@ >+public class X02 { >+ void foo() { >+ if (true) { >+ if (true) { >+ /* >+ * "If we are about to consider an unchecked exception handler, >+ * potential inits may have occured inside the try block that >+ * need to be detected , e.g. try { x = 1; throwSomething();} >+ * catch(Exception e){ x = 2} " "(uncheckedExceptionTypes notNil >+ * and: [uncheckedExceptionTypes at: index]) ifTrue: [catchInits >+ * addPotentialInitializationsFrom: tryInits]." >+ */ >+ } >+ } >+ } >+} >Index: workspace/FormatterJavadoc/test/bugs/b233228/X01c.java >=================================================================== >RCS file: workspace/FormatterJavadoc/test/bugs/b233228/X01c.java >diff -N workspace/FormatterJavadoc/test/bugs/b233228/X01c.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/FormatterJavadoc/test/bugs/b233228/X01c.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+public class X01c { >+ /** >+ * handle the \\u case manually into comment >+ */ >+} >Index: workspace/FormatterJavadoc/test/bugs/b233228/X01b.java >=================================================================== >RCS file: workspace/FormatterJavadoc/test/bugs/b233228/X01b.java >diff -N workspace/FormatterJavadoc/test/bugs/b233228/X01b.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/FormatterJavadoc/test/bugs/b233228/X01b.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+public class X01b { >+ /* handle the \\u case manually into comment */ >+} >#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.138 >diff -u -r1.138 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 21 May 2008 14:17:47 -0000 1.138 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 22 May 2008 09:37:21 -0000 >@@ -324,6 +324,27 @@ > } > } > >+ private int consumeInvalidToken(int end) { >+ this.scanner.resetTo(this.scanner.startPosition, end); >+ // In case of invalid unicode character, consume the current backslash character before continuing >+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233228 >+ if (this.scanner.currentCharacter == '\\') { >+ this.scanner.currentPosition = this.scanner.startPosition+1; >+ } >+ int previousPosition = this.scanner.currentPosition; >+ char ch = (char) this.scanner.getNextChar(); >+ while (!this.scanner.atEnd() && !ScannerHelper.isWhitespace(ch)) { >+ previousPosition = this.scanner.currentPosition; >+ ch = (char) this.scanner.getNextChar(); >+ } >+ if (this.scanner.atEnd()) { >+ return TerminalTokens.TokenNameEOF; >+ } >+ // restore last whitespace >+ this.scanner.currentPosition = previousPosition; >+ return 2000; // invalid token >+ } >+ > public Alignment createAlignment(String name, int mode, int count, int sourceRestart){ > return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); > } >@@ -1169,7 +1190,6 @@ > int firstLine = scannerLine; > int lineNumber = scannerLine; > int lastTextLine = -1; >- boolean openedString = false; > while (!this.scanner.atEnd()) { > > // Consume token >@@ -1177,32 +1197,8 @@ > try { > token = this.scanner.getNextToken(); > } catch (InvalidInputException iie) { >- String msg = iie.getMessage(); >- boolean insertSpace = (previousToken == TerminalTokens.TokenNameWHITESPACE || newLine) && !firstWord; >- if (msg == Scanner.INVALID_CHARACTER_CONSTANT) { >- if (insertSpace) { >- tokensBuffer.append(' '); >- } >- tokensBuffer.append('\''); >- } else if (msg == Scanner.INVALID_CHAR_IN_STRING) { >- if (openedString) { >- openedString = false; >- } else { >- if (insertSpace) { >- tokensBuffer.append(' '); >- } >- openedString = true; >- } >- tokensBuffer.append('"'); >- } else { >- // skip failure >- } >- // Need to retrieve correct position >- this.scanner.resetTo(this.scanner.startPosition, currentTokenEndPosition-1); >- this.scanner.getNextChar(); >- previousToken = 2000; >+ token = consumeInvalidToken(currentTokenEndPosition-1); > newLine = false; >- continue; > } > > // Look at specific tokens >@@ -1896,21 +1892,7 @@ > try { > token = this.scanner.getNextToken(); > } catch (InvalidInputException iie) { >- if (previousToken == -1 || previousToken == TerminalTokens.TokenNameWHITESPACE) { >- tokensBuffer.append(' '); >- } >- this.scanner.resetTo(this.scanner.startPosition, commentEnd); >- char ch = (char) this.scanner.getNextChar(); >- previousToken = TerminalTokens.TokenNameWHITESPACE; >- while (!ScannerHelper.isWhitespace(ch)) { >- tokensBuffer.append(ch); >- if (this.scanner.atEnd()) { >- previousToken = TerminalTokens.TokenNameEOF; >- break; >- } >- ch = (char) this.scanner.getNextChar(); >- } >- continue; >+ token = consumeInvalidToken(commentEnd); > } > switch (token) { > case TerminalTokens.TokenNameWHITESPACE: >@@ -3140,29 +3122,7 @@ > try { > token = this.scanner.getNextToken(); > } catch (InvalidInputException iie) { >- boolean insertSpace = (previousToken == TerminalTokens.TokenNameWHITESPACE || this.needSpace) && !isHtmlTag && !textOnNewLine; >- if (insertSpace) { >- tokensBuffer.append(' '); >- } >- int restart = this.scanner.startPosition; >- this.scanner.resetTo(restart, textEnd); >- char ch = (char) this.scanner.getNextChar(); >- while (!this.scanner.atEnd() && !ScannerHelper.isWhitespace(ch)) { >- tokensBuffer.append(ch); >- if (this.scanner.atEnd()) { >- previousToken = TerminalTokens.TokenNameEOF; >- break; >- } >- restart = this.scanner.currentPosition; >- ch = (char) this.scanner.getNextChar(); >- } >- // restart at the beginning of the whitespace >- if (this.scanner.atEnd()) { >- tokensBuffer.append(ch); >- } else { >- this.scanner.resetTo(restart, textEnd); >- } >- continue; >+ token = consumeInvalidToken(textEnd); > } > int tokensBufferLength = tokensBuffer.length(); > int tokenStart = this.scanner.getCurrentTokenStartPosition();
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 233228
:
101455
|
101466