1 /*
   2  * Copyright (c) 2011, 2017, 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 
  26 package com.sun.tools.javac.tree;
  27 
  28 import javax.tools.Diagnostic;
  29 
  30 import com.sun.source.doctree.*;
  31 import com.sun.tools.javac.parser.Tokens.Comment;
  32 import com.sun.tools.javac.util.Assert;
  33 import com.sun.tools.javac.util.DefinedBy;
  34 import com.sun.tools.javac.util.DefinedBy.Api;
  35 import com.sun.tools.javac.util.DiagnosticSource;
  36 import com.sun.tools.javac.util.JCDiagnostic;
  37 import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
  38 import com.sun.tools.javac.util.Position;
  39 
  40 import java.io.IOException;
  41 import java.io.StringWriter;
  42 import java.util.List;
  43 
  44 import javax.lang.model.element.Name;
  45 import 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  */
  53 public 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         public final List<DCTree> preamble;
 113         public final List<DCTree> postamble;
 114 
 115         public DCDocComment(Comment comment,
 116                             List<DCTree> fullBody,
 117                             List<DCTree> firstSentence,
 118                             List<DCTree> body,
 119                             List<DCTree> tags,
 120                             List<DCTree> preamble,
 121                             List<DCTree> postamble) {
 122             this.comment = comment;
 123             this.firstSentence = firstSentence;
 124             this.fullBody = fullBody;
 125             this.body = body;
 126             this.tags = tags;
 127             this.preamble = preamble;
 128             this.postamble = postamble;
 129         }
 130 
 131         @Override @DefinedBy(Api.COMPILER_TREE)
 132         public Kind getKind() {
 133             return Kind.DOC_COMMENT;
 134         }
 135 
 136         @Override @DefinedBy(Api.COMPILER_TREE)
 137         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 138             return v.visitDocComment(this, d);
 139         }
 140 
 141         @Override @DefinedBy(Api.COMPILER_TREE)
 142         public List<? extends DocTree> getFirstSentence() {
 143             return firstSentence;
 144         }
 145 
 146         @Override @DefinedBy(Api.COMPILER_TREE)
 147         public List<? extends DocTree> getFullBody() {
 148             return fullBody;
 149         }
 150 
 151         @Override @DefinedBy(Api.COMPILER_TREE)
 152         public List<? extends DocTree> getBody() {
 153             return body;
 154         }
 155 
 156         @Override @DefinedBy(Api.COMPILER_TREE)
 157         public List<? extends DocTree> getBlockTags() {
 158             return tags;
 159         }
 160 
 161         @Override @DefinedBy(Api.COMPILER_TREE)
 162         public List<? extends DocTree> getPreamble() {
 163             return preamble;
 164         }
 165 
 166         @Override @DefinedBy(Api.COMPILER_TREE)
 167         public List<? extends DocTree> getPostamble() {
 168             return postamble;
 169         }
 170     }
 171 
 172     public static abstract class DCBlockTag extends DCTree implements BlockTagTree {
 173         @Override @DefinedBy(Api.COMPILER_TREE)
 174         public String getTagName() {
 175             return getKind().tagName;
 176         }
 177     }
 178 
 179     public static abstract class DCInlineTag extends DCEndPosTree<DCInlineTag> implements InlineTagTree {
 180         @Override @DefinedBy(Api.COMPILER_TREE)
 181         public String getTagName() {
 182             return getKind().tagName;
 183         }
 184     }
 185 
 186     public static class DCAttribute extends DCTree implements AttributeTree {
 187         public final Name name;
 188         public final ValueKind vkind;
 189         public final List<DCTree> value;
 190 
 191         DCAttribute(Name name, ValueKind vkind, List<DCTree> value) {
 192             Assert.check((vkind == ValueKind.EMPTY) ? (value == null) : (value != null));
 193             this.name = name;
 194             this.vkind = vkind;
 195             this.value = value;
 196         }
 197 
 198         @Override @DefinedBy(Api.COMPILER_TREE)
 199         public Kind getKind() {
 200             return Kind.ATTRIBUTE;
 201         }
 202 
 203         @Override @DefinedBy(Api.COMPILER_TREE)
 204         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 205             return v.visitAttribute(this, d);
 206         }
 207 
 208         @Override @DefinedBy(Api.COMPILER_TREE)
 209         public Name getName() {
 210             return name;
 211         }
 212 
 213         @Override @DefinedBy(Api.COMPILER_TREE)
 214         public ValueKind getValueKind() {
 215             return vkind;
 216         }
 217 
 218         @Override @DefinedBy(Api.COMPILER_TREE)
 219         public List<DCTree> getValue() {
 220             return value;
 221         }
 222     }
 223 
 224     public static class DCAuthor extends DCBlockTag implements AuthorTree {
 225         public final List<DCTree> name;
 226 
 227         DCAuthor(List<DCTree> name) {
 228             this.name = name;
 229         }
 230 
 231         @Override @DefinedBy(Api.COMPILER_TREE)
 232         public Kind getKind() {
 233             return Kind.AUTHOR;
 234         }
 235 
 236         @Override @DefinedBy(Api.COMPILER_TREE)
 237         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 238             return v.visitAuthor(this, d);
 239         }
 240 
 241         @Override @DefinedBy(Api.COMPILER_TREE)
 242         public List<? extends DocTree> getName() {
 243             return name;
 244         }
 245     }
 246 
 247     public static class DCComment extends DCTree implements CommentTree {
 248         public final String body;
 249 
 250         DCComment(String body) {
 251             this.body = body;
 252         }
 253 
 254         @Override @DefinedBy(Api.COMPILER_TREE)
 255         public Kind getKind() {
 256             return Kind.COMMENT;
 257         }
 258 
 259         @Override @DefinedBy(Api.COMPILER_TREE)
 260         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 261             return v.visitComment(this, d);
 262         }
 263 
 264         @Override @DefinedBy(Api.COMPILER_TREE)
 265         public String getBody() {
 266             return body;
 267         }
 268     }
 269 
 270     public static class DCDeprecated extends DCBlockTag implements DeprecatedTree {
 271         public final List<DCTree> body;
 272 
 273         DCDeprecated(List<DCTree> body) {
 274             this.body = body;
 275         }
 276 
 277         @Override @DefinedBy(Api.COMPILER_TREE)
 278         public Kind getKind() {
 279             return Kind.DEPRECATED;
 280         }
 281 
 282         @Override @DefinedBy(Api.COMPILER_TREE)
 283         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 284             return v.visitDeprecated(this, d);
 285         }
 286 
 287         @Override @DefinedBy(Api.COMPILER_TREE)
 288         public List<? extends DocTree> getBody() {
 289             return body;
 290         }
 291     }
 292 
 293     public static class DCDocRoot extends DCInlineTag implements DocRootTree {
 294 
 295         @Override @DefinedBy(Api.COMPILER_TREE)
 296         public Kind getKind() {
 297             return Kind.DOC_ROOT;
 298         }
 299 
 300         @Override @DefinedBy(Api.COMPILER_TREE)
 301         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 302             return v.visitDocRoot(this, d);
 303         }
 304     }
 305 
 306     public static class DCDocType extends DCTree implements DocTypeTree {
 307         public final String text;
 308 
 309         DCDocType(String text) {
 310             this.text = text;
 311         }
 312 
 313         @Override @DefinedBy(Api.COMPILER_TREE)
 314         public Kind getKind() {
 315             return Kind.DOC_TYPE;
 316         }
 317 
 318         @Override @DefinedBy(Api.COMPILER_TREE)
 319         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 320             return v.visitDocType(this, d);
 321         }
 322 
 323         @Override @DefinedBy(Api.COMPILER_TREE)
 324         public String getText() {
 325             return text;
 326         }
 327     }
 328 
 329     public static class DCEndElement extends DCTree implements EndElementTree {
 330         public final Name name;
 331 
 332         DCEndElement(Name name) {
 333             this.name = name;
 334         }
 335 
 336         @Override @DefinedBy(Api.COMPILER_TREE)
 337         public Kind getKind() {
 338             return Kind.END_ELEMENT;
 339         }
 340 
 341         @Override @DefinedBy(Api.COMPILER_TREE)
 342         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 343             return v.visitEndElement(this, d);
 344         }
 345 
 346         @Override @DefinedBy(Api.COMPILER_TREE)
 347         public Name getName() {
 348             return name;
 349         }
 350     }
 351 
 352     public static class DCEntity extends DCTree implements EntityTree {
 353         public final Name name;
 354 
 355         DCEntity(Name name) {
 356             this.name = name;
 357         }
 358 
 359         @Override @DefinedBy(Api.COMPILER_TREE)
 360         public Kind getKind() {
 361             return Kind.ENTITY;
 362         }
 363 
 364         @Override @DefinedBy(Api.COMPILER_TREE)
 365         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 366             return v.visitEntity(this, d);
 367         }
 368 
 369         @Override @DefinedBy(Api.COMPILER_TREE)
 370         public Name getName() {
 371             return name;
 372         }
 373     }
 374 
 375     public static class DCErroneous extends DCTree implements ErroneousTree, JCDiagnostic.DiagnosticPosition {
 376         public final String body;
 377         public final JCDiagnostic diag;
 378 
 379         DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) {
 380             this.body = body;
 381             this.diag = diags.error(null, diagSource, this, code, args);
 382         }
 383 
 384         DCErroneous(String body, JCDiagnostic diag) {
 385             this.body = body;
 386             this.diag = diag;
 387         }
 388 
 389         @Override @DefinedBy(Api.COMPILER_TREE)
 390         public Kind getKind() {
 391             return Kind.ERRONEOUS;
 392         }
 393 
 394         @Override @DefinedBy(Api.COMPILER_TREE)
 395         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 396             return v.visitErroneous(this, d);
 397         }
 398 
 399         @Override @DefinedBy(Api.COMPILER_TREE)
 400         public String getBody() {
 401             return body;
 402         }
 403 
 404         @Override @DefinedBy(Api.COMPILER_TREE)
 405         public Diagnostic<JavaFileObject> getDiagnostic() {
 406             return diag;
 407         }
 408 
 409         @Override
 410         public JCTree getTree() {
 411             return null;
 412         }
 413 
 414         @Override
 415         public int getStartPosition() {
 416             return pos;
 417         }
 418 
 419         @Override
 420         public int getPreferredPosition() {
 421             return pos + body.length() - 1;
 422         }
 423 
 424         @Override
 425         public int getEndPosition(EndPosTable endPosTable) {
 426             return pos + body.length();
 427         }
 428 
 429     }
 430 
 431     public static class DCHidden extends DCBlockTag implements HiddenTree {
 432         public final List<DCTree> body;
 433 
 434         DCHidden(List<DCTree> body) {
 435             this.body = body;
 436         }
 437 
 438         @Override @DefinedBy(Api.COMPILER_TREE)
 439         public Kind getKind() {
 440             return Kind.HIDDEN;
 441         }
 442 
 443         @Override @DefinedBy(Api.COMPILER_TREE)
 444         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 445             return v.visitHidden(this, d);
 446         }
 447 
 448         @Override @DefinedBy(Api.COMPILER_TREE)
 449         public List<? extends DocTree> getBody() {
 450             return body;
 451         }
 452     }
 453 
 454     public static class DCIdentifier extends DCTree implements IdentifierTree {
 455         public final Name name;
 456 
 457         DCIdentifier(Name name) {
 458             this.name = name;
 459         }
 460 
 461         @Override @DefinedBy(Api.COMPILER_TREE)
 462         public Kind getKind() {
 463             return Kind.IDENTIFIER;
 464         }
 465 
 466         @Override @DefinedBy(Api.COMPILER_TREE)
 467         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 468             return v.visitIdentifier(this, d);
 469         }
 470 
 471         @Override @DefinedBy(Api.COMPILER_TREE)
 472         public Name getName() {
 473             return name;
 474         }
 475     }
 476 
 477     public static class DCIndex extends DCInlineTag implements IndexTree {
 478         public final DCTree term;
 479         public final List<DCTree> description;
 480 
 481         DCIndex(DCTree term, List<DCTree> description) {
 482             this.term = term;
 483             this.description = description;
 484         }
 485 
 486         @Override @DefinedBy(Api.COMPILER_TREE)
 487         public Kind getKind() {
 488             return Kind.INDEX;
 489         }
 490 
 491         @Override @DefinedBy(Api.COMPILER_TREE)
 492         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 493             return v.visitIndex(this, d);
 494         }
 495 
 496         @Override @DefinedBy(Api.COMPILER_TREE)
 497         public DocTree getSearchTerm() {
 498             return term;
 499         }
 500 
 501         @Override @DefinedBy(Api.COMPILER_TREE)
 502         public java.util.List<? extends DocTree> getDescription() {
 503             return description;
 504         }
 505     }
 506 
 507     public static class DCInheritDoc extends DCInlineTag implements InheritDocTree {
 508         @Override @DefinedBy(Api.COMPILER_TREE)
 509         public Kind getKind() {
 510             return Kind.INHERIT_DOC;
 511         }
 512 
 513         @Override @DefinedBy(Api.COMPILER_TREE)
 514         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 515             return v.visitInheritDoc(this, d);
 516         }
 517     }
 518 
 519     public static class DCLink extends DCInlineTag implements LinkTree {
 520         public final Kind kind;
 521         public final DCReference ref;
 522         public final List<DCTree> label;
 523 
 524         DCLink(Kind kind, DCReference ref, List<DCTree> label) {
 525             Assert.check(kind == Kind.LINK || kind == Kind.LINK_PLAIN);
 526             this.kind = kind;
 527             this.ref = ref;
 528             this.label = label;
 529         }
 530 
 531         @Override @DefinedBy(Api.COMPILER_TREE)
 532         public Kind getKind() {
 533             return kind;
 534         }
 535 
 536         @Override @DefinedBy(Api.COMPILER_TREE)
 537         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 538             return v.visitLink(this, d);
 539         }
 540 
 541         @Override @DefinedBy(Api.COMPILER_TREE)
 542         public ReferenceTree getReference() {
 543             return ref;
 544         }
 545 
 546         @Override @DefinedBy(Api.COMPILER_TREE)
 547         public List<? extends DocTree> getLabel() {
 548             return label;
 549         }
 550     }
 551 
 552     public static class DCLiteral extends DCInlineTag implements LiteralTree {
 553         public final Kind kind;
 554         public final DCText body;
 555 
 556         DCLiteral(Kind kind, DCText body) {
 557             Assert.check(kind == Kind.CODE || kind == Kind.LITERAL);
 558             this.kind = kind;
 559             this.body = body;
 560         }
 561 
 562         @Override @DefinedBy(Api.COMPILER_TREE)
 563         public Kind getKind() {
 564             return kind;
 565         }
 566 
 567         @Override @DefinedBy(Api.COMPILER_TREE)
 568         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 569             return v.visitLiteral(this, d);
 570         }
 571 
 572         @Override @DefinedBy(Api.COMPILER_TREE)
 573         public DCText getBody() {
 574             return body;
 575         }
 576     }
 577 
 578     public static class DCAccessor extends DCInlineTag implements AccessorTree {
 579         public final Kind kind;
 580         public final List<? extends DocTree> description;
 581 
 582         DCAccessor(Kind kind, List<? extends DocTree> description) {
 583             Assert.check(kind == Kind.GETTER || kind == Kind.SETTER);
 584             this.kind = kind;
 585             this.description = description;
 586         }
 587 
 588         @Override @DefinedBy(Api.COMPILER_TREE)
 589         public Kind getKind() {
 590             return kind;
 591         }
 592 
 593         @Override @DefinedBy(Api.COMPILER_TREE)
 594         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 595             return v.visitAccessor(this, d);
 596         }
 597 
 598         @Override @DefinedBy(Api.COMPILER_TREE)
 599         public List<? extends DocTree> getDescription() {
 600             return description;
 601         }
 602     }
 603 
 604     public static class DCParam extends DCBlockTag implements ParamTree {
 605         public final boolean isTypeParameter;
 606         public final DCIdentifier name;
 607         public final List<DCTree> description;
 608 
 609         DCParam(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) {
 610             this.isTypeParameter = isTypeParameter;
 611             this.name = name;
 612             this.description = description;
 613         }
 614 
 615         @Override @DefinedBy(Api.COMPILER_TREE)
 616         public Kind getKind() {
 617             return Kind.PARAM;
 618         }
 619 
 620         @Override @DefinedBy(Api.COMPILER_TREE)
 621         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 622             return v.visitParam(this, d);
 623         }
 624 
 625         @Override @DefinedBy(Api.COMPILER_TREE)
 626         public boolean isTypeParameter() {
 627             return isTypeParameter;
 628         }
 629 
 630         @Override @DefinedBy(Api.COMPILER_TREE)
 631         public IdentifierTree getName() {
 632             return name;
 633         }
 634 
 635         @Override @DefinedBy(Api.COMPILER_TREE)
 636         public List<? extends DocTree> getDescription() {
 637             return description;
 638         }
 639     }
 640 
 641     public static class DCProvides extends DCBlockTag implements ProvidesTree {
 642         public final DCReference serviceType;
 643         public final List<DCTree> description;
 644 
 645         DCProvides(DCReference serviceType, List<DCTree> description) {
 646             this.serviceType = serviceType;
 647             this.description = description;
 648         }
 649 
 650         @Override @DefinedBy(Api.COMPILER_TREE)
 651         public Kind getKind() {
 652             return Kind.PROVIDES;
 653         }
 654 
 655         @Override @DefinedBy(Api.COMPILER_TREE)
 656         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 657             return v.visitProvides(this, d);
 658         }
 659 
 660         @Override @DefinedBy(Api.COMPILER_TREE)
 661         public ReferenceTree getServiceType() {
 662             return serviceType;
 663         }
 664 
 665         @Override @DefinedBy(Api.COMPILER_TREE)
 666         public List<? extends DocTree> getDescription() {
 667             return description;
 668         }
 669     }
 670 
 671     public static class DCReference extends DCEndPosTree<DCReference> implements ReferenceTree {
 672         public final String signature;
 673 
 674         // The following are not directly exposed through ReferenceTree
 675         // use DocTrees.getElement(DocTreePath)
 676         public final JCTree qualifierExpression;
 677         public final Name memberName;
 678         public final List<JCTree> paramTypes;
 679 
 680 
 681         DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
 682             this.signature = signature;
 683             qualifierExpression = qualExpr;
 684             memberName = member;
 685             this.paramTypes = paramTypes;
 686         }
 687 
 688         @Override @DefinedBy(Api.COMPILER_TREE)
 689         public Kind getKind() {
 690             return Kind.REFERENCE;
 691         }
 692 
 693         @Override @DefinedBy(Api.COMPILER_TREE)
 694         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 695             return v.visitReference(this, d);
 696         }
 697 
 698         @Override @DefinedBy(Api.COMPILER_TREE)
 699         public String getSignature() {
 700             return signature;
 701         }
 702     }
 703 
 704     public static class DCReturn extends DCBlockTag implements ReturnTree {
 705         public final List<DCTree> description;
 706 
 707         DCReturn(List<DCTree> description) {
 708             this.description = description;
 709         }
 710 
 711         @Override @DefinedBy(Api.COMPILER_TREE)
 712         public Kind getKind() {
 713             return Kind.RETURN;
 714         }
 715 
 716         @Override @DefinedBy(Api.COMPILER_TREE)
 717         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 718             return v.visitReturn(this, d);
 719         }
 720 
 721         @Override @DefinedBy(Api.COMPILER_TREE)
 722         public List<? extends DocTree> getDescription() {
 723             return description;
 724         }
 725     }
 726 
 727     public static class DCSee extends DCBlockTag implements SeeTree {
 728         public final List<DCTree> reference;
 729 
 730         DCSee(List<DCTree> reference) {
 731             this.reference = reference;
 732         }
 733 
 734         @Override @DefinedBy(Api.COMPILER_TREE)
 735         public Kind getKind() {
 736             return Kind.SEE;
 737         }
 738 
 739         @Override @DefinedBy(Api.COMPILER_TREE)
 740         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 741             return v.visitSee(this, d);
 742         }
 743 
 744         @Override @DefinedBy(Api.COMPILER_TREE)
 745         public List<? extends DocTree> getReference() {
 746             return reference;
 747         }
 748     }
 749 
 750     public static class DCSerial extends DCBlockTag implements SerialTree {
 751         public final List<DCTree> description;
 752 
 753         DCSerial(List<DCTree> description) {
 754             this.description = description;
 755         }
 756 
 757         @Override @DefinedBy(Api.COMPILER_TREE)
 758         public Kind getKind() {
 759             return Kind.SERIAL;
 760         }
 761 
 762         @Override @DefinedBy(Api.COMPILER_TREE)
 763         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 764             return v.visitSerial(this, d);
 765         }
 766 
 767         @Override @DefinedBy(Api.COMPILER_TREE)
 768         public List<? extends DocTree> getDescription() {
 769             return description;
 770         }
 771     }
 772 
 773     public static class DCSerialData extends DCBlockTag implements SerialDataTree {
 774         public final List<DCTree> description;
 775 
 776         DCSerialData(List<DCTree> description) {
 777             this.description = description;
 778         }
 779 
 780         @Override @DefinedBy(Api.COMPILER_TREE)
 781         public Kind getKind() {
 782             return Kind.SERIAL_DATA;
 783         }
 784 
 785         @Override @DefinedBy(Api.COMPILER_TREE)
 786         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 787             return v.visitSerialData(this, d);
 788         }
 789 
 790         @Override @DefinedBy(Api.COMPILER_TREE)
 791         public List<? extends DocTree> getDescription() {
 792             return description;
 793         }
 794     }
 795 
 796     public static class DCSerialField extends DCBlockTag implements SerialFieldTree {
 797         public final DCIdentifier name;
 798         public final DCReference type;
 799         public final List<DCTree> description;
 800 
 801         DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
 802             this.description = description;
 803             this.name = name;
 804             this.type = type;
 805         }
 806 
 807         @Override @DefinedBy(Api.COMPILER_TREE)
 808         public Kind getKind() {
 809             return Kind.SERIAL_FIELD;
 810         }
 811 
 812         @Override @DefinedBy(Api.COMPILER_TREE)
 813         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 814             return v.visitSerialField(this, d);
 815         }
 816 
 817         @Override @DefinedBy(Api.COMPILER_TREE)
 818         public List<? extends DocTree> getDescription() {
 819             return description;
 820         }
 821 
 822         @Override @DefinedBy(Api.COMPILER_TREE)
 823         public IdentifierTree getName() {
 824             return name;
 825         }
 826 
 827         @Override @DefinedBy(Api.COMPILER_TREE)
 828         public ReferenceTree getType() {
 829             return type;
 830         }
 831     }
 832 
 833     public static class DCSince extends DCBlockTag implements SinceTree {
 834         public final List<DCTree> body;
 835 
 836         DCSince(List<DCTree> body) {
 837             this.body = body;
 838         }
 839 
 840         @Override @DefinedBy(Api.COMPILER_TREE)
 841         public Kind getKind() {
 842             return Kind.SINCE;
 843         }
 844 
 845         @Override @DefinedBy(Api.COMPILER_TREE)
 846         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 847             return v.visitSince(this, d);
 848         }
 849 
 850         @Override @DefinedBy(Api.COMPILER_TREE)
 851         public List<? extends DocTree> getBody() {
 852             return body;
 853         }
 854     }
 855 
 856     public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree {
 857         public final Name name;
 858         public final List<DCTree> attrs;
 859         public final boolean selfClosing;
 860 
 861         DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
 862             this.name = name;
 863             this.attrs = attrs;
 864             this.selfClosing = selfClosing;
 865         }
 866 
 867         @Override @DefinedBy(Api.COMPILER_TREE)
 868         public Kind getKind() {
 869             return Kind.START_ELEMENT;
 870         }
 871 
 872         @Override @DefinedBy(Api.COMPILER_TREE)
 873         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 874             return v.visitStartElement(this, d);
 875         }
 876 
 877         @Override @DefinedBy(Api.COMPILER_TREE)
 878         public Name getName() {
 879             return name;
 880         }
 881 
 882         @Override @DefinedBy(Api.COMPILER_TREE)
 883         public List<? extends DocTree> getAttributes() {
 884             return attrs;
 885         }
 886 
 887         @Override @DefinedBy(Api.COMPILER_TREE)
 888         public boolean isSelfClosing() {
 889             return selfClosing;
 890         }
 891     }
 892 
 893     public static class DCSummary extends DCInlineTag implements SummaryTree {
 894         public final List<DCTree> summary;
 895 
 896         DCSummary(List<DCTree> summary) {
 897             this.summary = summary;
 898         }
 899 
 900         @Override @DefinedBy(Api.COMPILER_TREE)
 901         public Kind getKind() {
 902             return Kind.SUMMARY;
 903         }
 904 
 905         @Override @DefinedBy(Api.COMPILER_TREE)
 906         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 907             return v.visitSummary(this, d);
 908         }
 909 
 910         @Override @DefinedBy(Api.COMPILER_TREE)
 911         public List<? extends DocTree> getSummary() {
 912             return summary;
 913         }
 914     }
 915 
 916     public static class DCSystemProperty extends DCInlineTag implements SystemPropertyTree {
 917         public final Name propertyName;
 918 
 919         DCSystemProperty(Name propertyName) {
 920             this.propertyName = propertyName;
 921         }
 922 
 923         @Override @DefinedBy(Api.COMPILER_TREE)
 924         public Kind getKind() {
 925             return Kind.SYSTEM_PROPERTY;
 926         }
 927 
 928         @Override @DefinedBy(Api.COMPILER_TREE)
 929         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 930             return v.visitSystemProperty(this, d);
 931         }
 932 
 933         @Override @DefinedBy(Api.COMPILER_TREE)
 934         public Name getPropertyName() {
 935             return propertyName;
 936         }
 937     }
 938 
 939     public static class DCText extends DCTree implements TextTree {
 940         public final String text;
 941 
 942         DCText(String text) {
 943             this.text = text;
 944         }
 945 
 946         @Override @DefinedBy(Api.COMPILER_TREE)
 947         public Kind getKind() {
 948             return Kind.TEXT;
 949         }
 950 
 951         @Override @DefinedBy(Api.COMPILER_TREE)
 952         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 953             return v.visitText(this, d);
 954         }
 955 
 956         @Override @DefinedBy(Api.COMPILER_TREE)
 957         public String getBody() {
 958             return text;
 959         }
 960     }
 961 
 962     public static class DCThrows extends DCBlockTag implements ThrowsTree {
 963         public final Kind kind;
 964         public final DCReference name;
 965         public final List<DCTree> description;
 966 
 967         DCThrows(Kind kind, DCReference name, List<DCTree> description) {
 968             Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS);
 969             this.kind = kind;
 970             this.name = name;
 971             this.description = description;
 972         }
 973 
 974         @Override @DefinedBy(Api.COMPILER_TREE)
 975         public Kind getKind() {
 976             return kind;
 977         }
 978 
 979         @Override @DefinedBy(Api.COMPILER_TREE)
 980         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
 981             return v.visitThrows(this, d);
 982         }
 983 
 984         @Override @DefinedBy(Api.COMPILER_TREE)
 985         public ReferenceTree getExceptionName() {
 986             return name;
 987         }
 988 
 989         @Override @DefinedBy(Api.COMPILER_TREE)
 990         public List<? extends DocTree> getDescription() {
 991             return description;
 992         }
 993     }
 994 
 995     public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree {
 996         public final Name name;
 997         public final List<DCTree> content;
 998 
 999         DCUnknownBlockTag(Name name, List<DCTree> content) {
1000             this.name = name;
1001             this.content = content;
1002         }
1003 
1004         @Override @DefinedBy(Api.COMPILER_TREE)
1005         public Kind getKind() {
1006             return Kind.UNKNOWN_BLOCK_TAG;
1007         }
1008 
1009         @Override @DefinedBy(Api.COMPILER_TREE)
1010         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1011             return v.visitUnknownBlockTag(this, d);
1012         }
1013 
1014         @Override @DefinedBy(Api.COMPILER_TREE)
1015         public String getTagName() {
1016             return name.toString();
1017         }
1018 
1019         @Override @DefinedBy(Api.COMPILER_TREE)
1020         public List<? extends DocTree> getContent() {
1021             return content;
1022         }
1023     }
1024 
1025     public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree {
1026         public final Name name;
1027         public final List<DCTree> content;
1028 
1029         DCUnknownInlineTag(Name name, List<DCTree> content) {
1030             this.name = name;
1031             this.content = content;
1032         }
1033 
1034         @Override @DefinedBy(Api.COMPILER_TREE)
1035         public Kind getKind() {
1036             return Kind.UNKNOWN_INLINE_TAG;
1037         }
1038 
1039         @Override @DefinedBy(Api.COMPILER_TREE)
1040         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1041             return v.visitUnknownInlineTag(this, d);
1042         }
1043 
1044         @Override @DefinedBy(Api.COMPILER_TREE)
1045         public String getTagName() {
1046             return name.toString();
1047         }
1048 
1049         @Override @DefinedBy(Api.COMPILER_TREE)
1050         public List<? extends DocTree> getContent() {
1051             return content;
1052         }
1053     }
1054 
1055     public static class DCUses extends DCBlockTag implements UsesTree {
1056         public final DCReference serviceType;
1057         public final List<DCTree> description;
1058 
1059         DCUses(DCReference serviceType, List<DCTree> description) {
1060             this.serviceType = serviceType;
1061             this.description = description;
1062         }
1063 
1064         @Override @DefinedBy(Api.COMPILER_TREE)
1065         public Kind getKind() {
1066             return Kind.USES;
1067         }
1068 
1069         @Override @DefinedBy(Api.COMPILER_TREE)
1070         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1071             return v.visitUses(this, d);
1072         }
1073 
1074         @Override @DefinedBy(Api.COMPILER_TREE)
1075         public ReferenceTree getServiceType() {
1076             return serviceType;
1077         }
1078 
1079         @Override @DefinedBy(Api.COMPILER_TREE)
1080         public List<? extends DocTree> getDescription() {
1081             return description;
1082         }
1083     }
1084 
1085     public static class DCValue extends DCInlineTag implements ValueTree {
1086         public final DCReference ref;
1087 
1088         DCValue(DCReference ref) {
1089             this.ref = ref;
1090         }
1091 
1092         @Override @DefinedBy(Api.COMPILER_TREE)
1093         public Kind getKind() {
1094             return Kind.VALUE;
1095         }
1096 
1097         @Override @DefinedBy(Api.COMPILER_TREE)
1098         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1099             return v.visitValue(this, d);
1100         }
1101 
1102         @Override @DefinedBy(Api.COMPILER_TREE)
1103         public ReferenceTree getReference() {
1104             return ref;
1105         }
1106     }
1107 
1108     public static class DCVersion extends DCBlockTag implements VersionTree {
1109         public final List<DCTree> body;
1110 
1111         DCVersion(List<DCTree> body) {
1112             this.body = body;
1113         }
1114 
1115         @Override @DefinedBy(Api.COMPILER_TREE)
1116         public Kind getKind() {
1117             return Kind.VERSION;
1118         }
1119 
1120         @Override @DefinedBy(Api.COMPILER_TREE)
1121         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1122             return v.visitVersion(this, d);
1123         }
1124 
1125         @Override @DefinedBy(Api.COMPILER_TREE)
1126         public List<? extends DocTree> getBody() {
1127             return body;
1128         }
1129     }
1130 
1131 }