FirstSentenceTest.java revision 3074:522e516b8a83
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 8078320 8132096
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 FirstSentenceTest.java
34 * @run main DocCommentTester -useBreakIterator FirstSentenceTest.java
35 */
36
37class FirstSentenceTest {
38    /** */
39    void empty() { }
40/*
41DocComment[DOC_COMMENT, pos:-1
42  firstSentence: empty
43  body: empty
44  block tags: empty
45]
46*/
47/*
48BREAK_ITERATOR
49DocComment[DOC_COMMENT, pos:-1
50  firstSentence: empty
51  body: empty
52  block tags: empty
53]
54*/
55
56    /** abc def ghi */
57    void no_terminator() { }
58/*
59DocComment[DOC_COMMENT, pos:0
60  firstSentence: 1
61    Text[TEXT, pos:0, abc_def_ghi]
62  body: empty
63  block tags: empty
64]
65*/
66/*
67BREAK_ITERATOR
68DocComment[DOC_COMMENT, pos:0
69  firstSentence: 1
70    Text[TEXT, pos:0, abc_def_ghi]
71  body: empty
72  block tags: empty
73]
74*/
75
76    /**
77     * abc def ghi.
78     */
79    void no_body() { }
80/*
81DocComment[DOC_COMMENT, pos:1
82  firstSentence: 1
83    Text[TEXT, pos:1, abc_def_ghi.]
84  body: empty
85  block tags: empty
86]
87*/
88/*
89BREAK_ITERATOR
90DocComment[DOC_COMMENT, pos:1
91  firstSentence: 1
92    Text[TEXT, pos:1, abc_def_ghi.]
93  body: empty
94  block tags: empty
95]
96*/
97    /**
98     * abc def ghi. jkl mno pqr.
99     */
100    void dot_space() { }
101/*
102DocComment[DOC_COMMENT, pos:1
103  firstSentence: 1
104    Text[TEXT, pos:1, abc_def_ghi.]
105  body: 1
106    Text[TEXT, pos:14, jkl_mno_pqr.]
107  block tags: empty
108]
109*/
110/*
111BREAK_ITERATOR
112DocComment[DOC_COMMENT, pos:1
113  firstSentence: 1
114    Text[TEXT, pos:1, abc_def_ghi._jkl_mno_pqr.]
115  body: empty
116  block tags: empty
117]
118*/
119    /**
120     * abc def ghi.
121     * jkl mno pqr
122     */
123    void dot_newline() { }
124/*
125DocComment[DOC_COMMENT, pos:1
126  firstSentence: 1
127    Text[TEXT, pos:1, abc_def_ghi.]
128  body: 1
129    Text[TEXT, pos:15, jkl_mno_pqr]
130  block tags: empty
131]
132*/
133/*
134BREAK_ITERATOR
135DocComment[DOC_COMMENT, pos:1
136  firstSentence: 1
137    Text[TEXT, pos:1, abc_def_ghi.]
138  body: 1
139    Text[TEXT, pos:15, jkl_mno_pqr]
140  block tags: empty
141]
142*/
143    /**
144     * abc def ghi
145     * <p>jkl mno pqr
146     */
147    void dot_p() { }
148/*
149DocComment[DOC_COMMENT, pos:1
150  firstSentence: 1
151    Text[TEXT, pos:1, abc_def_ghi]
152  body: 2
153    StartElement[START_ELEMENT, pos:14
154      name:p
155      attributes: empty
156    ]
157    Text[TEXT, pos:17, jkl_mno_pqr]
158  block tags: empty
159]
160*/
161/*
162BREAK_ITERATOR
163DocComment[DOC_COMMENT, pos:1
164  firstSentence: 1
165    Text[TEXT, pos:1, abc_def_ghi]
166  body: 2
167    StartElement[START_ELEMENT, pos:14
168      name:p
169      attributes: empty
170    ]
171    Text[TEXT, pos:17, jkl_mno_pqr]
172  block tags: empty
173]
174*/
175    /**
176     *
177     * <p>abc def ghi.
178     * jdl mno pqf
179     */
180    void newline_p() { }
181/*
182DocComment[DOC_COMMENT, pos:2
183  firstSentence: 2
184    StartElement[START_ELEMENT, pos:2
185      name:p
186      attributes: empty
187    ]
188    Text[TEXT, pos:5, abc_def_ghi.]
189  body: 1
190    Text[TEXT, pos:19, jdl_mno_pqf]
191  block tags: empty
192]
193*/
194/*
195BREAK_ITERATOR
196DocComment[DOC_COMMENT, pos:2
197  firstSentence: 2
198    StartElement[START_ELEMENT, pos:2
199      name:p
200      attributes: empty
201    ]
202    Text[TEXT, pos:5, abc_def_ghi.]
203  body: 1
204    Text[TEXT, pos:19, jdl_mno_pqf]
205  block tags: empty
206]
207*/
208    /**
209     * abc def ghi
210     * </p>jkl mno pqr
211     */
212    void dot_end_p() { }
213/*
214DocComment[DOC_COMMENT, pos:1
215  firstSentence: 1
216    Text[TEXT, pos:1, abc_def_ghi]
217  body: 2
218    EndElement[END_ELEMENT, pos:14, p]
219    Text[TEXT, pos:18, jkl_mno_pqr]
220  block tags: empty
221]
222*/
223/*
224BREAK_ITERATOR
225DocComment[DOC_COMMENT, pos:1
226  firstSentence: 1
227    Text[TEXT, pos:1, abc_def_ghi]
228  body: 2
229    EndElement[END_ELEMENT, pos:14, p]
230    Text[TEXT, pos:18, jkl_mno_pqr]
231  block tags: empty
232]
233*/
234    /**
235     * abc &lt; ghi. jkl mno pqr.
236     */
237    void entity() { }
238/*
239DocComment[DOC_COMMENT, pos:1
240  firstSentence: 3
241    Text[TEXT, pos:1, abc_]
242    Entity[ENTITY, pos:5, lt]
243    Text[TEXT, pos:9, _ghi.]
244  body: 1
245    Text[TEXT, pos:15, jkl_mno_pqr.]
246  block tags: empty
247]
248*/
249/*
250BREAK_ITERATOR
251DocComment[DOC_COMMENT, pos:1
252  firstSentence: 3
253    Text[TEXT, pos:1, abc_]
254    Entity[ENTITY, pos:5, lt]
255    Text[TEXT, pos:9, _ghi._jkl_mno_pqr.]
256  body: empty
257  block tags: empty
258]
259*/
260    /**
261     * abc {@code code} ghi. jkl mno pqr.
262     */
263    void inline_tag() { }
264/*
265DocComment[DOC_COMMENT, pos:1
266  firstSentence: 3
267    Text[TEXT, pos:1, abc_]
268    Literal[CODE, pos:5, code]
269    Text[TEXT, pos:17, _ghi.]
270  body: 1
271    Text[TEXT, pos:23, jkl_mno_pqr.]
272  block tags: empty
273]
274*/
275/*
276BREAK_ITERATOR
277DocComment[DOC_COMMENT, pos:1
278  firstSentence: 3
279    Text[TEXT, pos:1, abc_]
280    Literal[CODE, pos:5, code]
281    Text[TEXT, pos:17, _ghi._jkl_mno_pqr.]
282  body: empty
283  block tags: empty
284]
285*/
286    /**
287     * abc def ghi
288     * @author jjg
289     */
290    void block_tag() { }
291/*
292DocComment[DOC_COMMENT, pos:1
293  firstSentence: 1
294    Text[TEXT, pos:1, abc_def_ghi]
295  body: empty
296  block tags: 1
297    Author[AUTHOR, pos:14
298      name: 1
299        Text[TEXT, pos:22, jjg]
300    ]
301]
302*/
303/*
304BREAK_ITERATOR
305DocComment[DOC_COMMENT, pos:1
306  firstSentence: 1
307    Text[TEXT, pos:1, abc_def_ghi]
308  body: empty
309  block tags: 1
310    Author[AUTHOR, pos:14
311      name: 1
312        Text[TEXT, pos:22, jjg]
313    ]
314]
315*/
316    /**
317     * @author jjg
318     */
319    void just_tag() { }
320/*
321DocComment[DOC_COMMENT, pos:1
322  firstSentence: empty
323  body: empty
324  block tags: 1
325    Author[AUTHOR, pos:1
326      name: 1
327        Text[TEXT, pos:9, jjg]
328    ]
329]
330*/
331/*
332BREAK_ITERATOR
333DocComment[DOC_COMMENT, pos:1
334  firstSentence: empty
335  body: empty
336  block tags: 1
337    Author[AUTHOR, pos:1
338      name: 1
339        Text[TEXT, pos:9, jjg]
340    ]
341]
342*/
343    /**
344     * <p> abc def.
345     * ghi jkl
346     */
347    void p_at_zero() { }
348/*
349DocComment[DOC_COMMENT, pos:1
350  firstSentence: 2
351    StartElement[START_ELEMENT, pos:1
352      name:p
353      attributes: empty
354    ]
355    Text[TEXT, pos:4, _abc_def.]
356  body: 1
357    Text[TEXT, pos:15, ghi_jkl]
358  block tags: empty
359]
360*/
361/*
362BREAK_ITERATOR
363DocComment[DOC_COMMENT, pos:1
364  firstSentence: 2
365    StartElement[START_ELEMENT, pos:1
366      name:p
367      attributes: empty
368    ]
369    Text[TEXT, pos:4, _abc_def.]
370  body: 1
371    Text[TEXT, pos:15, ghi_jkl]
372  block tags: empty
373]
374*/
375
376    /**
377     * abc <p> def. ghi jkl
378     */
379    void p_at_nonzero() { }
380/*
381DocComment[DOC_COMMENT, pos:1
382  firstSentence: 1
383    Text[TEXT, pos:1, abc]
384  body: 2
385    StartElement[START_ELEMENT, pos:5
386      name:p
387      attributes: empty
388    ]
389    Text[TEXT, pos:8, _def._ghi_jkl]
390  block tags: empty
391]
392*/
393/*
394BREAK_ITERATOR
395DocComment[DOC_COMMENT, pos:1
396  firstSentence: 1
397    Text[TEXT, pos:1, abc]
398  body: 2
399    StartElement[START_ELEMENT, pos:5
400      name:p
401      attributes: empty
402    ]
403    Text[TEXT, pos:8, _def._ghi_jkl]
404  block tags: empty
405]
406*/
407}
408
409