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: 1 169 Text[TEXT, pos:20, "{@see_xyz}"_def] 170 ] 171 body: empty 172 block tags: empty 173 ] 174 */ 175 /** 176 * abc {@index @def lmn } xyz 177 */ term_with_at()178 void term_with_at() { } 179 /* 180 DocComment[DOC_COMMENT, pos:1 181 firstSentence: 3 182 Text[TEXT, pos:1, abc_] 183 Index[INDEX, pos:5 184 term: 185 Text[TEXT, pos:13, @def] 186 description: 1 187 Text[TEXT, pos:18, lmn_] 188 ] 189 Text[TEXT, pos:23, _xyz] 190 body: empty 191 block tags: empty 192 ] 193 */ 194 195 /** 196 * abc {@index ijk@lmn pqr } xyz 197 */ term_with_text_at()198 void term_with_text_at() { } 199 /* 200 DocComment[DOC_COMMENT, pos:1 201 firstSentence: 3 202 Text[TEXT, pos:1, abc_] 203 Index[INDEX, pos:5 204 term: 205 Text[TEXT, pos:13, ijk@lmn] 206 description: 1 207 Text[TEXT, pos:21, pqr_] 208 ] 209 Text[TEXT, pos:26, _xyz] 210 body: empty 211 block tags: empty 212 ] 213 */ 214 215 /** 216 * abc {@index ""} def 217 */ empty_index_in_quotes()218 void empty_index_in_quotes() {} 219 /* 220 DocComment[DOC_COMMENT, pos:1 221 firstSentence: 3 222 Text[TEXT, pos:1, abc_] 223 Index[INDEX, pos:5 224 term: 225 Text[TEXT, pos:13, ""] 226 description: empty 227 ] 228 Text[TEXT, pos:16, _def] 229 body: empty 230 block tags: empty 231 ] 232 */ 233 234 /** 235 * abc {@index 236 * @return def} xyz 237 */ bad_nl_at_in_term()238 void bad_nl_at_in_term() {} 239 /* 240 DocComment[DOC_COMMENT, pos:1 241 firstSentence: 2 242 Text[TEXT, pos:1, abc_] 243 Erroneous[ERRONEOUS, pos:5 244 code: compiler.err.dc.no.content 245 body: {@index 246 ] 247 body: empty 248 block tags: 1 249 Return[RETURN, pos:14 250 description: 1 251 Text[TEXT, pos:22, def}_xyz] 252 ] 253 ] 254 */ 255 /** 256 * abc {@index "xyz } def 257 */ bad_unbalanced_quote()258 void bad_unbalanced_quote() {} 259 /* 260 DocComment[DOC_COMMENT, pos:1 261 firstSentence: 2 262 Text[TEXT, pos:1, abc_] 263 Erroneous[ERRONEOUS, pos:5 264 code: compiler.err.dc.no.content 265 body: {@index_"xyz_}_def 266 ] 267 body: empty 268 block tags: empty 269 ] 270 */ 271 /** 272 * abc {@index} def 273 */ bad_no_index()274 void bad_no_index() {} 275 /* 276 DocComment[DOC_COMMENT, pos:1 277 firstSentence: 3 278 Text[TEXT, pos:1, abc_] 279 Erroneous[ERRONEOUS, pos:5 280 code: compiler.err.dc.no.content 281 body: {@index 282 ] 283 Text[TEXT, pos:12, }_def] 284 body: empty 285 block tags: empty 286 ] 287 */ 288 289 } 290