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