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 8076026
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 AttrTest.java
34  */
35 
36 class AttrTest {
37     /**
38      * <a name=unquoted>foo</a>
39      */
unquoted_attr()40     void unquoted_attr() { }
41 /*
42 DocComment[DOC_COMMENT, pos:1
43   firstSentence: 3
44     StartElement[START_ELEMENT, pos:1
45       name:a
46       attributes: 1
47         Attribute[ATTRIBUTE, pos:4
48           name: name
49           vkind: UNQUOTED
50           value: 1
51             Text[TEXT, pos:9, unquoted]
52         ]
53     ]
54     Text[TEXT, pos:18, foo]
55     EndElement[END_ELEMENT, pos:21, a]
56   body: empty
57   block tags: empty
58 ]
59 */
60 
61     /**
62      * <a name-test=hyphened>foo</a>
63      */
hyphened_attr()64     void hyphened_attr() { }
65 /*
66 DocComment[DOC_COMMENT, pos:1
67   firstSentence: 3
68     StartElement[START_ELEMENT, pos:1
69       name:a
70       attributes: 1
71         Attribute[ATTRIBUTE, pos:4
72           name: name-test
73           vkind: UNQUOTED
74           value: 1
75             Text[TEXT, pos:14, hyphened]
76         ]
77     ]
78     Text[TEXT, pos:23, foo]
79     EndElement[END_ELEMENT, pos:26, a]
80   body: empty
81   block tags: empty
82 ]
83 */
84 
85     /**
86      * <a name="double_quoted">foo</a>
87      */
double_quoted_attr()88     void double_quoted_attr() { }
89 /*
90 DocComment[DOC_COMMENT, pos:1
91   firstSentence: 3
92     StartElement[START_ELEMENT, pos:1
93       name:a
94       attributes: 1
95         Attribute[ATTRIBUTE, pos:4
96           name: name
97           vkind: DOUBLE
98           value: 1
99             Text[TEXT, pos:10, double_quoted]
100         ]
101     ]
102     Text[TEXT, pos:25, foo]
103     EndElement[END_ELEMENT, pos:28, a]
104   body: empty
105   block tags: empty
106 ]
107 */
108 
109     /**
110      * <a name='single_quoted'>foo</a>
111      */
single_quoted_attr()112     void single_quoted_attr() { }
113 /*
114 DocComment[DOC_COMMENT, pos:1
115   firstSentence: 3
116     StartElement[START_ELEMENT, pos:1
117       name:a
118       attributes: 1
119         Attribute[ATTRIBUTE, pos:4
120           name: name
121           vkind: SINGLE
122           value: 1
123             Text[TEXT, pos:10, single_quoted]
124         ]
125     ]
126     Text[TEXT, pos:25, foo]
127     EndElement[END_ELEMENT, pos:28, a]
128   body: empty
129   block tags: empty
130 ]
131 */
132 
133     /**
134      * <hr size="3">
135      */
numeric_attr()136     void numeric_attr() { }
137 /*
138 DocComment[DOC_COMMENT, pos:1
139   firstSentence: 1
140     StartElement[START_ELEMENT, pos:1
141       name:hr
142       attributes: 1
143         Attribute[ATTRIBUTE, pos:5
144           name: size
145           vkind: DOUBLE
146           value: 1
147             Text[TEXT, pos:11, 3]
148         ]
149     ]
150   body: empty
151   block tags: empty
152 ]
153 */
154 
155     /**
156      * <a href="{@docRoot}/index.html">
157      */
docRoot_attr()158     void docRoot_attr() { }
159 /*
160 DocComment[DOC_COMMENT, pos:1
161   firstSentence: 1
162     StartElement[START_ELEMENT, pos:1
163       name:a
164       attributes: 1
165         Attribute[ATTRIBUTE, pos:4
166           name: href
167           vkind: DOUBLE
168           value: 2
169             DocRoot[DOC_ROOT, pos:10]
170             Text[TEXT, pos:20, /index.html]
171         ]
172     ]
173   body: empty
174   block tags: empty
175 ]
176 */
177 
178     /**
179      * <a name="abc&quot;def">
180      */
entity_attr()181     void entity_attr() { }
182 /*
183 DocComment[DOC_COMMENT, pos:1
184   firstSentence: 1
185     StartElement[START_ELEMENT, pos:1
186       name:a
187       attributes: 1
188         Attribute[ATTRIBUTE, pos:4
189           name: name
190           vkind: DOUBLE
191           value: 3
192             Text[TEXT, pos:10, abc]
193             Entity[ENTITY, pos:13, quot]
194             Text[TEXT, pos:19, def]
195         ]
196     ]
197   body: empty
198   block tags: empty
199 ]
200 */
201 
202     /**
203      * <hr noshade>
204      */
no_value_attr()205     void no_value_attr() { }
206 /*
207 DocComment[DOC_COMMENT, pos:1
208   firstSentence: 1
209     StartElement[START_ELEMENT, pos:1
210       name:hr
211       attributes: 1
212         Attribute[ATTRIBUTE, pos:5
213           name: noshade
214           vkind: EMPTY
215           value: null
216         ]
217     ]
218   body: empty
219   block tags: empty
220 ]
221 */
222 
223     /**
224      * abc <hr size='3'/>
225      */
self_closing_attr_1()226     void self_closing_attr_1() { }
227 /*
228 DocComment[DOC_COMMENT, pos:1
229   firstSentence: 2
230     Text[TEXT, pos:1, abc_]
231     StartElement[START_ELEMENT, pos:5
232       name:hr
233       attributes: 1
234         Attribute[ATTRIBUTE, pos:9
235           name: size
236           vkind: SINGLE
237           value: 1
238             Text[TEXT, pos:15, 3]
239         ]
240     ]
241   body: empty
242   block tags: empty
243 ]
244 */
245 
246     /**
247      * abc <hr size=3 />
248      */
self_closing_attr_2()249     void self_closing_attr_2() { }
250 /*
251 DocComment[DOC_COMMENT, pos:1
252   firstSentence: 2
253     Text[TEXT, pos:1, abc_]
254     StartElement[START_ELEMENT, pos:5
255       name:hr
256       attributes: 1
257         Attribute[ATTRIBUTE, pos:9
258           name: size
259           vkind: UNQUOTED
260           value: 1
261             Text[TEXT, pos:14, 3]
262         ]
263     ]
264   body: empty
265   block tags: empty
266 ]
267 */
268 
269     /**
270      * abc <hr size="3
271      */
unterminated_attr_eoi()272     void unterminated_attr_eoi() { }
273 /*
274 DocComment[DOC_COMMENT, pos:1
275   firstSentence: 3
276     Text[TEXT, pos:1, abc_]
277     Erroneous[ERRONEOUS, pos:5
278       code: compiler.err.dc.malformed.html
279       body: <
280     ]
281     Text[TEXT, pos:6, hr_size="3]
282   body: empty
283   block tags: empty
284 ]
285 */
286 
287     /**
288      * abc <hr size="3
289      * @author jjg
290      */
unterminated_attr_block()291     void unterminated_attr_block() { }
292 /*
293 DocComment[DOC_COMMENT, pos:1
294   firstSentence: 3
295     Text[TEXT, pos:1, abc_]
296     Erroneous[ERRONEOUS, pos:5
297       code: compiler.err.dc.malformed.html
298       body: <
299     ]
300     Text[TEXT, pos:6, hr_size="3]
301   body: empty
302   block tags: 1
303     Author[AUTHOR, pos:18
304       name: 1
305         Text[TEXT, pos:26, jjg]
306     ]
307 ]
308 */
309 }
310