IndexTest.java revision 3162:f164d4c2d33e
1224135Sdim/*
2224135Sdim * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3224135Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4224135Sdim *
5224135Sdim * This code is free software; you can redistribute it and/or modify it
6224135Sdim * under the terms of the GNU General Public License version 2 only, as
7224135Sdim * published by the Free Software Foundation.
8224135Sdim *
9224135Sdim * This code is distributed in the hope that it will be useful, but WITHOUT
10224135Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11224135Sdim * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12224135Sdim * version 2 for more details (a copy is included in the LICENSE file that
13224135Sdim * accompanied this code).
14224135Sdim *
15224135Sdim * You should have received a copy of the GNU General Public License version
16224135Sdim * 2 along with this work; if not, write to the Free Software Foundation,
17224135Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18224135Sdim *
19252723Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20226890Sdim * or visit www.oracle.com if you need additional information or have any
21224135Sdim * questions.
22224135Sdim */
23224135Sdim
24224135Sdim/*
25224135Sdim * @test
26224135Sdim * @bug 8144287
27235633Sdim * @summary extend com.sun.source API to support parsing javadoc comments
28235633Sdim * @modules jdk.compiler/com.sun.tools.javac.api
29235633Sdim *          jdk.compiler/com.sun.tools.javac.file
30235633Sdim *          jdk.compiler/com.sun.tools.javac.tree
31235633Sdim *          jdk.compiler/com.sun.tools.javac.util
32235633Sdim * @build DocCommentTester
33235633Sdim * @run main DocCommentTester IndexTest.java
34235633Sdim */
35235633Sdim
36235633Sdimclass IndexTest {
37235633Sdim    /**
38235633Sdim     * abc {@index xyz} def
39235633Sdim     */
40235633Sdim    void simple_term() {}
41224135Sdim/*
42263509SdimDocComment[DOC_COMMENT, pos:1
43263509Sdim  firstSentence: 3
44235633Sdim    Text[TEXT, pos:1, abc_]
45263509Sdim    Index[INDEX, pos:5
46263509Sdim      term:
47263509Sdim        Text[TEXT, pos:13, xyz]
48226890Sdim      description: empty
49226890Sdim    ]
50226890Sdim    Text[TEXT, pos:17, _def]
51224135Sdim  body: empty
52263509Sdim  block tags: empty
53263509Sdim]
54235633Sdim*/
55263509Sdim
56263509Sdim    /**
57226890Sdim     * abc {@index lmn pqr stu} def
58226890Sdim     */
59226890Sdim    void simple_term_with_description() { }
60224135Sdim/*
61263509SdimDocComment[DOC_COMMENT, pos:1
62263509Sdim  firstSentence: 3
63235633Sdim    Text[TEXT, pos:1, abc_]
64263509Sdim    Index[INDEX, pos:5
65263509Sdim      term:
66224135Sdim        Text[TEXT, pos:13, lmn]
67224135Sdim      description: 1
68235633Sdim        Text[TEXT, pos:17, pqr_stu]
69263509Sdim    ]
70263509Sdim    Text[TEXT, pos:25, _def]
71224135Sdim  body: empty
72224135Sdim  block tags: empty
73224135Sdim]
74224135Sdim*/
75224135Sdim
76224135Sdim    /**
77224135Sdim     * abc {@index ijk {lmn opq} } def
78224135Sdim     */
79224135Sdim    void phrase_with_curly_description() { }
80224135Sdim/*
81224135SdimDocComment[DOC_COMMENT, pos:1
82224135Sdim  firstSentence: 3
83224135Sdim    Text[TEXT, pos:1, abc_]
84263509Sdim    Index[INDEX, pos:5
85224135Sdim      term:
86224135Sdim        Text[TEXT, pos:13, ijk]
87263509Sdim      description: 1
88263509Sdim        Text[TEXT, pos:17, {lmn_opq}_]
89263509Sdim    ]
90263509Sdim    Text[TEXT, pos:28, _def]
91263509Sdim  body: empty
92263509Sdim  block tags: empty
93263509Sdim]
94263509Sdim*/
95235633Sdim    /**
96235633Sdim     * abc {@index ijk lmn
97235633Sdim     * opq
98224135Sdim     * rst
99235633Sdim     * } def
100235633Sdim     */
101235633Sdim    void phrase_with_nl_description() { }
102235633Sdim/*
103235633SdimDocComment[DOC_COMMENT, pos:1
104235633Sdim  firstSentence: 3
105235633Sdim    Text[TEXT, pos:1, abc_]
106235633Sdim    Index[INDEX, pos:5
107235633Sdim      term:
108235633Sdim        Text[TEXT, pos:13, ijk]
109235633Sdim      description: 1
110235633Sdim        Text[TEXT, pos:17, lmn|_opq|_rst|_]
111235633Sdim    ]
112235633Sdim    Text[TEXT, pos:33, _def]
113235633Sdim  body: empty
114235633Sdim  block tags: empty
115235633Sdim]
116235633Sdim*/
117235633Sdim
118235633Sdim    /**
119235633Sdim     * abc {@index "lmn pqr"} def
120235633Sdim     */
121235633Sdim    void phrase_no_description() { }
122235633Sdim/*
123235633SdimDocComment[DOC_COMMENT, pos:1
124235633Sdim  firstSentence: 3
125235633Sdim    Text[TEXT, pos:1, abc_]
126235633Sdim    Index[INDEX, pos:5
127235633Sdim      term:
128235633Sdim        Text[TEXT, pos:13, "lmn_pqr"]
129235633Sdim      description: empty
130235633Sdim    ]
131224135Sdim    Text[TEXT, pos:23, _def]
132263509Sdim  body: empty
133226890Sdim  block tags: empty
134224135Sdim]
135224135Sdim*/
136224135Sdim
137224135Sdim    /**
138224135Sdim     * abc {@index "ijk lmn" pqr xyz} def
139263509Sdim     */
140263509Sdim    void phrase_with_description() { }
141263509Sdim/*
142263509SdimDocComment[DOC_COMMENT, pos:1
143263509Sdim  firstSentence: 3
144263509Sdim    Text[TEXT, pos:1, abc_]
145226890Sdim    Index[INDEX, pos:5
146224135Sdim      term:
147226890Sdim        Text[TEXT, pos:13, "ijk_lmn"]
148226890Sdim      description: 1
149224135Sdim        Text[TEXT, pos:23, pqr_xyz]
150224135Sdim    ]
151263509Sdim    Text[TEXT, pos:31, _def]
152263509Sdim  body: empty
153263509Sdim  block tags: empty
154263509Sdim]
155263509Sdim*/
156263509Sdim
157226890Sdim    /**
158226890Sdim     * abc {@index {@xyz} "{@see xyz}" def}
159226890Sdim     */
160226890Sdim    void term_and_description_with_nested_tag() {}
161224135Sdim/*
162224135SdimDocComment[DOC_COMMENT, pos:1
163224135Sdim  firstSentence: 2
164224135Sdim    Text[TEXT, pos:1, abc_]
165224135Sdim    Index[INDEX, pos:5
166226890Sdim      term:
167263509Sdim        Text[TEXT, pos:13, {@xyz}]
168224135Sdim      description: 1
169226890Sdim        Text[TEXT, pos:20, "{@see_xyz}"_def]
170226890Sdim    ]
171226890Sdim  body: empty
172226890Sdim  block tags: empty
173226890Sdim]
174226890Sdim*/
175226890Sdim    /**
176263509Sdim     * abc {@index @def lmn } xyz
177226890Sdim     */
178224135Sdim    void term_with_at() { }
179226890Sdim/*
180226890SdimDocComment[DOC_COMMENT, pos:1
181226890Sdim  firstSentence: 3
182226890Sdim    Text[TEXT, pos:1, abc_]
183226890Sdim    Index[INDEX, pos:5
184226890Sdim      term:
185226890Sdim        Text[TEXT, pos:13, @def]
186235633Sdim      description: 1
187235633Sdim        Text[TEXT, pos:18, lmn_]
188235633Sdim    ]
189235633Sdim    Text[TEXT, pos:23, _xyz]
190235633Sdim  body: empty
191235633Sdim  block tags: empty
192224135Sdim]
193226890Sdim*/
194224135Sdim
195226890Sdim    /**
196226890Sdim     * abc {@index ijk@lmn pqr } xyz
197226890Sdim     */
198226890Sdim    void term_with_text_at() { }
199263509Sdim/*
200245431SdimDocComment[DOC_COMMENT, pos:1
201263509Sdim  firstSentence: 3
202263509Sdim    Text[TEXT, pos:1, abc_]
203263509Sdim    Index[INDEX, pos:5
204245431Sdim      term:
205245431Sdim        Text[TEXT, pos:13, ijk@lmn]
206245431Sdim      description: 1
207245431Sdim        Text[TEXT, pos:21, pqr_]
208245431Sdim    ]
209245431Sdim    Text[TEXT, pos:26, _xyz]
210245431Sdim  body: empty
211263509Sdim  block tags: empty
212226890Sdim]
213226890Sdim*/
214226890Sdim
215226890Sdim    /**
216263509Sdim     * abc {@index ""} def
217235633Sdim     */
218235633Sdim    void empty_index_in_quotes() {}
219235633Sdim/*
220235633SdimDocComment[DOC_COMMENT, pos:1
221226890Sdim  firstSentence: 3
222263509Sdim    Text[TEXT, pos:1, abc_]
223263509Sdim    Index[INDEX, pos:5
224263509Sdim      term:
225263509Sdim        Text[TEXT, pos:13, ""]
226263509Sdim      description: empty
227224135Sdim    ]
228226890Sdim    Text[TEXT, pos:16, _def]
229226890Sdim  body: empty
230226890Sdim  block tags: empty
231226890Sdim]
232224135Sdim*/
233224135Sdim
234224135Sdim    /**
235252723Sdim     * abc {@index
236235633Sdim     * @return def} xyz
237235633Sdim     */
238235633Sdim    void bad_nl_at_in_term() {}
239245431Sdim/*
240263509SdimDocComment[DOC_COMMENT, pos:1
241263509Sdim  firstSentence: 2
242224135Sdim    Text[TEXT, pos:1, abc_]
243224135Sdim    Erroneous[ERRONEOUS, pos:5
244235633Sdim      code: compiler.err.dc.no.content
245235633Sdim      body: {@index
246235633Sdim    ]
247263509Sdim  body: empty
248235633Sdim  block tags: 1
249235633Sdim    Return[RETURN, pos:14
250235633Sdim      description: 1
251235633Sdim        Text[TEXT, pos:22, def}_xyz]
252235633Sdim    ]
253235633Sdim]
254235633Sdim*/
255235633Sdim    /**
256235633Sdim     * abc {@index "xyz } def
257235633Sdim     */
258235633Sdim    void bad_unbalanced_quote() {}
259235633Sdim/*
260235633SdimDocComment[DOC_COMMENT, pos:1
261235633Sdim  firstSentence: 2
262235633Sdim    Text[TEXT, pos:1, abc_]
263235633Sdim    Erroneous[ERRONEOUS, pos:5
264252723Sdim      code: compiler.err.dc.no.content
265252723Sdim      body: {@index_"xyz_}_def
266252723Sdim    ]
267252723Sdim  body: empty
268252723Sdim  block tags: empty
269235633Sdim]
270235633Sdim*/
271235633Sdim    /**
272235633Sdim     * abc {@index} def
273235633Sdim     */
274235633Sdim    void bad_no_index() {}
275235633Sdim/*
276235633SdimDocComment[DOC_COMMENT, pos:1
277235633Sdim  firstSentence: 3
278235633Sdim    Text[TEXT, pos:1, abc_]
279235633Sdim    Erroneous[ERRONEOUS, pos:5
280235633Sdim      code: compiler.err.dc.no.content
281235633Sdim      body: {@index
282235633Sdim    ]
283235633Sdim    Text[TEXT, pos:12, }_def]
284235633Sdim  body: empty
285235633Sdim  block tags: empty
286235633Sdim]
287235633Sdim*/
288235633Sdim
289235633Sdim}
290235633Sdim