1 /* 2 * Copyright (c) 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 8144287 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 IndexTest.java 34 */ 35 36 class IndexTest { 37 /** 38 * abc {@index xyz} def 39 */ simple_term()40 void simple_term() {} 41 /* 42 DocComment[DOC_COMMENT, pos:1 43 firstSentence: 3 44 Text[TEXT, pos:1, abc_] 45 Index[INDEX, pos:5 46 term: 47 Text[TEXT, pos:13, xyz] 48 description: empty 49 ] 50 Text[TEXT, pos:17, _def] 51 body: empty 52 block tags: empty 53 ] 54 */ 55 56 /** 57 * abc {@index lmn pqr stu} def 58 */ simple_term_with_description()59 void simple_term_with_description() { } 60 /* 61 DocComment[DOC_COMMENT, pos:1 62 firstSentence: 3 63 Text[TEXT, pos:1, abc_] 64 Index[INDEX, pos:5 65 term: 66 Text[TEXT, pos:13, lmn] 67 description: 1 68 Text[TEXT, pos:17, pqr_stu] 69 ] 70 Text[TEXT, pos:25, _def] 71 body: empty 72 block tags: empty 73 ] 74 */ 75 76 /** 77 * abc {@index ijk {lmn opq} } def 78 */ phrase_with_curly_description()79 void phrase_with_curly_description() { } 80 /* 81 DocComment[DOC_COMMENT, pos:1 82 firstSentence: 3 83 Text[TEXT, pos:1, abc_] 84 Index[INDEX, pos:5 85 term: 86 Text[TEXT, pos:13, ijk] 87 description: 1 88 Text[TEXT, pos:17, {lmn_opq}_] 89 ] 90 Text[TEXT, pos:28, _def] 91 body: empty 92 block tags: empty 93 ] 94 */ 95 /** 96 * abc {@index ijk lmn 97 * opq 98 * rst 99 * } def 100 */ phrase_with_nl_description()101 void phrase_with_nl_description() { } 102 /* 103 DocComment[DOC_COMMENT, pos:1 104 firstSentence: 3 105 Text[TEXT, pos:1, abc_] 106 Index[INDEX, pos:5 107 term: 108 Text[TEXT, pos:13, ijk] 109 description: 1 110 Text[TEXT, pos:17, lmn|_opq|_rst|_] 111 ] 112 Text[TEXT, pos:33, _def] 113 body: empty 114 block tags: empty 115 ] 116 */ 117 118 /** 119 * abc {@index "lmn pqr"} def 120 */ phrase_no_description()121 void phrase_no_description() { } 122 /* 123 DocComment[DOC_COMMENT, pos:1 124 firstSentence: 3 125 Text[TEXT, pos:1, abc_] 126 Index[INDEX, pos:5 127 term: 128 Text[TEXT, pos:13, "lmn_pqr"] 129 description: empty 130 ] 131 Text[TEXT, pos:23, _def] 132 body: empty 133 block tags: empty 134 ] 135 */ 136 137 /** 138 * abc {@index "ijk lmn" pqr xyz} def 139 */ phrase_with_description()140 void phrase_with_description() { } 141 /* 142 DocComment[DOC_COMMENT, pos:1 143 firstSentence: 3 144 Text[TEXT, pos:1, abc_] 145 Index[INDEX, pos:5 146 term: 147 Text[TEXT, pos:13, "ijk_lmn"] 148 description: 1 149 Text[TEXT, pos:23, pqr_xyz] 150 ] 151 Text[TEXT, pos:31, _def] 152 body: empty 153 block tags: empty 154 ] 155 */ 156 157 /** 158 * abc {@index {@xyz} "{@see xyz}" def} 159 */ term_and_description_with_nested_tag()160 void term_and_description_with_nested_tag() {} 161 /* 162 DocComment[DOC_COMMENT, pos:1 163 firstSentence: 2 164 Text[TEXT, pos:1, abc_] 165 Index[INDEX, pos:5 166 term: 167 Text[TEXT, pos:13, {@xyz}] 168 description: 3 169 Text[TEXT, pos:20, "] 170 UnknownInlineTag[UNKNOWN_INLINE_TAG, pos:21 171 tag:see 172 content: 1 173 Text[TEXT, pos:27, xyz] 174 ] 175 Text[TEXT, pos:31, "_def] 176 ] 177 body: empty 178 block tags: empty 179 ] 180 */ 181 /** 182 * abc {@index @def lmn } xyz 183 */ term_with_at()184 void term_with_at() { } 185 /* 186 DocComment[DOC_COMMENT, pos:1 187 firstSentence: 3 188 Text[TEXT, pos:1, abc_] 189 Index[INDEX, pos:5 190 term: 191 Text[TEXT, pos:13, @def] 192 description: 1 193 Text[TEXT, pos:18, lmn_] 194 ] 195 Text[TEXT, pos:23, _xyz] 196 body: empty 197 block tags: empty 198 ] 199 */ 200 201 /** 202 * abc {@index ijk@lmn pqr } xyz 203 */ term_with_text_at()204 void term_with_text_at() { } 205 /* 206 DocComment[DOC_COMMENT, pos:1 207 firstSentence: 3 208 Text[TEXT, pos:1, abc_] 209 Index[INDEX, pos:5 210 term: 211 Text[TEXT, pos:13, ijk@lmn] 212 description: 1 213 Text[TEXT, pos:21, pqr_] 214 ] 215 Text[TEXT, pos:26, _xyz] 216 body: empty 217 block tags: empty 218 ] 219 */ 220 221 /** 222 * abc {@index ""} def 223 */ empty_index_in_quotes()224 void empty_index_in_quotes() {} 225 /* 226 DocComment[DOC_COMMENT, pos:1 227 firstSentence: 3 228 Text[TEXT, pos:1, abc_] 229 Index[INDEX, pos:5 230 term: 231 Text[TEXT, pos:13, ""] 232 description: empty 233 ] 234 Text[TEXT, pos:16, _def] 235 body: empty 236 block tags: empty 237 ] 238 */ 239 240 /** 241 * abc {@index 242 * @return def} xyz 243 */ bad_nl_at_in_term()244 void bad_nl_at_in_term() {} 245 /* 246 DocComment[DOC_COMMENT, pos:1 247 firstSentence: 2 248 Text[TEXT, pos:1, abc_] 249 Erroneous[ERRONEOUS, pos:5 250 code: compiler.err.dc.no.content 251 body: {@index 252 ] 253 body: empty 254 block tags: 1 255 Return[RETURN, pos:14 256 description: 1 257 Text[TEXT, pos:22, def}_xyz] 258 ] 259 ] 260 */ 261 /** 262 * abc {@index "xyz } def 263 */ bad_unbalanced_quote()264 void bad_unbalanced_quote() {} 265 /* 266 DocComment[DOC_COMMENT, pos:1 267 firstSentence: 2 268 Text[TEXT, pos:1, abc_] 269 Erroneous[ERRONEOUS, pos:5 270 code: compiler.err.dc.no.content 271 body: {@index_"xyz_}_def 272 ] 273 body: empty 274 block tags: empty 275 ] 276 */ 277 /** 278 * abc {@index} def 279 */ bad_no_index()280 void bad_no_index() {} 281 /* 282 DocComment[DOC_COMMENT, pos:1 283 firstSentence: 3 284 Text[TEXT, pos:1, abc_] 285 Erroneous[ERRONEOUS, pos:5 286 code: compiler.err.dc.no.content 287 body: {@index 288 ] 289 Text[TEXT, pos:12, }_def] 290 body: empty 291 block tags: empty 292 ] 293 */ 294 295 } 296