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 146280 Details for
Bug 287833
[formatter] Formatter removes the first character after the * in the <pre> tag
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch
patch (text/plain), 5.32 KB, created by
Satyam Kandula
on 2009-09-02 09:56:46 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2009-09-02 09:56:46 EDT
Size:
5.32 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.173 >diff -u -r1.173 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 25 Aug 2009 07:47:23 -0000 1.173 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 2 Sep 2009 13:57:27 -0000 >@@ -1897,9 +1897,13 @@ > CommentFormatterUtil.log(e); > return; > } >- int prefixOffset= inputBuffer.indexOf(contentPrefix, lineOffset); >- if (prefixOffset >= 0 && inputBuffer.substring(lineOffset, prefixOffset).trim().length() == 0) >- inputBuffer.delete(lineOffset, prefixOffset + 1 + 1); >+ int prefixOffset = inputBuffer.indexOf(contentPrefix, lineOffset); >+ if (prefixOffset >= 0 && inputBuffer.substring(lineOffset, prefixOffset).trim().length() == 0) { >+ if (inputBuffer.charAt(prefixOffset + 1) == ' ' || inputBuffer.charAt(prefixOffset + 1) == '\t') >+ inputBuffer.delete(lineOffset, prefixOffset + 1 + 1); >+ else >+ inputBuffer.delete(lineOffset, prefixOffset + 1); >+ } > } > > // 2 - convert HTML to Java (@see JavaDocRegion#convertHtml2Java) >@@ -3330,23 +3334,29 @@ > if (isCode) { > int codeEnd = (int) (text.separators[max] >>> 32); > if (codeEnd > end) { >- if (this.formatter.preferences.comment_format_source) { >- if (textStart < end) addReplaceEdit(textStart, end, buffer.toString()); >+ if (this.formatter.preferences.comment_format_source) { >+ if (textStart < end) addReplaceEdit(textStart, end, buffer.toString()); > // Count the lines until the exact start position of the code > this.scanner.resetTo(end+1, nextStart-1); > int newLines = 0; >+ int realEnd = nextStart; >+ boolean spaceFound = true; > try { > int token = this.scanner.getNextToken(); > loop: while (true) { > switch (token) { > case TerminalTokens.TokenNameWHITESPACE: > if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition) < 0) { >+ if (realEnd != nextStart) >+ realEnd++; >+ spaceFound = true; > break loop; > } > newLines++; > break; > case TerminalTokens.TokenNameMULTIPLY: >- nextStart = this.scanner.currentPosition + 1; >+ realEnd = this.scanner.currentPosition; >+ spaceFound = false; > break; > default: > break loop; >@@ -3358,7 +3368,11 @@ > // skip > } > if (newLines == 0) newLines=1; >- printJavadocGapLines(end+1, nextStart-1, newLines, false/* clear first blank lines inside <pre> tag as done by old formatter */, false, null); >+ printJavadocGapLines(end+1, realEnd-1, newLines, false/* clear first blank lines inside <pre> tag as done by old formatter */, false, null); >+ if (realEnd < nextStart) >+ nextStart = realEnd; >+ if (spaceFound == false) >+ addInsertEdit(realEnd, " "); //$NON-NLS-1$ > printCodeSnippet(nextStart, codeEnd); > nextStart = (int) text.separators[max]; > printJavadocGapLines(codeEnd+1, nextStart-1, 1, false/* clear blank lines inside <pre> tag as done by old formatter */, false, null); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java,v >retrieving revision 1.21 >diff -u -r1.21 JavaDocTestCase.java >--- src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 27 Jun 2008 16:02:41 -0000 1.21 >+++ src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 2 Sep 2009 13:57:29 -0000 >@@ -27,7 +27,7 @@ > public class JavaDocTestCase extends CommentTestCase { > > static { >-// TESTS_NAMES = new String[] { "test109636_2" } ; >+ // TESTS_NAMES = new String[] { "testNoRemoveFirstCharacter" } ; > } > > protected static final String INFIX= MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; >@@ -1012,4 +1012,34 @@ > String result = testFormat(input, 62, 19, CodeFormatter.K_JAVA_DOC, options); > assertEquals(expected, result); > } >+ >+ /** >+ * [formatter] Formatter removes the first character after the * in the <pre> tag >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=287833 >+ */ >+ public void testNoRemoveFirstCharacter() { >+ String input= PREFIX + DELIMITER + >+ INFIX + "<pre>" + DELIMITER + >+ " *void foo() {" + DELIMITER + >+ " *}" + DELIMITER + >+ " * </pre>" + DELIMITER + >+ POSTFIX; >+ >+ String expected = PREFIX + DELIMITER + >+ INFIX + "<pre>" + DELIMITER + >+ " * void foo() {" + DELIMITER + >+ " * }" + DELIMITER + >+ " * </pre>" + DELIMITER + >+ POSTFIX; >+ String result= testFormat(input); >+ assertEquals(expected, result); >+ >+ // now re-format several times >+ result= testFormat(result); >+ result= testFormat(result); >+ result= testFormat(result); >+ result= testFormat(result); >+ >+ assertEquals(expected, result); >+ } > }
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 287833
:
146280
|
147524
|
147536
|
147885