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 147536 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]
Other proposed patch
v02.txt (text/plain), 7.42 KB, created by
Frederic Fusier
on 2009-09-18 06:43:50 EDT
(
hide
)
Description:
Other proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2009-09-18 06:43:50 EDT
Size:
7.42 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >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.46 >diff -u -r1.46 FormatterCommentsBugsTest.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 22 Jun 2009 11:10:32 -0000 1.46 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 18 Sep 2009 10:36:01 -0000 >@@ -26,7 +26,9 @@ > public static Test suite() { > return buildModelTestSuite(FormatterCommentsBugsTest.class); > } >- >+static { >+ //TESTS_NAMES = new String[] { "testBug287833b" } ; >+ } > public FormatterCommentsBugsTest(String name) { > super(name); > } >@@ -4848,4 +4850,100 @@ > ); > } > >+/** >+ * [formatter] Formatter removes the first character after the * in the <pre> tag >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=287833 >+ */ >+public void testBug287833a() { >+ String source = >+ "public class test1 {\n" + >+ "/**\n"+ >+ "* <pre>\n"+ >+ "*void foo() {\n"+ >+ "*}\n"+ >+ "* </pre>\n"+ >+ "*/\n"+ >+ "void foo() {\n"+ >+ "}\n"+ >+ "}\n"; >+ >+ formatSource(source, >+ "public class test1 {\n"+ >+ " /**\n"+ >+ " * <pre>\n"+ >+ " * void foo() {\n"+ >+ " * }\n"+ >+ " * </pre>\n"+ >+ " */\n"+ >+ " void foo() {\n"+ >+ " }\n" + >+ "}\n"); >+} >+ >+/** >+ * [formatter] Formatter removes the first character after the * in the <pre> tag >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=287833 >+ */ >+public void testBug287833b() { >+ String source = >+ "public class test1 {\n" + >+ "/**\n"+ >+ "* <pre>\n"+ >+ "* void foo() {\n"+ >+ "*\r\n"+ >+ "* }\n"+ >+ "* </pre>\n"+ >+ "*/ \n"+ >+ "void foo() {\n"+ >+ "}\n"+ >+ "}\n"; >+ >+ formatSource(source, >+ "public class test1 {\n"+ >+ " /**\n"+ >+ " * <pre>\n"+ >+ " * void foo() {\n"+ >+ " * \r\n" + >+ " * }\n"+ >+ " * </pre>\n"+ >+ " */\n"+ >+ " void foo() {\n"+ >+ " }\n" + >+ "}\n"); >+} >+ >+/** >+ * [formatter] Formatter removes the first character after the * in the <pre> tag >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=287833 >+ */ >+public void testBug287833c() { >+ String source = >+ "public class test1 {\n" + >+ "/**\n"+ >+ "* <pre>\n"+ >+ "* void foo() {\n"+ >+ "*\n"+ >+ "* }\n"+ >+ "* </pre>\n"+ >+ "*/ \n"+ >+ "void foo() {\n"+ >+ "}\n"+ >+ "}\n"; >+ >+ formatSource(source, >+ "public class test1 {\n"+ >+ " /**\n"+ >+ " * <pre>\n"+ >+ " * void foo() {\n"+ >+ " * \n" + >+ " * }\n"+ >+ " * </pre>\n"+ >+ " */\n"+ >+ " void foo() {\n"+ >+ " }\n" + >+ "}\n"); >+} >+ >+ >+ > } >#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 18 Sep 2009 10:36:03 -0000 >@@ -1897,9 +1897,27 @@ > 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) { >+ int offsetEnd = prefixOffset + 1; >+ char ch = inputBuffer.charAt(offsetEnd); >+ switch (ch) { >+ case '\n': >+ case '\r': >+ break; >+ case ' ': >+ case '\t': >+ case '\u000c' : /* FORM FEED */ >+ offsetEnd++; >+ break; >+ default: >+ if (ScannerHelper.isWhitespace(ch)) { >+ offsetEnd++; >+ } >+ break; >+ } >+ inputBuffer.delete(lineOffset, offsetEnd); >+ } > } > > // 2 - convert HTML to Java (@see JavaDocRegion#convertHtml2Java) >@@ -3332,34 +3350,47 @@ > if (codeEnd > end) { > 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; >- 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) { >- break loop; >- } >- newLines++; >- break; >- case TerminalTokens.TokenNameMULTIPLY: >- nextStart = this.scanner.currentPosition + 1; >- break; >- default: >- break loop; >+ // See whether there's a space before the code >+ boolean needLeadingSpace = false; >+ if (linesGap > 0) { >+ int lineStart = this.scanner.getLineStart(startLine); >+ if (nextStart > lineStart) { // if code starts at the line, then no leading space is needed >+ this.scanner.resetTo(lineStart, nextStart-1); >+ try { >+ int token = this.scanner.getNextToken(); >+ if (token == TerminalTokens.TokenNameWHITESPACE) { >+ // skip indentation >+ token = this.scanner.getNextToken(); >+ needLeadingSpace = false; // there may be no star after >+ } else { >+ needLeadingSpace = true; >+ } >+ if (token == TerminalTokens.TokenNameMULTIPLY) { >+ nextStart = this.scanner.currentPosition; >+ // skip javadoc comment star >+ token = this.scanner.getNextToken(); >+ needLeadingSpace = true; >+ } >+ if (token == TerminalTokens.TokenNameWHITESPACE) { >+ needLeadingSpace = false; >+ nextStart++; >+ } >+ } >+ catch (InvalidInputException iie) { >+ // skip > } >- token = this.scanner.getNextToken(); > } > } >- catch (InvalidInputException iie) { >- // skip >- } >+ // Format gap lines before code >+ int newLines = linesGap; > 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, nextStart-1, newLines, false/* clear first blank lines inside <pre> tag as done by old formatter */, false, null); >+ if (needLeadingSpace) { >+ addInsertEdit(nextStart, " "); //$NON-NLS-1$ >+ } >+ // Format the code > printCodeSnippet(nextStart, codeEnd); >+ // Format the gap lines after the code > 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); > return 2;
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