1 /*
2  * Copyright (c) 2011, 2019, 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 
getSourcePosition(DCDocComment dc)66     public long getSourcePosition(DCDocComment dc) {
67         return dc.comment.getSourcePos(pos);
68     }
69 
pos(DCDocComment dc)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
toString()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 
getEndPos(DCDocComment dc)93         public int getEndPos(DCDocComment dc) {
94             return dc.comment.getSourcePos(endPos);
95         }
96 
97         @SuppressWarnings("unchecked")
setEndPos(int endPos)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 
DCDocComment(Comment comment, List<DCTree> fullBody, List<DCTree> firstSentence, List<DCTree> body, List<DCTree> tags, List<DCTree> preamble, List<DCTree> postamble)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)
getKind()132         public Kind getKind() {
133             return Kind.DOC_COMMENT;
134         }
135 
136         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getFirstSentence()142         public List<? extends DocTree> getFirstSentence() {
143             return firstSentence;
144         }
145 
146         @Override @DefinedBy(Api.COMPILER_TREE)
getFullBody()147         public List<? extends DocTree> getFullBody() {
148             return fullBody;
149         }
150 
151         @Override @DefinedBy(Api.COMPILER_TREE)
getBody()152         public List<? extends DocTree> getBody() {
153             return body;
154         }
155 
156         @Override @DefinedBy(Api.COMPILER_TREE)
getBlockTags()157         public List<? extends DocTree> getBlockTags() {
158             return tags;
159         }
160 
161         @Override @DefinedBy(Api.COMPILER_TREE)
getPreamble()162         public List<? extends DocTree> getPreamble() {
163             return preamble;
164         }
165 
166         @Override @DefinedBy(Api.COMPILER_TREE)
getPostamble()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)
getTagName()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)
getTagName()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 
DCAttribute(Name name, ValueKind vkind, List<DCTree> value)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)
getKind()199         public Kind getKind() {
200             return Kind.ATTRIBUTE;
201         }
202 
203         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getName()209         public Name getName() {
210             return name;
211         }
212 
213         @Override @DefinedBy(Api.COMPILER_TREE)
getValueKind()214         public ValueKind getValueKind() {
215             return vkind;
216         }
217 
218         @Override @DefinedBy(Api.COMPILER_TREE)
getValue()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 
DCAuthor(List<DCTree> name)227         DCAuthor(List<DCTree> name) {
228             this.name = name;
229         }
230 
231         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()232         public Kind getKind() {
233             return Kind.AUTHOR;
234         }
235 
236         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getName()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 
DCComment(String body)250         DCComment(String body) {
251             this.body = body;
252         }
253 
254         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()255         public Kind getKind() {
256             return Kind.COMMENT;
257         }
258 
259         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getBody()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 
DCDeprecated(List<DCTree> body)273         DCDeprecated(List<DCTree> body) {
274             this.body = body;
275         }
276 
277         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()278         public Kind getKind() {
279             return Kind.DEPRECATED;
280         }
281 
282         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getBody()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)
getKind()296         public Kind getKind() {
297             return Kind.DOC_ROOT;
298         }
299 
300         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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 
DCDocType(String text)309         DCDocType(String text) {
310             this.text = text;
311         }
312 
313         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()314         public Kind getKind() {
315             return Kind.DOC_TYPE;
316         }
317 
318         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getText()324         public String getText() {
325             return text;
326         }
327     }
328 
329     public static class DCEndElement extends DCEndPosTree<DCStartElement> implements EndElementTree {
330         public final Name name;
331 
DCEndElement(Name name)332         DCEndElement(Name name) {
333             this.name = name;
334         }
335 
336         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()337         public Kind getKind() {
338             return Kind.END_ELEMENT;
339         }
340 
341         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getName()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 
DCEntity(Name name)355         DCEntity(Name name) {
356             this.name = name;
357         }
358 
359         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()360         public Kind getKind() {
361             return Kind.ENTITY;
362         }
363 
364         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getName()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 
DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args)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 
DCErroneous(String body, JCDiagnostic diag)384         DCErroneous(String body, JCDiagnostic diag) {
385             this.body = body;
386             this.diag = diag;
387         }
388 
389         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()390         public Kind getKind() {
391             return Kind.ERRONEOUS;
392         }
393 
394         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getBody()400         public String getBody() {
401             return body;
402         }
403 
404         @Override @DefinedBy(Api.COMPILER_TREE)
getDiagnostic()405         public Diagnostic<JavaFileObject> getDiagnostic() {
406             return diag;
407         }
408 
409         @Override
getTree()410         public JCTree getTree() {
411             return null;
412         }
413 
414         @Override
getStartPosition()415         public int getStartPosition() {
416             return pos;
417         }
418 
419         @Override
getPreferredPosition()420         public int getPreferredPosition() {
421             return pos + body.length() - 1;
422         }
423 
424         @Override
getEndPosition(EndPosTable endPosTable)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 
DCHidden(List<DCTree> body)434         DCHidden(List<DCTree> body) {
435             this.body = body;
436         }
437 
438         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()439         public Kind getKind() {
440             return Kind.HIDDEN;
441         }
442 
443         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getBody()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 
DCIdentifier(Name name)457         DCIdentifier(Name name) {
458             this.name = name;
459         }
460 
461         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()462         public Kind getKind() {
463             return Kind.IDENTIFIER;
464         }
465 
466         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getName()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 
DCIndex(DCTree term, List<DCTree> description)481         DCIndex(DCTree term, List<DCTree> description) {
482             this.term = term;
483             this.description = description;
484         }
485 
486         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()487         public Kind getKind() {
488             return Kind.INDEX;
489         }
490 
491         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getSearchTerm()497         public DocTree getSearchTerm() {
498             return term;
499         }
500 
501         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()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)
getKind()509         public Kind getKind() {
510             return Kind.INHERIT_DOC;
511         }
512 
513         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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 
DCLink(Kind kind, DCReference ref, List<DCTree> label)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)
getKind()532         public Kind getKind() {
533             return kind;
534         }
535 
536         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getReference()542         public ReferenceTree getReference() {
543             return ref;
544         }
545 
546         @Override @DefinedBy(Api.COMPILER_TREE)
getLabel()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 
DCLiteral(Kind kind, DCText body)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)
getKind()563         public Kind getKind() {
564             return kind;
565         }
566 
567         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)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)
getBody()573         public DCText getBody() {
574             return body;
575         }
576     }
577 
578     public static class DCParam extends DCBlockTag implements ParamTree {
579         public final boolean isTypeParameter;
580         public final DCIdentifier name;
581         public final List<DCTree> description;
582 
DCParam(boolean isTypeParameter, DCIdentifier name, List<DCTree> description)583         DCParam(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) {
584             this.isTypeParameter = isTypeParameter;
585             this.name = name;
586             this.description = description;
587         }
588 
589         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()590         public Kind getKind() {
591             return Kind.PARAM;
592         }
593 
594         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)595         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
596             return v.visitParam(this, d);
597         }
598 
599         @Override @DefinedBy(Api.COMPILER_TREE)
isTypeParameter()600         public boolean isTypeParameter() {
601             return isTypeParameter;
602         }
603 
604         @Override @DefinedBy(Api.COMPILER_TREE)
getName()605         public IdentifierTree getName() {
606             return name;
607         }
608 
609         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()610         public List<? extends DocTree> getDescription() {
611             return description;
612         }
613     }
614 
615     public static class DCProvides extends DCBlockTag implements ProvidesTree {
616         public final DCReference serviceType;
617         public final List<DCTree> description;
618 
DCProvides(DCReference serviceType, List<DCTree> description)619         DCProvides(DCReference serviceType, List<DCTree> description) {
620             this.serviceType = serviceType;
621             this.description = description;
622         }
623 
624         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()625         public Kind getKind() {
626             return Kind.PROVIDES;
627         }
628 
629         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)630         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
631             return v.visitProvides(this, d);
632         }
633 
634         @Override @DefinedBy(Api.COMPILER_TREE)
getServiceType()635         public ReferenceTree getServiceType() {
636             return serviceType;
637         }
638 
639         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()640         public List<? extends DocTree> getDescription() {
641             return description;
642         }
643     }
644 
645     public static class DCReference extends DCEndPosTree<DCReference> implements ReferenceTree {
646         public final String signature;
647 
648         // The following are not directly exposed through ReferenceTree
649         // use DocTrees.getElement(DocTreePath)
650         public final JCTree qualifierExpression;
651         public final Name memberName;
652         public final List<JCTree> paramTypes;
653 
654 
DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes)655         DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
656             this.signature = signature;
657             qualifierExpression = qualExpr;
658             memberName = member;
659             this.paramTypes = paramTypes;
660         }
661 
662         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()663         public Kind getKind() {
664             return Kind.REFERENCE;
665         }
666 
667         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)668         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
669             return v.visitReference(this, d);
670         }
671 
672         @Override @DefinedBy(Api.COMPILER_TREE)
getSignature()673         public String getSignature() {
674             return signature;
675         }
676     }
677 
678     public static class DCReturn extends DCBlockTag implements ReturnTree {
679         public final List<DCTree> description;
680 
DCReturn(List<DCTree> description)681         DCReturn(List<DCTree> description) {
682             this.description = description;
683         }
684 
685         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()686         public Kind getKind() {
687             return Kind.RETURN;
688         }
689 
690         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)691         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
692             return v.visitReturn(this, d);
693         }
694 
695         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()696         public List<? extends DocTree> getDescription() {
697             return description;
698         }
699     }
700 
701     public static class DCSee extends DCBlockTag implements SeeTree {
702         public final List<DCTree> reference;
703 
DCSee(List<DCTree> reference)704         DCSee(List<DCTree> reference) {
705             this.reference = reference;
706         }
707 
708         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()709         public Kind getKind() {
710             return Kind.SEE;
711         }
712 
713         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)714         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
715             return v.visitSee(this, d);
716         }
717 
718         @Override @DefinedBy(Api.COMPILER_TREE)
getReference()719         public List<? extends DocTree> getReference() {
720             return reference;
721         }
722     }
723 
724     public static class DCSerial extends DCBlockTag implements SerialTree {
725         public final List<DCTree> description;
726 
DCSerial(List<DCTree> description)727         DCSerial(List<DCTree> description) {
728             this.description = description;
729         }
730 
731         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()732         public Kind getKind() {
733             return Kind.SERIAL;
734         }
735 
736         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)737         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
738             return v.visitSerial(this, d);
739         }
740 
741         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()742         public List<? extends DocTree> getDescription() {
743             return description;
744         }
745     }
746 
747     public static class DCSerialData extends DCBlockTag implements SerialDataTree {
748         public final List<DCTree> description;
749 
DCSerialData(List<DCTree> description)750         DCSerialData(List<DCTree> description) {
751             this.description = description;
752         }
753 
754         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()755         public Kind getKind() {
756             return Kind.SERIAL_DATA;
757         }
758 
759         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)760         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
761             return v.visitSerialData(this, d);
762         }
763 
764         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()765         public List<? extends DocTree> getDescription() {
766             return description;
767         }
768     }
769 
770     public static class DCSerialField extends DCBlockTag implements SerialFieldTree {
771         public final DCIdentifier name;
772         public final DCReference type;
773         public final List<DCTree> description;
774 
DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description)775         DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
776             this.description = description;
777             this.name = name;
778             this.type = type;
779         }
780 
781         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()782         public Kind getKind() {
783             return Kind.SERIAL_FIELD;
784         }
785 
786         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)787         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
788             return v.visitSerialField(this, d);
789         }
790 
791         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()792         public List<? extends DocTree> getDescription() {
793             return description;
794         }
795 
796         @Override @DefinedBy(Api.COMPILER_TREE)
getName()797         public IdentifierTree getName() {
798             return name;
799         }
800 
801         @Override @DefinedBy(Api.COMPILER_TREE)
getType()802         public ReferenceTree getType() {
803             return type;
804         }
805     }
806 
807     public static class DCSince extends DCBlockTag implements SinceTree {
808         public final List<DCTree> body;
809 
DCSince(List<DCTree> body)810         DCSince(List<DCTree> body) {
811             this.body = body;
812         }
813 
814         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()815         public Kind getKind() {
816             return Kind.SINCE;
817         }
818 
819         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)820         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
821             return v.visitSince(this, d);
822         }
823 
824         @Override @DefinedBy(Api.COMPILER_TREE)
getBody()825         public List<? extends DocTree> getBody() {
826             return body;
827         }
828     }
829 
830     public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree {
831         public final Name name;
832         public final List<DCTree> attrs;
833         public final boolean selfClosing;
834 
DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing)835         DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
836             this.name = name;
837             this.attrs = attrs;
838             this.selfClosing = selfClosing;
839         }
840 
841         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()842         public Kind getKind() {
843             return Kind.START_ELEMENT;
844         }
845 
846         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)847         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
848             return v.visitStartElement(this, d);
849         }
850 
851         @Override @DefinedBy(Api.COMPILER_TREE)
getName()852         public Name getName() {
853             return name;
854         }
855 
856         @Override @DefinedBy(Api.COMPILER_TREE)
getAttributes()857         public List<? extends DocTree> getAttributes() {
858             return attrs;
859         }
860 
861         @Override @DefinedBy(Api.COMPILER_TREE)
isSelfClosing()862         public boolean isSelfClosing() {
863             return selfClosing;
864         }
865     }
866 
867     public static class DCSummary extends DCInlineTag implements SummaryTree {
868         public final List<DCTree> summary;
869 
DCSummary(List<DCTree> summary)870         DCSummary(List<DCTree> summary) {
871             this.summary = summary;
872         }
873 
874         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()875         public Kind getKind() {
876             return Kind.SUMMARY;
877         }
878 
879         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)880         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
881             return v.visitSummary(this, d);
882         }
883 
884         @Override @DefinedBy(Api.COMPILER_TREE)
getSummary()885         public List<? extends DocTree> getSummary() {
886             return summary;
887         }
888     }
889 
890     public static class DCSystemProperty extends DCInlineTag implements SystemPropertyTree {
891         public final Name propertyName;
892 
DCSystemProperty(Name propertyName)893         DCSystemProperty(Name propertyName) {
894             this.propertyName = propertyName;
895         }
896 
897         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()898         public Kind getKind() {
899             return Kind.SYSTEM_PROPERTY;
900         }
901 
902         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)903         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
904             return v.visitSystemProperty(this, d);
905         }
906 
907         @Override @DefinedBy(Api.COMPILER_TREE)
getPropertyName()908         public Name getPropertyName() {
909             return propertyName;
910         }
911     }
912 
913     public static class DCText extends DCTree implements TextTree {
914         public final String text;
915 
DCText(String text)916         DCText(String text) {
917             this.text = text;
918         }
919 
920         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()921         public Kind getKind() {
922             return Kind.TEXT;
923         }
924 
925         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)926         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
927             return v.visitText(this, d);
928         }
929 
930         @Override @DefinedBy(Api.COMPILER_TREE)
getBody()931         public String getBody() {
932             return text;
933         }
934     }
935 
936     public static class DCThrows extends DCBlockTag implements ThrowsTree {
937         public final Kind kind;
938         public final DCReference name;
939         public final List<DCTree> description;
940 
DCThrows(Kind kind, DCReference name, List<DCTree> description)941         DCThrows(Kind kind, DCReference name, List<DCTree> description) {
942             Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS);
943             this.kind = kind;
944             this.name = name;
945             this.description = description;
946         }
947 
948         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()949         public Kind getKind() {
950             return kind;
951         }
952 
953         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)954         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
955             return v.visitThrows(this, d);
956         }
957 
958         @Override @DefinedBy(Api.COMPILER_TREE)
getExceptionName()959         public ReferenceTree getExceptionName() {
960             return name;
961         }
962 
963         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()964         public List<? extends DocTree> getDescription() {
965             return description;
966         }
967     }
968 
969     public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree {
970         public final Name name;
971         public final List<DCTree> content;
972 
DCUnknownBlockTag(Name name, List<DCTree> content)973         DCUnknownBlockTag(Name name, List<DCTree> content) {
974             this.name = name;
975             this.content = content;
976         }
977 
978         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()979         public Kind getKind() {
980             return Kind.UNKNOWN_BLOCK_TAG;
981         }
982 
983         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)984         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
985             return v.visitUnknownBlockTag(this, d);
986         }
987 
988         @Override @DefinedBy(Api.COMPILER_TREE)
getTagName()989         public String getTagName() {
990             return name.toString();
991         }
992 
993         @Override @DefinedBy(Api.COMPILER_TREE)
getContent()994         public List<? extends DocTree> getContent() {
995             return content;
996         }
997     }
998 
999     public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree {
1000         public final Name name;
1001         public final List<DCTree> content;
1002 
DCUnknownInlineTag(Name name, List<DCTree> content)1003         DCUnknownInlineTag(Name name, List<DCTree> content) {
1004             this.name = name;
1005             this.content = content;
1006         }
1007 
1008         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1009         public Kind getKind() {
1010             return Kind.UNKNOWN_INLINE_TAG;
1011         }
1012 
1013         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1014         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1015             return v.visitUnknownInlineTag(this, d);
1016         }
1017 
1018         @Override @DefinedBy(Api.COMPILER_TREE)
getTagName()1019         public String getTagName() {
1020             return name.toString();
1021         }
1022 
1023         @Override @DefinedBy(Api.COMPILER_TREE)
getContent()1024         public List<? extends DocTree> getContent() {
1025             return content;
1026         }
1027     }
1028 
1029     public static class DCUses extends DCBlockTag implements UsesTree {
1030         public final DCReference serviceType;
1031         public final List<DCTree> description;
1032 
DCUses(DCReference serviceType, List<DCTree> description)1033         DCUses(DCReference serviceType, List<DCTree> description) {
1034             this.serviceType = serviceType;
1035             this.description = description;
1036         }
1037 
1038         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1039         public Kind getKind() {
1040             return Kind.USES;
1041         }
1042 
1043         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1044         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1045             return v.visitUses(this, d);
1046         }
1047 
1048         @Override @DefinedBy(Api.COMPILER_TREE)
getServiceType()1049         public ReferenceTree getServiceType() {
1050             return serviceType;
1051         }
1052 
1053         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()1054         public List<? extends DocTree> getDescription() {
1055             return description;
1056         }
1057     }
1058 
1059     public static class DCValue extends DCInlineTag implements ValueTree {
1060         public final DCReference ref;
1061 
DCValue(DCReference ref)1062         DCValue(DCReference ref) {
1063             this.ref = ref;
1064         }
1065 
1066         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1067         public Kind getKind() {
1068             return Kind.VALUE;
1069         }
1070 
1071         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1072         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1073             return v.visitValue(this, d);
1074         }
1075 
1076         @Override @DefinedBy(Api.COMPILER_TREE)
getReference()1077         public ReferenceTree getReference() {
1078             return ref;
1079         }
1080     }
1081 
1082     public static class DCVersion extends DCBlockTag implements VersionTree {
1083         public final List<DCTree> body;
1084 
DCVersion(List<DCTree> body)1085         DCVersion(List<DCTree> body) {
1086             this.body = body;
1087         }
1088 
1089         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1090         public Kind getKind() {
1091             return Kind.VERSION;
1092         }
1093 
1094         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1095         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1096             return v.visitVersion(this, d);
1097         }
1098 
1099         @Override @DefinedBy(Api.COMPILER_TREE)
getBody()1100         public List<? extends DocTree> getBody() {
1101             return body;
1102         }
1103     }
1104 
1105 }
1106