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 126874 Details for
Bug 260011
[formatter] Formatting of html in javadoc comments doesn't work with style attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
v05.txt (text/plain), 17.53 KB, created by
Frederic Fusier
on 2009-02-26 12:34:28 EST
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2009-02-26 12:34:28 EST
Size:
17.53 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.34 >diff -u -r1.34 FormatterCommentsBugsTest.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 14 Jan 2009 10:48:43 -0000 1.34 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 26 Feb 2009 15:20:40 -0000 >@@ -3229,6 +3229,356 @@ > } > > /** >+ * @bug 260011: [formatter] Formatting of html in javadoc comments doesn't work with style attributes >+ * @test Ensure that the comment formatter understand <p> html tag with attributes >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260011" >+ */ >+public void testBug260011() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ " /**\n" + >+ " * some comment text here\n" + >+ " * <p style=\"font-variant:small-caps;\">\n" + >+ " * some text to be styled a certain way\n" + >+ " * </p>\n" + >+ " */\n" + >+ " void foo() {}\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " /**\n" + >+ " * some comment text here\n" + >+ " * <p style=\"font-variant:small-caps;\">\n" + >+ " * some text to be styled a certain way\n" + >+ " * </p>\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_01() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ " /**\n" + >+ " * some comment text here\n" + >+ " * <ul style=\"font-variant:small-caps;\"><li style=\"font-variant:small-caps;\">\n" + >+ " * some text to be styled a certain way</li></ul>\n" + >+ " * end of comment\n" + >+ " */\n" + >+ " void foo() {}\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " /**\n" + >+ " * some comment text here\n" + >+ " * <ul style=\"font-variant:small-caps;\">\n" + >+ " * <li style=\"font-variant:small-caps;\">\n" + >+ " * some text to be styled a certain way</li>\n" + >+ " * </ul>\n" + >+ " * end of comment\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_02() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ " /**\n" + >+ " * some comment text here\n" + >+ " * <pre style=\"font-variant:small-caps;\">\n" + >+ " * some text\n" + >+ " * to be styled\n" + >+ " * a certain way\n" + >+ " * \n" + >+ " * </pre>\n" + >+ " * end of comment\n" + >+ " */\n" + >+ " void foo() {}\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " /**\n" + >+ " * some comment text here\n" + >+ " * \n" + >+ " * <pre style=\"font-variant:small-caps;\">\n" + >+ " * some text\n" + >+ " * to be styled\n" + >+ " * a certain way\n" + >+ " * \n" + >+ " * </pre>\n" + >+ " * \n" + >+ " * end of comment\n" + >+ " */\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_03() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Indent char is a space char but not a line delimiters.\n" + >+ " * <code>== Character.isWhitespace(ch) && ch != \'\\n\' && ch != \'\\r\'</code>\n" + >+ " */\n" + >+ " public void foo() {\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Indent char is a space char but not a line delimiters.\n" + >+ " * <code>== Character.isWhitespace(ch) && ch != \'\\n\' && ch != \'\\r\'</code>\n" + >+ " */\n" + >+ " public void foo() {\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_04() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * The list of variable declaration fragments (element type: \n" + >+ " * <code VariableDeclarationFragment</code>). Defaults to an empty list.\n" + >+ " */\n" + >+ " int field;\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * The list of variable declaration fragments (element type:\n" + >+ " * <code VariableDeclarationFragment</code>). Defaults to an empty list.\n" + >+ " */\n" + >+ " int field;\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_05() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Compares version strings.\n" + >+ " * \n" + >+ " * @return result of comparison, as integer;\n" + >+ " * <code><0 if left is less than right </code>\n" + >+ " * <code>0 if left is equals to right</code>\n" + >+ " * <code>>0 if left is greater than right</code>\n" + >+ " */\n" + >+ " int foo() {\n" + >+ " return 0;\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Compares version strings.\n" + >+ " * \n" + >+ " * @return result of comparison, as integer;\n" + >+ " * <code><0 if left is less than right </code>\n" + >+ " * <code>0 if left is equals to right</code>\n" + >+ " * <code>>0 if left is greater than right</code>\n" + >+ " */\n" + >+ " int foo() {\n" + >+ " return 0;\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_06() throws JavaModelException { >+ String source = >+ "public interface Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Returns the length of this array.\n" + >+ " * \n" + >+ " * @return the length of this array\n" + >+ " * @exception DebugException if this method fails. Reasons include:<ul>\n" + >+ " * <li>Failure communicating with the VM. The DebugException\'s\n" + >+ " * status code contains the underlying exception responsible for\n" + >+ " * the failure.</li>\n" + >+ " * </ul\n" + >+ " */\n" + >+ " public int getLength();\n" + >+ "}\n"; >+ formatSource(source, >+ "public interface Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Returns the length of this array.\n" + >+ " * \n" + >+ " * @return the length of this array\n" + >+ " * @exception DebugException\n" + >+ " * if this method fails. Reasons include:\n" + >+ " * <ul>\n" + >+ " * <li>Failure communicating with the VM. The\n" + >+ " * DebugException\'s status code contains the underlying\n" + >+ " * exception responsible for the failure.</li>\n" + >+ " * </ul\n" + >+ " */\n" + >+ " public int getLength();\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_07() throws JavaModelException { >+ String source = >+ "public interface Test {\n" + >+ "\n" + >+ " \n" + >+ " /**\n" + >+ " * Returns the change directly associated with this change element or <code\n" + >+ " * null</code> if the element isn\'t associated with a change.\n" + >+ " * \n" + >+ " * @return the change or <code>null</code>\n" + >+ " */\n" + >+ " public String getChange();\n" + >+ "}\n"; >+ formatSource(source, >+ "public interface Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Returns the change directly associated with this change element or <code\n" + >+ " * null</code>\n" + >+ " * if the element isn\'t associated with a change.\n" + >+ " * \n" + >+ " * @return the change or <code>null</code>\n" + >+ " */\n" + >+ " public String getChange();\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_08() throws JavaModelException { >+ String source = >+ "public interface Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Answer the element factory for an id, or <code>null</code. if not found.\n" + >+ " * @param targetID\n" + >+ " * @return\n" + >+ " */\n" + >+ " public int foo(String targetID);\n" + >+ "}\n"; >+ formatSource(source, >+ "public interface Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Answer the element factory for an id, or <code>null</code. if not found.\n" + >+ " * \n" + >+ " * @param targetID\n" + >+ " * @return\n" + >+ " */\n" + >+ " public int foo(String targetID);\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_09() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * o Example: baseCE < a << b <<< q << c < d < e * nextCE(X,1) \n" + >+ " */\n" + >+ " int field;\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * o Example: baseCE < a << b <<< q << c < d < e * nextCE(X,1)\n" + >+ " */\n" + >+ " int field;\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_09b() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * o Example: baseCE < a < b < q < c < p < e * nextCE(X,1) \n" + >+ " */\n" + >+ " int field;\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * o Example: baseCE < a < b < q < c < p < e * nextCE(X,1)\n" + >+ " */\n" + >+ " int field;\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_10() throws JavaModelException { >+ String source = >+ "public interface Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Creates and opens a dialog to edit the given template.\n" + >+ " * <p\n" + >+ " * Subclasses may override this method to provide a custom dialog.</p>\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "public interface Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * Creates and opens a dialog to edit the given template.\n" + >+ " * <p\n" + >+ " * Subclasses may override this method to provide a custom dialog.\n" + >+ " * </p>\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260011_11() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "\n" + >+ " /** \n" + >+ " * <p>Binary property IDS_Trinary_Operator (new).</p> \n" + >+ " * <p?For programmatic determination of Ideographic Description \n" + >+ " * Sequences.</p> \n" + >+ " * @stable ICU 2.6\n" + >+ " */ \n" + >+ " public static final int IDS_TRINARY_OPERATOR = 19; \n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " /**\n" + >+ " * <p>\n" + >+ " * Binary property IDS_Trinary_Operator (new).\n" + >+ " * </p>\n" + >+ " * <p\n" + >+ " * ?For programmatic determination of Ideographic Description Sequences.\n" + >+ " * </p>\n" + >+ " * \n" + >+ " * @stable ICU 2.6\n" + >+ " */\n" + >+ " public static final int IDS_TRINARY_OPERATOR = 19;\n" + >+ "}\n" >+ ); >+} >+ >+/** > * @bug 260274: [formatter] * character is removed while formatting block comments > * @test Ensure that the comment formatter keep '*' characters while formatting block comments > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260274" >#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.22 >diff -u -r1.22 FormatterCommentParser.java >--- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 19 Aug 2008 16:16:39 -0000 1.22 >+++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 26 Feb 2009 15:20:42 -0000 >@@ -142,13 +142,6 @@ > int length = htmlTag == null ? 0 : htmlTag.length; > int tagId = 0; > if (length > 0) { >- for (int i=0, max=JAVADOC_SPECIAL_TAGS.length; i<max; i++) { >- char[] tag = JAVADOC_SPECIAL_TAGS[i]; >- if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) { >- tagId = JAVADOC_SPECIAL_TAGS_ID; >- break; >- } >- } > for (int i=0, max=JAVADOC_SINGLE_BREAK_TAG.length; i<max; i++) { > char[] tag = JAVADOC_SINGLE_BREAK_TAG[i]; > if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) { >@@ -193,7 +186,10 @@ > boolean valid = false; > boolean incremented = false; > int start = this.scanner.currentPosition; >+ int currentPosition = start; > int htmlPtr = this.htmlTagsPtr; >+ char firstChar = peekChar(); >+ boolean hasWhitespaces = firstChar == ' ' || ScannerHelper.isWhitespace(firstChar); > try { > int token = readTokenAndConsume(); > char[] htmlTag; >@@ -240,6 +236,7 @@ > } > } > // Accept xhtml syntax >+ currentPosition = this.scanner.currentPosition; > if (readToken() == TerminalTokens.TokenNameDIVIDE) { > consumeToken(); > } >@@ -268,24 +265,60 @@ > // set closing flag > htmlIndex |= JAVADOC_CLOSED_TAG; > closing = true; >+ currentPosition = this.scanner.currentPosition; > break; > default: > return false; > } >- if ((token = readTokenAndConsume()) != TerminalTokens.TokenNameGREATER) { >- if ((htmlIndex & JAVADOC_SPECIAL_TAGS_ID) == JAVADOC_SPECIAL_TAGS_ID) { >- // Special tags may have attributes, so consume tokens until the greater token is encountered >- while (token != TerminalTokens.TokenNameGREATER) { >- token = readTokenAndConsume(); >- if (token == TerminalTokens.TokenNameEOF) { >- return false; >- } >+ >+ // Looking for tag closing >+ switch (token = readTokenAndConsume()) { >+ case TerminalTokens.TokenNameLESS: >+ case TerminalTokens.TokenNameLESS_EQUAL: >+ // consider that the closing '>' is missing >+ return false; >+ case TerminalTokens.TokenNameGREATER: >+ // simple tag without attributes >+ break; >+ case TerminalTokens.TokenNameGREATER_EQUAL: >+ case TerminalTokens.TokenNameRIGHT_SHIFT: >+ case TerminalTokens.TokenNameRIGHT_SHIFT_EQUAL: >+ // simple tag without attributes, but the closing '>' is followed by an '=' or '>' >+ break; >+ default: >+ this.index = currentPosition; >+ loop: while (true) { >+// currentPosition = this.index; >+ switch (readChar()) { >+ case '<': >+ if (hasWhitespaces) { >+ // not 100% sure this is a tag definition => give up >+ return false; >+ } >+ // opening tag => consider the current one as closed >+ this.index = currentPosition; >+ this.scanner.startPosition = currentPosition; >+ this.scanner.currentPosition = currentPosition; >+ this.scanner.currentCharacter = '<'; >+ break loop; >+ case '>': >+ // simple tag without attributes >+ this.scanner.startPosition = this.index; >+ this.scanner.currentPosition = this.index; >+ this.scanner.currentCharacter = peekChar(); >+ break loop; >+ default: >+ break; >+ } >+ if (this.index >= this.javadocTextEnd) { >+ // the end of the comment is reached => consider current tag as closed >+ this.index = currentPosition; >+ this.scanner.startPosition = currentPosition; >+ this.scanner.currentPosition = currentPosition; >+ break; >+ } > } >- } else { >- // invalid syntax >- return false; >- } >- } >+ } > > // Push texts > if (this.lineStarted && this.textStart != -1 && this.textStart < endTextPosition) { >Index: formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java,v >retrieving revision 1.12 >diff -u -r1.12 IJavaDocTagConstants.java >--- formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java 27 Jun 2008 16:03:57 -0000 1.12 >+++ formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java 26 Feb 2009 15:20:42 -0000 >@@ -67,8 +67,8 @@ > }; > > /** Javadoc parameter tags */ >- // TODO (eric) should have another name than 'param' for the following tags >- // TODO (eric) investigate how and why this list was created >+ // TODO (frederic) should have another name than 'param' for the following tags >+ // TODO (frederic) investigate how and why this list was created > public static final char[][] JAVADOC_PARAM_TAGS= new char[][] { > "@exception".toCharArray(), //$NON-NLS-1$ > "@param".toCharArray(), //$NON-NLS-1$ >@@ -89,16 +89,6 @@ > "tr".toCharArray(), //$NON-NLS-1$ > }; > >- /** >- * Following table is used to identify special tags which may have more complex >- * opening than just <name> >- */ >- public static final char[][] JAVADOC_SPECIAL_TAGS= new char[][] { >- "table".toCharArray(), //$NON-NLS-1$ >- "tr".toCharArray(), //$NON-NLS-1$ >- "td".toCharArray(), //$NON-NLS-1$ >- }; >- > /** Javadoc tag prefix */ > public static final char JAVADOC_TAG_PREFIX= '@'; > >@@ -151,5 +141,4 @@ > static final int JAVADOC_SEPARATOR_TAGS_ID = 0x1000; > static final int JAVADOC_SINGLE_TAGS_ID = JAVADOC_SINGLE_BREAK_TAG_ID; // ID max for tags ID with no opening/closing (e.g. <bla>....</bla>) > static final int JAVADOC_CLOSED_TAG = 0x10000; >- static final int JAVADOC_SPECIAL_TAGS_ID = 0x20000; > }
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 260011
:
126535
| 126874