DCTree.java revision 3337:cba09a2e6ae9
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 DCHidden extends DCBlockTag implements HiddenTree { 394 public final List<DCTree> body; 395 396 DCHidden(List<DCTree> body) { 397 this.body = body; 398 } 399 400 @Override @DefinedBy(Api.COMPILER_TREE) 401 public Kind getKind() { 402 return Kind.HIDDEN; 403 } 404 405 @Override @DefinedBy(Api.COMPILER_TREE) 406 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 407 return v.visitHidden(this, d); 408 } 409 410 @Override @DefinedBy(Api.COMPILER_TREE) 411 public List<? extends DocTree> getBody() { 412 return body; 413 } 414 } 415 416 public static class DCIdentifier extends DCTree implements IdentifierTree { 417 public final Name name; 418 419 DCIdentifier(Name name) { 420 this.name = name; 421 } 422 423 @Override @DefinedBy(Api.COMPILER_TREE) 424 public Kind getKind() { 425 return Kind.IDENTIFIER; 426 } 427 428 @Override @DefinedBy(Api.COMPILER_TREE) 429 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 430 return v.visitIdentifier(this, d); 431 } 432 433 @Override @DefinedBy(Api.COMPILER_TREE) 434 public Name getName() { 435 return name; 436 } 437 } 438 439 public static class DCIndex extends DCInlineTag implements IndexTree { 440 public final DCTree term; 441 public final List<DCTree> description; 442 443 DCIndex(DCTree term, List<DCTree> description) { 444 this.term = term; 445 this.description = description; 446 } 447 448 @Override @DefinedBy(Api.COMPILER_TREE) 449 public Kind getKind() { 450 return Kind.INDEX; 451 } 452 453 @Override @DefinedBy(Api.COMPILER_TREE) 454 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 455 return v.visitIndex(this, d); 456 } 457 458 @Override @DefinedBy(Api.COMPILER_TREE) 459 public DocTree getSearchTerm() { 460 return term; 461 } 462 463 @Override @DefinedBy(Api.COMPILER_TREE) 464 public java.util.List<? extends DocTree> getDescription() { 465 return description; 466 } 467 } 468 469 public static class DCInheritDoc extends DCInlineTag implements InheritDocTree { 470 @Override @DefinedBy(Api.COMPILER_TREE) 471 public Kind getKind() { 472 return Kind.INHERIT_DOC; 473 } 474 475 @Override @DefinedBy(Api.COMPILER_TREE) 476 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 477 return v.visitInheritDoc(this, d); 478 } 479 } 480 481 public static class DCLink extends DCInlineTag implements LinkTree { 482 public final Kind kind; 483 public final DCReference ref; 484 public final List<DCTree> label; 485 486 DCLink(Kind kind, DCReference ref, List<DCTree> label) { 487 Assert.check(kind == Kind.LINK || kind == Kind.LINK_PLAIN); 488 this.kind = kind; 489 this.ref = ref; 490 this.label = label; 491 } 492 493 @Override @DefinedBy(Api.COMPILER_TREE) 494 public Kind getKind() { 495 return kind; 496 } 497 498 @Override @DefinedBy(Api.COMPILER_TREE) 499 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 500 return v.visitLink(this, d); 501 } 502 503 @Override @DefinedBy(Api.COMPILER_TREE) 504 public ReferenceTree getReference() { 505 return ref; 506 } 507 508 @Override @DefinedBy(Api.COMPILER_TREE) 509 public List<? extends DocTree> getLabel() { 510 return label; 511 } 512 } 513 514 public static class DCLiteral extends DCInlineTag implements LiteralTree { 515 public final Kind kind; 516 public final DCText body; 517 518 DCLiteral(Kind kind, DCText body) { 519 Assert.check(kind == Kind.CODE || kind == Kind.LITERAL); 520 this.kind = kind; 521 this.body = body; 522 } 523 524 @Override @DefinedBy(Api.COMPILER_TREE) 525 public Kind getKind() { 526 return kind; 527 } 528 529 @Override @DefinedBy(Api.COMPILER_TREE) 530 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 531 return v.visitLiteral(this, d); 532 } 533 534 @Override @DefinedBy(Api.COMPILER_TREE) 535 public DCText getBody() { 536 return body; 537 } 538 } 539 540 public static class DCParam extends DCBlockTag implements ParamTree { 541 public final boolean isTypeParameter; 542 public final DCIdentifier name; 543 public final List<DCTree> description; 544 545 DCParam(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) { 546 this.isTypeParameter = isTypeParameter; 547 this.name = name; 548 this.description = description; 549 } 550 551 @Override @DefinedBy(Api.COMPILER_TREE) 552 public Kind getKind() { 553 return Kind.PARAM; 554 } 555 556 @Override @DefinedBy(Api.COMPILER_TREE) 557 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 558 return v.visitParam(this, d); 559 } 560 561 @Override @DefinedBy(Api.COMPILER_TREE) 562 public boolean isTypeParameter() { 563 return isTypeParameter; 564 } 565 566 @Override @DefinedBy(Api.COMPILER_TREE) 567 public IdentifierTree getName() { 568 return name; 569 } 570 571 @Override @DefinedBy(Api.COMPILER_TREE) 572 public List<? extends DocTree> getDescription() { 573 return description; 574 } 575 } 576 577 public static class DCReference extends DCEndPosTree<DCReference> implements ReferenceTree { 578 public final String signature; 579 580 // The following are not directly exposed through ReferenceTree 581 // use DocTrees.getElement(TreePath,ReferenceTree) 582 public final JCTree qualifierExpression; 583 public final Name memberName; 584 public final List<JCTree> paramTypes; 585 586 587 DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) { 588 this.signature = signature; 589 qualifierExpression = qualExpr; 590 memberName = member; 591 this.paramTypes = paramTypes; 592 } 593 594 @Override @DefinedBy(Api.COMPILER_TREE) 595 public Kind getKind() { 596 return Kind.REFERENCE; 597 } 598 599 @Override @DefinedBy(Api.COMPILER_TREE) 600 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 601 return v.visitReference(this, d); 602 } 603 604 @Override @DefinedBy(Api.COMPILER_TREE) 605 public String getSignature() { 606 return signature; 607 } 608 } 609 610 public static class DCReturn extends DCBlockTag implements ReturnTree { 611 public final List<DCTree> description; 612 613 DCReturn(List<DCTree> description) { 614 this.description = description; 615 } 616 617 @Override @DefinedBy(Api.COMPILER_TREE) 618 public Kind getKind() { 619 return Kind.RETURN; 620 } 621 622 @Override @DefinedBy(Api.COMPILER_TREE) 623 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 624 return v.visitReturn(this, d); 625 } 626 627 @Override @DefinedBy(Api.COMPILER_TREE) 628 public List<? extends DocTree> getDescription() { 629 return description; 630 } 631 } 632 633 public static class DCSee extends DCBlockTag implements SeeTree { 634 public final List<DCTree> reference; 635 636 DCSee(List<DCTree> reference) { 637 this.reference = reference; 638 } 639 640 @Override @DefinedBy(Api.COMPILER_TREE) 641 public Kind getKind() { 642 return Kind.SEE; 643 } 644 645 @Override @DefinedBy(Api.COMPILER_TREE) 646 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 647 return v.visitSee(this, d); 648 } 649 650 @Override @DefinedBy(Api.COMPILER_TREE) 651 public List<? extends DocTree> getReference() { 652 return reference; 653 } 654 } 655 656 public static class DCSerial extends DCBlockTag implements SerialTree { 657 public final List<DCTree> description; 658 659 DCSerial(List<DCTree> description) { 660 this.description = description; 661 } 662 663 @Override @DefinedBy(Api.COMPILER_TREE) 664 public Kind getKind() { 665 return Kind.SERIAL; 666 } 667 668 @Override @DefinedBy(Api.COMPILER_TREE) 669 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 670 return v.visitSerial(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 DCSerialData extends DCBlockTag implements SerialDataTree { 680 public final List<DCTree> description; 681 682 DCSerialData(List<DCTree> description) { 683 this.description = description; 684 } 685 686 @Override @DefinedBy(Api.COMPILER_TREE) 687 public Kind getKind() { 688 return Kind.SERIAL_DATA; 689 } 690 691 @Override @DefinedBy(Api.COMPILER_TREE) 692 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 693 return v.visitSerialData(this, d); 694 } 695 696 @Override @DefinedBy(Api.COMPILER_TREE) 697 public List<? extends DocTree> getDescription() { 698 return description; 699 } 700 } 701 702 public static class DCSerialField extends DCBlockTag implements SerialFieldTree { 703 public final DCIdentifier name; 704 public final DCReference type; 705 public final List<DCTree> description; 706 707 DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description) { 708 this.description = description; 709 this.name = name; 710 this.type = type; 711 } 712 713 @Override @DefinedBy(Api.COMPILER_TREE) 714 public Kind getKind() { 715 return Kind.SERIAL_FIELD; 716 } 717 718 @Override @DefinedBy(Api.COMPILER_TREE) 719 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 720 return v.visitSerialField(this, d); 721 } 722 723 @Override @DefinedBy(Api.COMPILER_TREE) 724 public List<? extends DocTree> getDescription() { 725 return description; 726 } 727 728 @Override @DefinedBy(Api.COMPILER_TREE) 729 public IdentifierTree getName() { 730 return name; 731 } 732 733 @Override @DefinedBy(Api.COMPILER_TREE) 734 public ReferenceTree getType() { 735 return type; 736 } 737 } 738 739 public static class DCSince extends DCBlockTag implements SinceTree { 740 public final List<DCTree> body; 741 742 DCSince(List<DCTree> body) { 743 this.body = body; 744 } 745 746 @Override @DefinedBy(Api.COMPILER_TREE) 747 public Kind getKind() { 748 return Kind.SINCE; 749 } 750 751 @Override @DefinedBy(Api.COMPILER_TREE) 752 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 753 return v.visitSince(this, d); 754 } 755 756 @Override @DefinedBy(Api.COMPILER_TREE) 757 public List<? extends DocTree> getBody() { 758 return body; 759 } 760 } 761 762 public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree { 763 public final Name name; 764 public final List<DCTree> attrs; 765 public final boolean selfClosing; 766 767 DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing) { 768 this.name = name; 769 this.attrs = attrs; 770 this.selfClosing = selfClosing; 771 } 772 773 @Override @DefinedBy(Api.COMPILER_TREE) 774 public Kind getKind() { 775 return Kind.START_ELEMENT; 776 } 777 778 @Override @DefinedBy(Api.COMPILER_TREE) 779 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 780 return v.visitStartElement(this, d); 781 } 782 783 @Override @DefinedBy(Api.COMPILER_TREE) 784 public Name getName() { 785 return name; 786 } 787 788 @Override @DefinedBy(Api.COMPILER_TREE) 789 public List<? extends DocTree> getAttributes() { 790 return attrs; 791 } 792 793 @Override @DefinedBy(Api.COMPILER_TREE) 794 public boolean isSelfClosing() { 795 return selfClosing; 796 } 797 } 798 799 public static class DCText extends DCTree implements TextTree { 800 public final String text; 801 802 DCText(String text) { 803 this.text = text; 804 } 805 806 @Override @DefinedBy(Api.COMPILER_TREE) 807 public Kind getKind() { 808 return Kind.TEXT; 809 } 810 811 @Override @DefinedBy(Api.COMPILER_TREE) 812 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 813 return v.visitText(this, d); 814 } 815 816 @Override @DefinedBy(Api.COMPILER_TREE) 817 public String getBody() { 818 return text; 819 } 820 } 821 822 public static class DCThrows extends DCBlockTag implements ThrowsTree { 823 public final Kind kind; 824 public final DCReference name; 825 public final List<DCTree> description; 826 827 DCThrows(Kind kind, DCReference name, List<DCTree> description) { 828 Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS); 829 this.kind = kind; 830 this.name = name; 831 this.description = description; 832 } 833 834 @Override @DefinedBy(Api.COMPILER_TREE) 835 public Kind getKind() { 836 return kind; 837 } 838 839 @Override @DefinedBy(Api.COMPILER_TREE) 840 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 841 return v.visitThrows(this, d); 842 } 843 844 @Override @DefinedBy(Api.COMPILER_TREE) 845 public ReferenceTree getExceptionName() { 846 return name; 847 } 848 849 @Override @DefinedBy(Api.COMPILER_TREE) 850 public List<? extends DocTree> getDescription() { 851 return description; 852 } 853 } 854 855 public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree { 856 public final Name name; 857 public final List<DCTree> content; 858 859 DCUnknownBlockTag(Name name, List<DCTree> content) { 860 this.name = name; 861 this.content = content; 862 } 863 864 @Override @DefinedBy(Api.COMPILER_TREE) 865 public Kind getKind() { 866 return Kind.UNKNOWN_BLOCK_TAG; 867 } 868 869 @Override @DefinedBy(Api.COMPILER_TREE) 870 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 871 return v.visitUnknownBlockTag(this, d); 872 } 873 874 @Override @DefinedBy(Api.COMPILER_TREE) 875 public String getTagName() { 876 return name.toString(); 877 } 878 879 @Override @DefinedBy(Api.COMPILER_TREE) 880 public List<? extends DocTree> getContent() { 881 return content; 882 } 883 } 884 885 public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree { 886 public final Name name; 887 public final List<DCTree> content; 888 889 DCUnknownInlineTag(Name name, List<DCTree> content) { 890 this.name = name; 891 this.content = content; 892 } 893 894 @Override @DefinedBy(Api.COMPILER_TREE) 895 public Kind getKind() { 896 return Kind.UNKNOWN_INLINE_TAG; 897 } 898 899 @Override @DefinedBy(Api.COMPILER_TREE) 900 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 901 return v.visitUnknownInlineTag(this, d); 902 } 903 904 @Override @DefinedBy(Api.COMPILER_TREE) 905 public String getTagName() { 906 return name.toString(); 907 } 908 909 @Override @DefinedBy(Api.COMPILER_TREE) 910 public List<? extends DocTree> getContent() { 911 return content; 912 } 913 } 914 915 public static class DCValue extends DCInlineTag implements ValueTree { 916 public final DCReference ref; 917 918 DCValue(DCReference ref) { 919 this.ref = ref; 920 } 921 922 @Override @DefinedBy(Api.COMPILER_TREE) 923 public Kind getKind() { 924 return Kind.VALUE; 925 } 926 927 @Override @DefinedBy(Api.COMPILER_TREE) 928 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 929 return v.visitValue(this, d); 930 } 931 932 @Override @DefinedBy(Api.COMPILER_TREE) 933 public ReferenceTree getReference() { 934 return ref; 935 } 936 } 937 938 public static class DCVersion extends DCBlockTag implements VersionTree { 939 public final List<DCTree> body; 940 941 DCVersion(List<DCTree> body) { 942 this.body = body; 943 } 944 945 @Override @DefinedBy(Api.COMPILER_TREE) 946 public Kind getKind() { 947 return Kind.VERSION; 948 } 949 950 @Override @DefinedBy(Api.COMPILER_TREE) 951 public <R, D> R accept(DocTreeVisitor<R, D> v, D d) { 952 return v.visitVersion(this, d); 953 } 954 955 @Override @DefinedBy(Api.COMPILER_TREE) 956 public List<? extends DocTree> getBody() { 957 return body; 958 } 959 } 960 961} 962