1 /*
2  * Copyright (c) 2011, 2020, 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<DCEndElement> 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.JCExpression moduleName;
651         public final JCTree qualifierExpression;
652         public final Name memberName;
653         public final List<JCTree> paramTypes;
654 
655 
DCReference(String signature, JCTree.JCExpression moduleName, JCTree qualExpr, Name member, List<JCTree> paramTypes)656         DCReference(String signature, JCTree.JCExpression moduleName, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
657             this.signature = signature;
658             this.moduleName = moduleName;
659             qualifierExpression = qualExpr;
660             memberName = member;
661             this.paramTypes = paramTypes;
662         }
663 
664         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()665         public Kind getKind() {
666             return Kind.REFERENCE;
667         }
668 
669         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)670         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
671             return v.visitReference(this, d);
672         }
673 
674         @Override @DefinedBy(Api.COMPILER_TREE)
getSignature()675         public String getSignature() {
676             return signature;
677         }
678     }
679 
680     public static class DCReturn extends DCEndPosTree<DCReturn> implements ReturnTree {
681         public final boolean inline;
682         public final List<DCTree> description;
683 
DCReturn(boolean inline, List<DCTree> description)684         DCReturn(boolean inline, List<DCTree> description) {
685             this.inline = inline;
686             this.description = description;
687         }
688 
689         @Override @DefinedBy(Api.COMPILER_TREE)
getTagName()690         public String getTagName() {
691             return "return";
692         }
693 
694         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()695         public Kind getKind() {
696             return Kind.RETURN;
697         }
698 
699         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)700         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
701             return v.visitReturn(this, d);
702         }
703 
704         @Override @DefinedBy(Api.COMPILER_TREE)
isInline()705         public boolean isInline() {
706             return inline;
707         }
708 
709         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()710         public List<? extends DocTree> getDescription() {
711             return description;
712         }
713     }
714 
715     public static class DCSee extends DCBlockTag implements SeeTree {
716         public final List<DCTree> reference;
717 
DCSee(List<DCTree> reference)718         DCSee(List<DCTree> reference) {
719             this.reference = reference;
720         }
721 
722         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()723         public Kind getKind() {
724             return Kind.SEE;
725         }
726 
727         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)728         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
729             return v.visitSee(this, d);
730         }
731 
732         @Override @DefinedBy(Api.COMPILER_TREE)
getReference()733         public List<? extends DocTree> getReference() {
734             return reference;
735         }
736     }
737 
738     public static class DCSerial extends DCBlockTag implements SerialTree {
739         public final List<DCTree> description;
740 
DCSerial(List<DCTree> description)741         DCSerial(List<DCTree> description) {
742             this.description = description;
743         }
744 
745         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()746         public Kind getKind() {
747             return Kind.SERIAL;
748         }
749 
750         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)751         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
752             return v.visitSerial(this, d);
753         }
754 
755         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()756         public List<? extends DocTree> getDescription() {
757             return description;
758         }
759     }
760 
761     public static class DCSerialData extends DCBlockTag implements SerialDataTree {
762         public final List<DCTree> description;
763 
DCSerialData(List<DCTree> description)764         DCSerialData(List<DCTree> description) {
765             this.description = description;
766         }
767 
768         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()769         public Kind getKind() {
770             return Kind.SERIAL_DATA;
771         }
772 
773         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)774         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
775             return v.visitSerialData(this, d);
776         }
777 
778         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()779         public List<? extends DocTree> getDescription() {
780             return description;
781         }
782     }
783 
784     public static class DCSerialField extends DCBlockTag implements SerialFieldTree {
785         public final DCIdentifier name;
786         public final DCReference type;
787         public final List<DCTree> description;
788 
DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description)789         DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
790             this.description = description;
791             this.name = name;
792             this.type = type;
793         }
794 
795         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()796         public Kind getKind() {
797             return Kind.SERIAL_FIELD;
798         }
799 
800         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)801         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
802             return v.visitSerialField(this, d);
803         }
804 
805         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()806         public List<? extends DocTree> getDescription() {
807             return description;
808         }
809 
810         @Override @DefinedBy(Api.COMPILER_TREE)
getName()811         public IdentifierTree getName() {
812             return name;
813         }
814 
815         @Override @DefinedBy(Api.COMPILER_TREE)
getType()816         public ReferenceTree getType() {
817             return type;
818         }
819     }
820 
821     public static class DCSince extends DCBlockTag implements SinceTree {
822         public final List<DCTree> body;
823 
DCSince(List<DCTree> body)824         DCSince(List<DCTree> body) {
825             this.body = body;
826         }
827 
828         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()829         public Kind getKind() {
830             return Kind.SINCE;
831         }
832 
833         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)834         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
835             return v.visitSince(this, d);
836         }
837 
838         @Override @DefinedBy(Api.COMPILER_TREE)
getBody()839         public List<? extends DocTree> getBody() {
840             return body;
841         }
842     }
843 
844     public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree {
845         public final Name name;
846         public final List<DCTree> attrs;
847         public final boolean selfClosing;
848 
DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing)849         DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
850             this.name = name;
851             this.attrs = attrs;
852             this.selfClosing = selfClosing;
853         }
854 
855         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()856         public Kind getKind() {
857             return Kind.START_ELEMENT;
858         }
859 
860         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)861         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
862             return v.visitStartElement(this, d);
863         }
864 
865         @Override @DefinedBy(Api.COMPILER_TREE)
getName()866         public Name getName() {
867             return name;
868         }
869 
870         @Override @DefinedBy(Api.COMPILER_TREE)
getAttributes()871         public List<? extends DocTree> getAttributes() {
872             return attrs;
873         }
874 
875         @Override @DefinedBy(Api.COMPILER_TREE)
isSelfClosing()876         public boolean isSelfClosing() {
877             return selfClosing;
878         }
879     }
880 
881     public static class DCSummary extends DCInlineTag implements SummaryTree {
882         public final List<DCTree> summary;
883 
DCSummary(List<DCTree> summary)884         DCSummary(List<DCTree> summary) {
885             this.summary = summary;
886         }
887 
888         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()889         public Kind getKind() {
890             return Kind.SUMMARY;
891         }
892 
893         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)894         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
895             return v.visitSummary(this, d);
896         }
897 
898         @Override @DefinedBy(Api.COMPILER_TREE)
getSummary()899         public List<? extends DocTree> getSummary() {
900             return summary;
901         }
902     }
903 
904     public static class DCSystemProperty extends DCInlineTag implements SystemPropertyTree {
905         public final Name propertyName;
906 
DCSystemProperty(Name propertyName)907         DCSystemProperty(Name propertyName) {
908             this.propertyName = propertyName;
909         }
910 
911         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()912         public Kind getKind() {
913             return Kind.SYSTEM_PROPERTY;
914         }
915 
916         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)917         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
918             return v.visitSystemProperty(this, d);
919         }
920 
921         @Override @DefinedBy(Api.COMPILER_TREE)
getPropertyName()922         public Name getPropertyName() {
923             return propertyName;
924         }
925     }
926 
927     public static class DCText extends DCTree implements TextTree {
928         public final String text;
929 
DCText(String text)930         DCText(String text) {
931             this.text = text;
932         }
933 
934         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()935         public Kind getKind() {
936             return Kind.TEXT;
937         }
938 
939         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)940         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
941             return v.visitText(this, d);
942         }
943 
944         @Override @DefinedBy(Api.COMPILER_TREE)
getBody()945         public String getBody() {
946             return text;
947         }
948     }
949 
950     public static class DCThrows extends DCBlockTag implements ThrowsTree {
951         public final Kind kind;
952         public final DCReference name;
953         public final List<DCTree> description;
954 
DCThrows(Kind kind, DCReference name, List<DCTree> description)955         DCThrows(Kind kind, DCReference name, List<DCTree> description) {
956             Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS);
957             this.kind = kind;
958             this.name = name;
959             this.description = description;
960         }
961 
962         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()963         public Kind getKind() {
964             return kind;
965         }
966 
967         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)968         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
969             return v.visitThrows(this, d);
970         }
971 
972         @Override @DefinedBy(Api.COMPILER_TREE)
getExceptionName()973         public ReferenceTree getExceptionName() {
974             return name;
975         }
976 
977         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()978         public List<? extends DocTree> getDescription() {
979             return description;
980         }
981     }
982 
983     public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree {
984         public final Name name;
985         public final List<DCTree> content;
986 
DCUnknownBlockTag(Name name, List<DCTree> content)987         DCUnknownBlockTag(Name name, List<DCTree> content) {
988             this.name = name;
989             this.content = content;
990         }
991 
992         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()993         public Kind getKind() {
994             return Kind.UNKNOWN_BLOCK_TAG;
995         }
996 
997         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)998         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
999             return v.visitUnknownBlockTag(this, d);
1000         }
1001 
1002         @Override @DefinedBy(Api.COMPILER_TREE)
getTagName()1003         public String getTagName() {
1004             return name.toString();
1005         }
1006 
1007         @Override @DefinedBy(Api.COMPILER_TREE)
getContent()1008         public List<? extends DocTree> getContent() {
1009             return content;
1010         }
1011     }
1012 
1013     public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree {
1014         public final Name name;
1015         public final List<DCTree> content;
1016 
DCUnknownInlineTag(Name name, List<DCTree> content)1017         DCUnknownInlineTag(Name name, List<DCTree> content) {
1018             this.name = name;
1019             this.content = content;
1020         }
1021 
1022         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1023         public Kind getKind() {
1024             return Kind.UNKNOWN_INLINE_TAG;
1025         }
1026 
1027         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1028         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1029             return v.visitUnknownInlineTag(this, d);
1030         }
1031 
1032         @Override @DefinedBy(Api.COMPILER_TREE)
getTagName()1033         public String getTagName() {
1034             return name.toString();
1035         }
1036 
1037         @Override @DefinedBy(Api.COMPILER_TREE)
getContent()1038         public List<? extends DocTree> getContent() {
1039             return content;
1040         }
1041     }
1042 
1043     public static class DCUses extends DCBlockTag implements UsesTree {
1044         public final DCReference serviceType;
1045         public final List<DCTree> description;
1046 
DCUses(DCReference serviceType, List<DCTree> description)1047         DCUses(DCReference serviceType, List<DCTree> description) {
1048             this.serviceType = serviceType;
1049             this.description = description;
1050         }
1051 
1052         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1053         public Kind getKind() {
1054             return Kind.USES;
1055         }
1056 
1057         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1058         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1059             return v.visitUses(this, d);
1060         }
1061 
1062         @Override @DefinedBy(Api.COMPILER_TREE)
getServiceType()1063         public ReferenceTree getServiceType() {
1064             return serviceType;
1065         }
1066 
1067         @Override @DefinedBy(Api.COMPILER_TREE)
getDescription()1068         public List<? extends DocTree> getDescription() {
1069             return description;
1070         }
1071     }
1072 
1073     public static class DCValue extends DCInlineTag implements ValueTree {
1074         public final DCReference ref;
1075 
DCValue(DCReference ref)1076         DCValue(DCReference ref) {
1077             this.ref = ref;
1078         }
1079 
1080         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1081         public Kind getKind() {
1082             return Kind.VALUE;
1083         }
1084 
1085         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1086         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1087             return v.visitValue(this, d);
1088         }
1089 
1090         @Override @DefinedBy(Api.COMPILER_TREE)
getReference()1091         public ReferenceTree getReference() {
1092             return ref;
1093         }
1094     }
1095 
1096     public static class DCVersion extends DCBlockTag implements VersionTree {
1097         public final List<DCTree> body;
1098 
DCVersion(List<DCTree> body)1099         DCVersion(List<DCTree> body) {
1100             this.body = body;
1101         }
1102 
1103         @Override @DefinedBy(Api.COMPILER_TREE)
getKind()1104         public Kind getKind() {
1105             return Kind.VERSION;
1106         }
1107 
1108         @Override @DefinedBy(Api.COMPILER_TREE)
accept(DocTreeVisitor<R, D> v, D d)1109         public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1110             return v.visitVersion(this, d);
1111         }
1112 
1113         @Override @DefinedBy(Api.COMPILER_TREE)
getBody()1114         public List<? extends DocTree> getBody() {
1115             return body;
1116         }
1117     }
1118 
1119 }
1120