2
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
26
* @bug 7021614 8241780 8273244 8284908
27
* @summary extend com.sun.source API to support parsing javadoc comments
28
* @modules jdk.compiler/com.sun.tools.javac.api
29
* jdk.compiler/com.sun.tools.javac.file
30
* jdk.compiler/com.sun.tools.javac.tree
31
* jdk.compiler/com.sun.tools.javac.util
32
* @build DocCommentTester
33
* @run main DocCommentTester LiteralTest.java
37
/** {@literal if (a < b) { }} */
40
DocComment[DOC_COMMENT, pos:0
42
Literal[LITERAL, pos:0, if_(a_<_b)_{_}]
48
/** [{@literal if (a < b) { }}] */
49
void in_brackets() { }
51
DocComment[DOC_COMMENT, pos:0
54
Literal[LITERAL, pos:1, if_(a_<_b)_{_}]
61
/** [ {@literal if (a < b) { }} ] */
62
void in_brackets_with_whitespace() { }
64
DocComment[DOC_COMMENT, pos:0
67
Literal[LITERAL, pos:2, if_(a_<_b)_{_}]
68
Text[TEXT, pos:27, _]]
75
* {@literal {@literal nested} }
79
DocComment[DOC_COMMENT, pos:1
81
Literal[LITERAL, pos:1, {@literal_nested}_]
88
* {@literal if (a < b) {
92
void embedded_newline() { }
94
DocComment[DOC_COMMENT, pos:1
96
Literal[LITERAL, pos:1, if_(a_<_b)_{|________}|_]
107
void embedded_at() { }
109
DocComment[DOC_COMMENT, pos:1
111
Literal[LITERAL, pos:1, |_@tag|_]
118
/** {@literal if (a < b) { } */
119
void unterminated_1() { }
121
DocComment[DOC_COMMENT, pos:0
123
Erroneous[ERRONEOUS, pos:0, prefPos:23
124
code: compiler.err.dc.unterminated.inline.tag
125
body: {@literal_if_(a_<_b)_{_}
133
* {@literal if (a < b) { }
135
void unterminated_2() { }
137
DocComment[DOC_COMMENT, pos:1
139
Erroneous[ERRONEOUS, pos:1, prefPos:37
140
code: compiler.err.dc.unterminated.inline.tag
141
body: {@literal_if_(a_<_b)_{_}|_@author_jjg