author | jlahoda |
Mon, 22 Jul 2019 12:21:18 +0200 (2019-07-22) | |
changeset 55756 | d48ffad997b1 |
parent 55755 | 6e97fcd96aee |
child 55757 | 07e998f8f816 |
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Mon Jul 22 14:31:04 2019 +0800 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Mon Jul 22 12:21:18 2019 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,8 +109,10 @@ import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.DCTree; import com.sun.tools.javac.tree.DCTree.DCBlockTag; +import com.sun.tools.javac.tree.DCTree.DCComment; import com.sun.tools.javac.tree.DCTree.DCDocComment; import com.sun.tools.javac.tree.DCTree.DCEndPosTree; +import com.sun.tools.javac.tree.DCTree.DCEntity; import com.sun.tools.javac.tree.DCTree.DCErroneous; import com.sun.tools.javac.tree.DCTree.DCIdentifier; import com.sun.tools.javac.tree.DCTree.DCParam; @@ -302,6 +304,14 @@ return dcComment.comment.getSourcePos(block.pos + block.getTagName().length() + 1); } + case ENTITY: { + DCEntity endEl = (DCEntity) tree; + return dcComment.comment.getSourcePos(endEl.pos + (endEl.name != names.error ? endEl.name.length() : 0) + 2); + } + case COMMENT: { + DCComment endEl = (DCComment) tree; + return dcComment.comment.getSourcePos(endEl.pos + endEl.body.length()); + } default: DocTree last = getLastChild(tree);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon Jul 22 14:31:04 2019 +0800 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon Jul 22 12:21:18 2019 +0200 @@ -930,7 +930,7 @@ skipWhitespace(); if (ch == '>') { nextChar(); - return m.at(p).newEndElementTree(name); + return m.at(p).newEndElementTree(name).setEndPos(bp); } } } else if (ch == '!') {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java Mon Jul 22 14:31:04 2019 +0800 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java Mon Jul 22 12:21:18 2019 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -326,7 +326,7 @@ } } - public static class DCEndElement extends DCTree implements EndElementTree { + public static class DCEndElement extends DCEndPosTree<DCStartElement> implements EndElementTree { public final Name name; DCEndElement(Name name) {
--- a/test/langtools/tools/javac/doctree/positions/TestPosition.java Mon Jul 22 14:31:04 2019 +0800 +++ b/test/langtools/tools/javac/doctree/positions/TestPosition.java Mon Jul 22 12:21:18 2019 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8008174 + * @bug 8008174 8227923 * @summary proper source positions for doc comments * @modules jdk.compiler * @build TestPosition
--- a/test/langtools/tools/javac/doctree/positions/TestPosition.out Mon Jul 22 14:31:04 2019 +0800 +++ b/test/langtools/tools/javac/doctree/positions/TestPosition.out Mon Jul 22 12:21:18 2019 +0200 @@ -3,6 +3,8 @@ * * <p>Description with {@link java.io.InputStream link} * + * <em>text < < <!--some comment--> suffix</em> + * * @param first description * @param second description * @return whatever @@ -15,6 +17,18 @@ LINK:{@link java.io.InputStream link} REFERENCE:java.io.InputStream TEXT:link +TEXT: + * + *!trailing-whitespace! +START_ELEMENT:<em> +TEXT:text!trailing-whitespace! +ENTITY:< +TEXT:!trailing-whitespace! +ENTITY:< +TEXT:!trailing-whitespace! +COMMENT:<!--some comment--> +TEXT: suffix +END_ELEMENT:</em> PARAM:@param first description IDENTIFIER:first TEXT:description @@ -61,7 +75,7 @@ SINCE:@since ERRONEOUS:@see withWhiteSpaces: -DOC_COMMENT:First sentence. +DOC_COMMENT:First sentence. <em >text <!-- some comment --> suffix</em > * * <p>Description with {@link }, {@link java.util.List#add( int )}, * {@link java.util.List#add( int ) some text with whitespaces}, {@link @@ -72,6 +86,14 @@ * @throws java.lang.IllegalStateException * @throws java.lang.IllegalStateException some text TEXT:First sentence. +START_ELEMENT:<em > +TEXT:text!trailing-whitespace! +COMMENT:<!-- some comment --> +TEXT: suffix +END_ELEMENT:</em > +TEXT: + * + *!trailing-whitespace! START_ELEMENT:<p> TEXT:Description with!trailing-whitespace! LINK:{@link } @@ -96,4 +118,79 @@ REFERENCE:java.lang.IllegalStateException THROWS:@throws java.lang.IllegalStateException some text REFERENCE:java.lang.IllegalStateException -TEXT:some text \ No newline at end of file +TEXT:some text +erroneous2: +DOC_COMMENT:First sentence. + * + * <p>Description with {@unknownInlineTag }, {@unknownInlineTag text}, {@unknownInlineTag + * + * @param p1 p {@unknownInlineTag text + * @param p2 p < + * @param p3 p <em + * @param p4 p <!-- + * @param p5 p <!-- -- + * @param p6 p <!-- -- + * @param p7 p & + * @param p8 p < + * @param p9 p <em> </ + * @param pa p <em> </em +TEXT:First sentence. +START_ELEMENT:<p> +TEXT:Description with!trailing-whitespace! +UNKNOWN_INLINE_TAG:{@unknownInlineTag } +TEXT: +TEXT:,!trailing-whitespace! +UNKNOWN_INLINE_TAG:{@unknownInlineTag text} +TEXT:text +TEXT:,!trailing-whitespace! +ERRONEOUS:{@unknownInlineTag +PARAM:@param p1 p {@unknownInlineTag text +IDENTIFIER:p1 +TEXT:p!trailing-whitespace! +ERRONEOUS:{@unknownInlineTag text +PARAM:@param p2 p < +IDENTIFIER:p2 +TEXT:p!trailing-whitespace! +ERRONEOUS:< +PARAM:@param p3 p <em +IDENTIFIER:p3 +TEXT:p!trailing-whitespace! +ERRONEOUS:< +TEXT:em +PARAM:@param p4 p <!-- +IDENTIFIER:p4 +TEXT:p!trailing-whitespace! +ERRONEOUS:< +TEXT:!-- +PARAM:@param p5 p <!-- -- +IDENTIFIER:p5 +TEXT:p!trailing-whitespace! +ERRONEOUS:< +TEXT:!-- -- +PARAM:@param p6 p <!-- -- +IDENTIFIER:p6 +TEXT:p!trailing-whitespace! +ERRONEOUS:< +TEXT:!-- -- +PARAM:@param p7 p & +IDENTIFIER:p7 +TEXT:p!trailing-whitespace! +ERRONEOUS:& +PARAM:@param p8 p < +IDENTIFIER:p8 +TEXT:p!trailing-whitespace! +ERRONEOUS:< +PARAM:@param p9 p <em> </ +IDENTIFIER:p9 +TEXT:p!trailing-whitespace! +START_ELEMENT:<em> +TEXT:!trailing-whitespace! +ERRONEOUS:< +TEXT:/ +PARAM:@param pa p <em> </em +IDENTIFIER:pa +TEXT:p!trailing-whitespace! +START_ELEMENT:<em> +TEXT:!trailing-whitespace! +ERRONEOUS:< +TEXT:/em
--- a/test/langtools/tools/javac/doctree/positions/TestPositionSource.java Mon Jul 22 14:31:04 2019 +0800 +++ b/test/langtools/tools/javac/doctree/positions/TestPositionSource.java Mon Jul 22 12:21:18 2019 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ * * <p>Description with {@link java.io.InputStream link} * + * <em>text < < <!--some comment--> suffix</em> + * * @param first description * @param second description * @return whatever @@ -54,7 +56,7 @@ return true; } - /**First sentence. + /**First sentence. <em >text <!-- some comment --> suffix</em > * * <p>Description with {@link }, {@link java.util.List#add( int )}, * {@link java.util.List#add( int ) some text with whitespaces}, {@link @@ -69,4 +71,22 @@ return true; } + /**First sentence. + * + * <p>Description with {@unknownInlineTag }, {@unknownInlineTag text}, {@unknownInlineTag + * + * @param p1 p {@unknownInlineTag text + * @param p2 p < + * @param p3 p <em + * @param p4 p <!-- + * @param p5 p <!-- -- + * @param p6 p <!-- -- + * @param p7 p & + * @param p8 p < + * @param p9 p <em> </ + * @param pa p <em> </em + */ + public void erroneous2(int p1, int p2, int p3, int p4, int p5, + int p6, int p7, int p8, int p9, int pa) { + } }