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