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