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 105695 Details for
Bug 233259
[formatter] html tag should not be split by formatter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v05.txt (text/plain), 11.03 KB, created by
Frederic Fusier
on 2008-06-24 09:06:14 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2008-06-24 09:06:14 EDT
Size:
11.03 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java,v >retrieving revision 1.15 >diff -u -r1.15 FormatterCommentParser.java >--- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 20 Jun 2008 15:57:24 -0000 1.15 >+++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 23 Jun 2008 10:23:00 -0000 >@@ -62,6 +62,18 @@ > } > > /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#createFakeReference(int) >+ */ >+protected boolean createFakeReference(int start) { >+ // synch scanner and parser positions >+ this.scanner.currentPosition = this.index; >+ // create reference in order to be able to format it >+ int lineStart = this.scanner.getLineNumber(start); >+ FormatJavadocReference reference = new FormatJavadocReference(start, this.index-1, lineStart); >+ return pushSeeRef(reference); >+} >+ >+/* (non-Javadoc) > * @see org.eclipse.jdt.internal.compiler.parser.JavadocParser#createFieldReference(java.lang.Object) > */ > protected Object createFieldReference(Object receiver) throws InvalidInputException { >@@ -729,30 +741,7 @@ > * @see org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#verifyEndLine(int) > */ > protected boolean verifyEndLine(int textPosition) { >- int endPosition = this.scanner.currentPosition; >- this.scanner.resetTo(textPosition, this.javadocEnd); >- boolean tokenizeWhiteSpace = this.scanner.tokenizeWhiteSpace; >- this.scanner.tokenizeWhiteSpace = true; >- try { >- int token = this.scanner.getNextToken(); >- int startPosition = textPosition; >- if (token == TerminalTokens.TokenNameWHITESPACE) { >- while (this.scanner.currentCharacter == '*' || ScannerHelper.isWhitespace(this.scanner.currentCharacter)) { >- token = this.scanner.getNextToken(); >- } >- startPosition = this.scanner.currentPosition; >- } >- createTag(); >- pushText(startPosition, endPosition); >- } >- catch (InvalidInputException iie) { >- // skip >- } >- finally { >- this.scanner.tokenizeWhiteSpace = tokenizeWhiteSpace; >- } >- this.scanner.resetTo(endPosition, this.javadocEnd); >- this.index = endPosition; >+ // do not verify anything at end of line while formatting > return true; > } > >Index: compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java,v >retrieving revision 1.76 >diff -u -r1.76 AbstractCommentParser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 20 Jun 2008 15:54:53 -0000 1.76 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 23 Jun 2008 10:23:00 -0000 >@@ -413,6 +413,10 @@ > } > > protected abstract Object createArgumentReference(char[] name, int dim, boolean isVarargs, Object typeRef, long[] dimPos, long argNamePos) throws InvalidInputException; >+ protected boolean createFakeReference(int start) { >+ // Do nothing by default >+ return true; >+ } > protected abstract Object createFieldReference(Object receiver) throws InvalidInputException; > protected abstract Object createMethodReference(Object receiver, List arguments) throws InvalidInputException; > protected Object createReturnStatement() { return null; } >@@ -618,7 +622,7 @@ > /* > * Parse an URL link reference in @see tag > */ >- private boolean parseHref() throws InvalidInputException { >+ protected boolean parseHref() throws InvalidInputException { > int start = this.scanner.getCurrentTokenStartPosition(); > char currentChar = readChar(); > if (currentChar == 'a' || currentChar == 'A') { >@@ -1104,11 +1108,11 @@ > > // verify end line > if (verifyEndLine(previousPosition)) { >- return true; >+ return createFakeReference(start); > } > if (this.reportProblems) this.sourceParser.problemReporter().javadocUnexpectedText(this.scanner.currentPosition, this.lineEnd); > return false; >- case TerminalTokens.TokenNameLESS : // @see "<a href="URL#Value">label</a> >+ case TerminalTokens.TokenNameLESS : // @see <a href="URL#Value">label</a> > // If typeRef != null we may raise a warning here to let user know there's an unused reference... > // Currently as javadoc 1.4.2 ignore it, we do the same (see bug 69302) > if (typeRef != null) break nextToken; >@@ -1122,7 +1126,9 @@ > return false; > } > // verify end line >- if (verifyEndLine(previousPosition)) return true; >+ if (verifyEndLine(previousPosition)) { >+ return createFakeReference(start); >+ } > if (this.reportProblems) this.sourceParser.problemReporter().javadocUnexpectedText(this.scanner.currentPosition, this.lineEnd); > } > else if (this.tagValue == TAG_VALUE_VALUE) { >#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.13 >diff -u -r1.13 FormatterCommentsBugsTest.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 20 Jun 2008 15:57:25 -0000 1.13 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 23 Jun 2008 10:23:02 -0000 >@@ -956,6 +956,189 @@ > } > > /** >+ * @bug 233259: [formatter] html tag should not be split by formatter >+ * @test Ensure that html tag is not split by the new comment formatter >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=233259" >+ */ >+public void testBug233259a() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a href=\"http://0\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a href=\"http://0\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug233259b() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ // difference with 3.3 formatter: >+ // split html reference as this allow not to go over the max line width >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a href=\"http://0123\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a\n"+ >+ " * href=\"http://0123\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug233259c() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a href=\"http://012346789\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a\n" + >+ " * href=\"http://012346789\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug233259d() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a href=\"http://012346789012346789012346789\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see <a\n" + >+ " * href=\"http://012346789012346789012346789\">Test</a>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+ >+/** >+ * @bug 237942: [formatter] String references are put on next line when over the max line length >+ * @test Ensure that string reference is not put on next line when over the max line width >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=237942" >+ */ >+public void testBug237942a() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 01234567\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 01234567\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug237942b() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ // difference with 3.3 formatter: >+ // do not split string reference as this can lead to javadoc syntax error >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 012345678\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 012345678\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug237942c() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ // difference with 3.3 formatter: >+ // do not split string reference as this can lead to javadoc syntax error >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 01234567 90\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 01234567 90\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug237942d() throws JavaModelException { >+ this.preferences.comment_line_length = 40; >+ // difference with 3.3 formatter: >+ // do not split string reference as this can lead to javadoc syntax error >+ String source = >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 01234567890123\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X {\n" + >+ " /**\n" + >+ " * @see \"string reference: 01234567890123\"\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+ >+/** > * @bug 234336: [formatter] JavaDocTestCase.testMultiLineCommentIndent* tests fail in I20080527-2000 build > * @test Ensure that new comment formatter format all comments concerned by selections > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=234336"
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 233259
: 105695