1 /*
2  * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
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.
8  *
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).
14  *
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.
18  *
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
21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 7021614
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
34  */
35 
36 class LiteralTest {
37     /** {@literal if (a < b) { }} */
minimal()38     void minimal() { }
39 /*
40 DocComment[DOC_COMMENT, pos:0
41   firstSentence: 1
42     Literal[LITERAL, pos:0, if_(a_<_b)_{_}]
43   body: empty
44   block tags: empty
45 ]
46 */
47 
48     /** [{@literal if (a < b) { }}] */
in_brackets()49     void in_brackets() { }
50 /*
51 DocComment[DOC_COMMENT, pos:0
52   firstSentence: 3
53     Text[TEXT, pos:0, []
54     Literal[LITERAL, pos:1, if_(a_<_b)_{_}]
55     Text[TEXT, pos:26, ]]
56   body: empty
57   block tags: empty
58 ]
59 */
60 
61     /** [ {@literal if (a < b) { }} ] */
in_brackets_with_whitespace()62     void in_brackets_with_whitespace() { }
63 /*
64 DocComment[DOC_COMMENT, pos:0
65   firstSentence: 3
66     Text[TEXT, pos:0, [_]
67     Literal[LITERAL, pos:2, if_(a_<_b)_{_}]
68     Text[TEXT, pos:27, _]]
69   body: empty
70   block tags: empty
71 ]
72 */
73 
74     /**
75      * {@literal {@literal nested} }
76      */
nested()77     void nested() { }
78 /*
79 DocComment[DOC_COMMENT, pos:1
80   firstSentence: 1
81     Literal[LITERAL, pos:1, {@literal_nested}_]
82   body: empty
83   block tags: empty
84 ]
85 */
86 
87     /**
88      * {@literal if (a < b) {
89      *        }
90      * }
91      */
embedded_newline()92     void embedded_newline() { }
93 /*
94 DocComment[DOC_COMMENT, pos:1
95   firstSentence: 1
96     Literal[LITERAL, pos:1, if_(a_<_b)_{|________}|_]
97   body: empty
98   block tags: empty
99 ]
100 */
101 
102 
103     /** {@literal if (a < b) { } */
unterminated_1()104     void unterminated_1() { }
105 /*
106 DocComment[DOC_COMMENT, pos:0
107   firstSentence: 1
108     Erroneous[ERRONEOUS, pos:0
109       code: compiler.err.dc.unterminated.inline.tag
110       body: {@literal_if_(a_<_b)_{_}
111     ]
112   body: empty
113   block tags: empty
114 ]
115 */
116 
117     /**
118      * {@literal if (a < b) { }
119      * @author jjg */
unterminated_2()120     void unterminated_2() { }
121 /*
122 DocComment[DOC_COMMENT, pos:1
123   firstSentence: 1
124     Erroneous[ERRONEOUS, pos:1
125       code: compiler.err.dc.unterminated.inline.tag
126       body: {@literal_if_(a_<_b)_{_}
127     ]
128   body: empty
129   block tags: 1
130     Author[AUTHOR, pos:27
131       name: 1
132         Text[TEXT, pos:35, jjg]
133     ]
134 ]
135 */
136 
137 }
138 
139