DCTree.java revision 3209:1203d1d370e2
1/* 2 * Copyright (c) 2011, 2016, 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.tools.javac.tree; 27 28import javax.tools.Diagnostic; 29 30import com.sun.source.doctree.*; 31import com.sun.tools.javac.parser.Tokens.Comment; 32import com.sun.tools.javac.util.Assert; 33import com.sun.tools.javac.util.DefinedBy; 34import com.sun.tools.javac.util.DefinedBy.Api; 35import com.sun.tools.javac.util.DiagnosticSource; 36import com.sun.tools.javac.util.JCDiagnostic; 37import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; 38import com.sun.tools.javac.util.Position; 39 40import java.io.IOException; 41import java.io.StringWriter; 42import java.util.List; 43 44import javax.lang.model.element.Name; 45import javax.tools.JavaFileObject; 46 47/** 48 * <p><b>This is NOT part of any supported API. 49 * If you write code that depends on this, you do so at your own risk. 50 * This code and its internal interfaces are subject to change or 51 * deletion without notice.</b> 52 */ 53public abstract class DCTree implements DocTree { 54 55 /** 56 * The position in the comment string. 57 * Use {@link #getSourcePosition getSourcePosition} to convert 58 * it to a position in the source file. 59 * 60 * TODO: why not simply translate all these values into 61 * source file positions? Is it useful to have string-offset 62 * positions as well? 63 */ 64 public int pos; 65 66 public long getSourcePosition(DCDocComment dc) { 67 return dc.comment.getSourcePos(pos); 68 } 69 70 public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) { 71 return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos)); 72 } 73 74 /** Convert a tree to a pretty-printed string. */ 75 @Override 76 public String toString() { 77 StringWriter s = new StringWriter(); 78 try { 79 new DocPretty(s).print(this); 80 } 81 catch (IOException e) { 82 // should never happen, because StringWriter is defined 83 // never to throw any IOExceptions 84 throw new AssertionError(e); 85 } 86 return s.toString(); 87 } 88 89 public static abstract class DCEndPosTree<T extends DCEndPosTree<T>> extends DCTree { 90 91 private int endPos = Position.NOPOS; 92 93 public int getEndPos(DCDocComment dc) { 94 return dc.comment.getSourcePos(endPos); 95 } 96 97 @SuppressWarnings("unchecked") 98 public T setEndPos(int endPos) { 99 this.endPos = endPos; 100 return (T) this; 101 } 102 103 } 104 105 public static class DCDocComment extends DCTree implements DocCommentTree { 106 public final Comment comment; // required for the implicit source pos table 107 108 public final List<DCTree> fullBody; 109 public final List<DCTree> firstSentence; 110 public final List<DCTree> body; 111 public final List<DCTree> tags; 112 113 public DCDocComment(Comment comment, 114 List<DCTree> fullBody, 115 List<DCTree> firstSentence, 116 List<DCTree> body, 117 List<DCTree> tags) { 118 this.comment = comment; 119 this.firstSentence = firstSentence; 120 this.fullBody = fullBody; 121 this.body = body; 122 this.tags = tags; 123 } 124 125 @Override @DefinedBy(Api.COMPILER_TREE) 126 public Kind getKind() { 127 return Kind.DOC_COMMENT; 128 } 129 130 @Override @DefinedBy(Api.COMPILER_TREE) 131 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 132 return v.visitDocComment(this, d); 133 } 134 135 @Override @DefinedBy(Api.COMPILER_TREE) 136 public List<? extends DocTree> getFirstSentence() { 137 return firstSentence; 138 } 139 140 @Override @DefinedBy(Api.COMPILER_TREE) 141 public List<? extends DocTree> getFullBody() { 142 return fullBody; 143 } 144 145 @Override @DefinedBy(Api.COMPILER_TREE) 146 public List<? extends DocTree> getBody() { 147 return body; 148 } 149 150 @Override @DefinedBy(Api.COMPILER_TREE) 151 public List<? extends DocTree> getBlockTags() { 152 return tags; 153 } 154 155 } 156 157 public static abstract class DCBlockTag extends DCTree implements BlockTagTree { 158 @Override @DefinedBy(Api.COMPILER_TREE) 159 public String getTagName() { 160 return getKind().tagName; 161 } 162 } 163 164 public static abstract class DCInlineTag extends DCEndPosTree<DCInlineTag> implements InlineTagTree { 165 @Override @DefinedBy(Api.COMPILER_TREE) 166 public String getTagName() { 167 return getKind().tagName; 168 } 169 } 170 171 public static class DCAttribute extends DCTree implements AttributeTree { 172 public final Name name; 173 public final ValueKind vkind; 174 public final List<DCTree> value; 175 176 DCAttribute(Name name, ValueKind vkind, List<DCTree> value) { 177 Assert.check((vkind == ValueKind.EMPTY) ? (value == null) : (value != null)); 178 this.name = name; 179 this.vkind = vkind; 180 this.value = value; 181 } 182 183 @Override @DefinedBy(Api.COMPILER_TREE) 184 public Kind getKind() { 185 return Kind.ATTRIBUTE; 186 } 187 188 @Override @DefinedBy(Api.COMPILER_TREE) 189 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 190 return v.visitAttribute(this, d); 191 } 192 193 @Override @DefinedBy(Api.COMPILER_TREE) 194 public Name getName() { 195 return name; 196 } 197 198 @Override @DefinedBy(Api.COMPILER_TREE) 199 public ValueKind getValueKind() { 200 return vkind; 201 } 202 203 @Override @DefinedBy(Api.COMPILER_TREE) 204 public List<DCTree> getValue() { 205 return value; 206 } 207 } 208 209 public static class DCAuthor extends DCBlockTag implements AuthorTree { 210 public final List<DCTree> name; 211 212 DCAuthor(List<DCTree> name) { 213 this.name = name; 214 } 215 216 @Override @DefinedBy(Api.COMPILER_TREE) 217 public Kind getKind() { 218 return Kind.AUTHOR; 219 } 220 221 @Override @DefinedBy(Api.COMPILER_TREE) 222 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 223 return v.visitAuthor(this, d); 224 } 225 226 @Override @DefinedBy(Api.COMPILER_TREE) 227 public List<? extends DocTree> getName() { 228 return name; 229 } 230 } 231 232 public static class DCComment extends DCTree implements CommentTree { 233 public final String body; 234 235 DCComment(String body) { 236 this.body = body; 237 } 238 239 @Override @DefinedBy(Api.COMPILER_TREE) 240 public Kind getKind() { 241 return Kind.COMMENT; 242 } 243 244 @Override @DefinedBy(Api.COMPILER_TREE) 245 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 246 return v.visitComment(this, d); 247 } 248 249 @Override @DefinedBy(Api.COMPILER_TREE) 250 public String getBody() { 251 return body; 252 } 253 } 254 255 public static class DCDeprecated extends DCBlockTag implements DeprecatedTree { 256 public final List<DCTree> body; 257 258 DCDeprecated(List<DCTree> body) { 259 this.body = body; 260 } 261 262 @Override @DefinedBy(Api.COMPILER_TREE) 263 public Kind getKind() { 264 return Kind.DEPRECATED; 265 } 266 267 @Override @DefinedBy(Api.COMPILER_TREE) 268 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 269 return v.visitDeprecated(this, d); 270 } 271 272 @Override @DefinedBy(Api.COMPILER_TREE) 273 public List<? extends DocTree> getBody() { 274 return body; 275 } 276 } 277 278 public static class DCDocRoot extends DCInlineTag implements DocRootTree { 279 280 @Override @DefinedBy(Api.COMPILER_TREE) 281 public Kind getKind() { 282 return Kind.DOC_ROOT; 283 } 284 285 @Override @DefinedBy(Api.COMPILER_TREE) 286 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 287 return v.visitDocRoot(this, d); 288 } 289 } 290 291 public static class DCEndElement extends DCTree implements EndElementTree { 292 public final Name name; 293 294 DCEndElement(Name name) { 295 this.name = name; 296 } 297 298 @Override @DefinedBy(Api.COMPILER_TREE) 299 public Kind getKind() { 300 return Kind.END_ELEMENT; 301 } 302 303 @Override @DefinedBy(Api.COMPILER_TREE) 304 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 305 return v.visitEndElement(this, d); 306 } 307 308 @Override @DefinedBy(Api.COMPILER_TREE) 309 public Name getName() { 310 return name; 311 } 312 } 313 314 public static class DCEntity extends DCTree implements EntityTree { 315 public final Name name; 316 317 DCEntity(Name name) { 318 this.name = name; 319 } 320 321 @Override @DefinedBy(Api.COMPILER_TREE) 322 public Kind getKind() { 323 return Kind.ENTITY; 324 } 325 326 @Override @DefinedBy(Api.COMPILER_TREE) 327 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 328 return v.visitEntity(this, d); 329 } 330 331 @Override @DefinedBy(Api.COMPILER_TREE) 332 public Name getName() { 333 return name; 334 } 335 } 336 337 public static class DCErroneous extends DCTree implements ErroneousTree, JCDiagnostic.DiagnosticPosition { 338 public final String body; 339 public final JCDiagnostic diag; 340 341 DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { 342 this.body = body; 343 this.diag = diags.error(null, diagSource, this, code, args); 344 } 345 346 DCErroneous(String body, JCDiagnostic diag) { 347 this.body = body; 348 this.diag = diag; 349 } 350 351 @Override @DefinedBy(Api.COMPILER_TREE) 352 public Kind getKind() { 353 return Kind.ERRONEOUS; 354 } 355 356 @Override @DefinedBy(Api.COMPILER_TREE) 357 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 358 return v.visitErroneous(this, d); 359 } 360 361 @Override @DefinedBy(Api.COMPILER_TREE) 362 public String getBody() { 363 return body; 364 } 365 366 @Override @DefinedBy(Api.COMPILER_TREE) 367 public Diagnostic<JavaFileObject> getDiagnostic() { 368 return diag; 369 } 370 371 @Override 372 public JCTree getTree() { 373 return null; 374 } 375 376 @Override 377 public int getStartPosition() { 378 return pos; 379 } 380 381 @Override 382 public int getPreferredPosition() { 383 return pos + body.length() - 1; 384 } 385 386 @Override 387 public int getEndPosition(EndPosTable endPosTable) { 388 return pos + body.length(); 389 } 390 391 } 392 393 public static class DCIdentifier extends DCTree implements IdentifierTree { 394 public final Name name; 395 396 DCIdentifier(Name name) { 397 this.name = name; 398 } 399 400 @Override @DefinedBy(Api.COMPILER_TREE) 401 public Kind getKind() { 402 return Kind.IDENTIFIER; 403 } 404 405 @Override @DefinedBy(Api.COMPILER_TREE) 406 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 407 return v.visitIdentifier(this, d); 408 } 409 410 @Override @DefinedBy(Api.COMPILER_TREE) 411 public Name getName() { 412 return name; 413 } 414 } 415 416 public static class DCIndex extends DCInlineTag implements IndexTree { 417 public final DCTree term; 418 public final List<DCTree> description; 419 420 DCIndex(DCTree term, List<DCTree> description) { 421 this.term = term; 422 this.description = description; 423 } 424 425 @Override @DefinedBy(Api.COMPILER_TREE) 426 public Kind getKind() { 427 return Kind.INDEX; 428 } 429 430 @Override @DefinedBy(Api.COMPILER_TREE) 431 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 432 return v.visitIndex(this, d); 433 } 434 435 @Override @DefinedBy(Api.COMPILER_TREE) 436 public DocTree getSearchTerm() { 437 return term; 438 } 439 440 @Override @DefinedBy(Api.COMPILER_TREE) 441 public java.util.List<? extends DocTree> getDescription() { 442 return description; 443 } 444 } 445 446 public static class DCInheritDoc extends DCInlineTag implements InheritDocTree { 447 @Override @DefinedBy(Api.COMPILER_TREE) 448 public Kind getKind() { 449 return Kind.INHERIT_DOC; 450 } 451 452 @Override @DefinedBy(Api.COMPILER_TREE) 453 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 454 return v.visitInheritDoc(this, d); 455 } 456 } 457 458 public static class DCLink extends DCInlineTag implements LinkTree { 459 public final Kind kind; 460 public final DCReference ref; 461 public final List<DCTree> label; 462 463 DCLink(Kind kind, DCReference ref, List<DCTree> label) { 464 Assert.check(kind == Kind.LINK || kind == Kind.LINK_PLAIN); 465 this.kind = kind; 466 this.ref = ref; 467 this.label = label; 468 } 469 470 @Override @DefinedBy(Api.COMPILER_TREE) 471 public Kind getKind() { 472 return kind; 473 } 474 475 @Override @DefinedBy(Api.COMPILER_TREE) 476 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 477 return v.visitLink(this, d); 478 } 479 480 @Override @DefinedBy(Api.COMPILER_TREE) 481 public ReferenceTree getReference() { 482 return ref; 483 } 484 485 @Override @DefinedBy(Api.COMPILER_TREE) 486 public List<? extends DocTree> getLabel() { 487 return label; 488 } 489 } 490 491 public static class DCLiteral extends DCInlineTag implements LiteralTree { 492 public final Kind kind; 493 public final DCText body; 494 495 DCLiteral(Kind kind, DCText body) { 496 Assert.check(kind == Kind.CODE || kind == Kind.LITERAL); 497 this.kind = kind; 498 this.body = body; 499 } 500 501 @Override @DefinedBy(Api.COMPILER_TREE) 502 public Kind getKind() { 503 return kind; 504 } 505 506 @Override @DefinedBy(Api.COMPILER_TREE) 507 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 508 return v.visitLiteral(this, d); 509 } 510 511 @Override @DefinedBy(Api.COMPILER_TREE) 512 public DCText getBody() { 513 return body; 514 } 515 } 516 517 public static class DCParam extends DCBlockTag implements ParamTree { 518 public final boolean isTypeParameter; 519 public final DCIdentifier name; 520 public final List<DCTree> description; 521 522 DCParam(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) { 523 this.isTypeParameter = isTypeParameter; 524 this.name = name; 525 this.description = description; 526 } 527 528 @Override @DefinedBy(Api.COMPILER_TREE) 529 public Kind getKind() { 530 return Kind.PARAM; 531 } 532 533 @Override @DefinedBy(Api.COMPILER_TREE) 534 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 535 return v.visitParam(this, d); 536 } 537 538 @Override @DefinedBy(Api.COMPILER_TREE) 539 public boolean isTypeParameter() { 540 return isTypeParameter; 541 } 542 543 @Override @DefinedBy(Api.COMPILER_TREE) 544 public IdentifierTree getName() { 545 return name; 546 } 547 548 @Override @DefinedBy(Api.COMPILER_TREE) 549 public List<? extends DocTree> getDescription() { 550 return description; 551 } 552 } 553 554 public static class DCReference extends DCEndPosTree<DCReference> implements ReferenceTree { 555 public final String signature; 556 557 // The following are not directly exposed through ReferenceTree 558 // use DocTrees.getElement(TreePath,ReferenceTree) 559 public final JCTree qualifierExpression; 560 public final Name memberName; 561 public final List<JCTree> paramTypes; 562 563 564 DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) { 565 this.signature = signature; 566 qualifierExpression = qualExpr; 567 memberName = member; 568 this.paramTypes = paramTypes; 569 } 570 571 @Override @DefinedBy(Api.COMPILER_TREE) 572 public Kind getKind() { 573 return Kind.REFERENCE; 574 } 575 576 @Override @DefinedBy(Api.COMPILER_TREE) 577 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 578 return v.visitReference(this, d); 579 } 580 581 @Override @DefinedBy(Api.COMPILER_TREE) 582 public String getSignature() { 583 return signature; 584 } 585 } 586 587 public static class DCReturn extends DCBlockTag implements ReturnTree { 588 public final List<DCTree> description; 589 590 DCReturn(List<DCTree> description) { 591 this.description = description; 592 } 593 594 @Override @DefinedBy(Api.COMPILER_TREE) 595 public Kind getKind() { 596 return Kind.RETURN; 597 } 598 599 @Override @DefinedBy(Api.COMPILER_TREE) 600 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 601 return v.visitReturn(this, d); 602 } 603 604 @Override @DefinedBy(Api.COMPILER_TREE) 605 public List<? extends DocTree> getDescription() { 606 return description; 607 } 608 } 609 610 public static class DCSee extends DCBlockTag implements SeeTree { 611 public final List<DCTree> reference; 612 613 DCSee(List<DCTree> reference) { 614 this.reference = reference; 615 } 616 617 @Override @DefinedBy(Api.COMPILER_TREE) 618 public Kind getKind() { 619 return Kind.SEE; 620 } 621 622 @Override @DefinedBy(Api.COMPILER_TREE) 623 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 624 return v.visitSee(this, d); 625 } 626 627 @Override @DefinedBy(Api.COMPILER_TREE) 628 public List<? extends DocTree> getReference() { 629 return reference; 630 } 631 } 632 633 public static class DCSerial extends DCBlockTag implements SerialTree { 634 public final List<DCTree> description; 635 636 DCSerial(List<DCTree> description) { 637 this.description = description; 638 } 639 640 @Override @DefinedBy(Api.COMPILER_TREE) 641 public Kind getKind() { 642 return Kind.SERIAL; 643 } 644 645 @Override @DefinedBy(Api.COMPILER_TREE) 646 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 647 return v.visitSerial(this, d); 648 } 649 650 @Override @DefinedBy(Api.COMPILER_TREE) 651 public List<? extends DocTree> getDescription() { 652 return description; 653 } 654 } 655 656 public static class DCSerialData extends DCBlockTag implements SerialDataTree { 657 public final List<DCTree> description; 658 659 DCSerialData(List<DCTree> description) { 660 this.description = description; 661 } 662 663 @Override @DefinedBy(Api.COMPILER_TREE) 664 public Kind getKind() { 665 return Kind.SERIAL_DATA; 666 } 667 668 @Override @DefinedBy(Api.COMPILER_TREE) 669 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 670 return v.visitSerialData(this, d); 671 } 672 673 @Override @DefinedBy(Api.COMPILER_TREE) 674 public List<? extends DocTree> getDescription() { 675 return description; 676 } 677 } 678 679 public static class DCSerialField extends DCBlockTag implements SerialFieldTree { 680 public final DCIdentifier name; 681 public final DCReference type; 682 public final List<DCTree> description; 683 684 DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description) { 685 this.description = description; 686 this.name = name; 687 this.type = type; 688 } 689 690 @Override @DefinedBy(Api.COMPILER_TREE) 691 public Kind getKind() { 692 return Kind.SERIAL_FIELD; 693 } 694 695 @Override @DefinedBy(Api.COMPILER_TREE) 696 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 697 return v.visitSerialField(this, d); 698 } 699 700 @Override @DefinedBy(Api.COMPILER_TREE) 701 public List<? extends DocTree> getDescription() { 702 return description; 703 } 704 705 @Override @DefinedBy(Api.COMPILER_TREE) 706 public IdentifierTree getName() { 707 return name; 708 } 709 710 @Override @DefinedBy(Api.COMPILER_TREE) 711 public ReferenceTree getType() { 712 return type; 713 } 714 } 715 716 public static class DCSince extends DCBlockTag implements SinceTree { 717 public final List<DCTree> body; 718 719 DCSince(List<DCTree> body) { 720 this.body = body; 721 } 722 723 @Override @DefinedBy(Api.COMPILER_TREE) 724 public Kind getKind() { 725 return Kind.SINCE; 726 } 727 728 @Override @DefinedBy(Api.COMPILER_TREE) 729 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 730 return v.visitSince(this, d); 731 } 732 733 @Override @DefinedBy(Api.COMPILER_TREE) 734 public List<? extends DocTree> getBody() { 735 return body; 736 } 737 } 738 739 public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree { 740 public final Name name; 741 public final List<DCTree> attrs; 742 public final boolean selfClosing; 743 744 DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing) { 745 this.name = name; 746 this.attrs = attrs; 747 this.selfClosing = selfClosing; 748 } 749 750 @Override @DefinedBy(Api.COMPILER_TREE) 751 public Kind getKind() { 752 return Kind.START_ELEMENT; 753 } 754 755 @Override @DefinedBy(Api.COMPILER_TREE) 756 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 757 return v.visitStartElement(this, d); 758 } 759 760 @Override @DefinedBy(Api.COMPILER_TREE) 761 public Name getName() { 762 return name; 763 } 764 765 @Override @DefinedBy(Api.COMPILER_TREE) 766 public List<? extends DocTree> getAttributes() { 767 return attrs; 768 } 769 770 @Override @DefinedBy(Api.COMPILER_TREE) 771 public boolean isSelfClosing() { 772 return selfClosing; 773 } 774 } 775 776 public static class DCText extends DCTree implements TextTree { 777 public final String text; 778 779 DCText(String text) { 780 this.text = text; 781 } 782 783 @Override @DefinedBy(Api.COMPILER_TREE) 784 public Kind getKind() { 785 return Kind.TEXT; 786 } 787 788 @Override @DefinedBy(Api.COMPILER_TREE) 789 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 790 return v.visitText(this, d); 791 } 792 793 @Override @DefinedBy(Api.COMPILER_TREE) 794 public String getBody() { 795 return text; 796 } 797 } 798 799 public static class DCThrows extends DCBlockTag implements ThrowsTree { 800 public final Kind kind; 801 public final DCReference name; 802 public final List<DCTree> description; 803 804 DCThrows(Kind kind, DCReference name, List<DCTree> description) { 805 Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS); 806 this.kind = kind; 807 this.name = name; 808 this.description = description; 809 } 810 811 @Override @DefinedBy(Api.COMPILER_TREE) 812 public Kind getKind() { 813 return kind; 814 } 815 816 @Override @DefinedBy(Api.COMPILER_TREE) 817 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 818 return v.visitThrows(this, d); 819 } 820 821 @Override @DefinedBy(Api.COMPILER_TREE) 822 public ReferenceTree getExceptionName() { 823 return name; 824 } 825 826 @Override @DefinedBy(Api.COMPILER_TREE) 827 public List<? extends DocTree> getDescription() { 828 return description; 829 } 830 } 831 832 public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree { 833 public final Name name; 834 public final List<DCTree> content; 835 836 DCUnknownBlockTag(Name name, List<DCTree> content) { 837 this.name = name; 838 this.content = content; 839 } 840 841 @Override @DefinedBy(Api.COMPILER_TREE) 842 public Kind getKind() { 843 return Kind.UNKNOWN_BLOCK_TAG; 844 } 845 846 @Override @DefinedBy(Api.COMPILER_TREE) 847 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 848 return v.visitUnknownBlockTag(this, d); 849 } 850 851 @Override @DefinedBy(Api.COMPILER_TREE) 852 public String getTagName() { 853 return name.toString(); 854 } 855 856 @Override @DefinedBy(Api.COMPILER_TREE) 857 public List<? extends DocTree> getContent() { 858 return content; 859 } 860 } 861 862 public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree { 863 public final Name name; 864 public final List<DCTree> content; 865 866 DCUnknownInlineTag(Name name, List<DCTree> content) { 867 this.name = name; 868 this.content = content; 869 } 870 871 @Override @DefinedBy(Api.COMPILER_TREE) 872 public Kind getKind() { 873 return Kind.UNKNOWN_INLINE_TAG; 874 } 875 876 @Override @DefinedBy(Api.COMPILER_TREE) 877 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 878 return v.visitUnknownInlineTag(this, d); 879 } 880 881 @Override @DefinedBy(Api.COMPILER_TREE) 882 public String getTagName() { 883 return name.toString(); 884 } 885 886 @Override @DefinedBy(Api.COMPILER_TREE) 887 public List<? extends DocTree> getContent() { 888 return content; 889 } 890 } 891 892 public static class DCValue extends DCInlineTag implements ValueTree { 893 public final DCReference ref; 894 895 DCValue(DCReference ref) { 896 this.ref = ref; 897 } 898 899 @Override @DefinedBy(Api.COMPILER_TREE) 900 public Kind getKind() { 901 return Kind.VALUE; 902 } 903 904 @Override @DefinedBy(Api.COMPILER_TREE) 905 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 906 return v.visitValue(this, d); 907 } 908 909 @Override @DefinedBy(Api.COMPILER_TREE) 910 public ReferenceTree getReference() { 911 return ref; 912 } 913 } 914 915 public static class DCVersion extends DCBlockTag implements VersionTree { 916 public final List<DCTree> body; 917 918 DCVersion(List<DCTree> body) { 919 this.body = body; 920 } 921 922 @Override @DefinedBy(Api.COMPILER_TREE) 923 public Kind getKind() { 924 return Kind.VERSION; 925 } 926 927 @Override @DefinedBy(Api.COMPILER_TREE) 928 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 929 return v.visitVersion(this, d); 930 } 931 932 @Override @DefinedBy(Api.COMPILER_TREE) 933 public List<? extends DocTree> getBody() { 934 return body; 935 } 936 } 937 938} 939