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