langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java
changeset 26266 2d24bda701dc
parent 25874 83c19f00452c
child 33360 d8ef08003d35
equal deleted inserted replaced
26265:46aacfffd3b5 26266:2d24bda701dc
    28 import java.io.Writer;
    28 import java.io.Writer;
    29 
    29 
    30 import com.sun.source.doctree.*;
    30 import com.sun.source.doctree.*;
    31 import com.sun.source.doctree.AttributeTree.ValueKind;
    31 import com.sun.source.doctree.AttributeTree.ValueKind;
    32 import com.sun.tools.javac.util.Convert;
    32 import com.sun.tools.javac.util.Convert;
       
    33 import com.sun.tools.javac.util.DefinedBy;
       
    34 import com.sun.tools.javac.util.DefinedBy.Api;
    33 import java.io.IOException;
    35 import java.io.IOException;
    34 import java.util.List;
    36 import java.util.List;
    35 
    37 
    36 /**
    38 /**
    37  * Prints out a doc comment tree.
    39  * Prints out a doc comment tree.
   126             super(e.getMessage(), e);
   128             super(e.getMessage(), e);
   127         }
   129         }
   128     }
   130     }
   129 
   131 
   130 
   132 
       
   133     @DefinedBy(Api.COMPILER_TREE)
   131     public Void visitAttribute(AttributeTree node, Void p) {
   134     public Void visitAttribute(AttributeTree node, Void p) {
   132         try {
   135         try {
   133             print(node.getName());
   136             print(node.getName());
   134             String quote;
   137             String quote;
   135             switch (node.getValueKind()) {
   138             switch (node.getValueKind()) {
   157             throw new UncheckedIOException(e);
   160             throw new UncheckedIOException(e);
   158         }
   161         }
   159         return null;
   162         return null;
   160     }
   163     }
   161 
   164 
       
   165     @DefinedBy(Api.COMPILER_TREE)
   162     public Void visitAuthor(AuthorTree node, Void p) {
   166     public Void visitAuthor(AuthorTree node, Void p) {
   163         try {
   167         try {
   164             printTagName(node);
   168             printTagName(node);
   165             print(" ");
   169             print(" ");
   166             print(node.getName());
   170             print(node.getName());
   168             throw new UncheckedIOException(e);
   172             throw new UncheckedIOException(e);
   169         }
   173         }
   170         return null;
   174         return null;
   171     }
   175     }
   172 
   176 
       
   177     @DefinedBy(Api.COMPILER_TREE)
   173     public Void visitComment(CommentTree node, Void p) {
   178     public Void visitComment(CommentTree node, Void p) {
   174         try {
   179         try {
   175             print(node.getBody());
   180             print(node.getBody());
   176         } catch (IOException e) {
   181         } catch (IOException e) {
   177             throw new UncheckedIOException(e);
   182             throw new UncheckedIOException(e);
   178         }
   183         }
   179         return null;
   184         return null;
   180     }
   185     }
   181 
   186 
       
   187     @DefinedBy(Api.COMPILER_TREE)
   182     public Void visitDeprecated(DeprecatedTree node, Void p) {
   188     public Void visitDeprecated(DeprecatedTree node, Void p) {
   183         try {
   189         try {
   184             printTagName(node);
   190             printTagName(node);
   185             if (!node.getBody().isEmpty()) {
   191             if (!node.getBody().isEmpty()) {
   186                 print(" ");
   192                 print(" ");
   190             throw new UncheckedIOException(e);
   196             throw new UncheckedIOException(e);
   191         }
   197         }
   192         return null;
   198         return null;
   193     }
   199     }
   194 
   200 
       
   201     @DefinedBy(Api.COMPILER_TREE)
   195     public Void visitDocComment(DocCommentTree node, Void p) {
   202     public Void visitDocComment(DocCommentTree node, Void p) {
   196         try {
   203         try {
   197             List<? extends DocTree> fs = node.getFirstSentence();
   204             List<? extends DocTree> fs = node.getFirstSentence();
   198             List<? extends DocTree> b = node.getBody();
   205             List<? extends DocTree> b = node.getBody();
   199             List<? extends DocTree> t = node.getBlockTags();
   206             List<? extends DocTree> t = node.getBlockTags();
   208             throw new UncheckedIOException(e);
   215             throw new UncheckedIOException(e);
   209         }
   216         }
   210         return null;
   217         return null;
   211     }
   218     }
   212 
   219 
       
   220     @DefinedBy(Api.COMPILER_TREE)
   213     public Void visitDocRoot(DocRootTree node, Void p) {
   221     public Void visitDocRoot(DocRootTree node, Void p) {
   214         try {
   222         try {
   215             print("{");
   223             print("{");
   216             printTagName(node);
   224             printTagName(node);
   217             print("}");
   225             print("}");
   219             throw new UncheckedIOException(e);
   227             throw new UncheckedIOException(e);
   220         }
   228         }
   221         return null;
   229         return null;
   222     }
   230     }
   223 
   231 
       
   232     @DefinedBy(Api.COMPILER_TREE)
   224     public Void visitEndElement(EndElementTree node, Void p) {
   233     public Void visitEndElement(EndElementTree node, Void p) {
   225         try {
   234         try {
   226             print("</");
   235             print("</");
   227             print(node.getName());
   236             print(node.getName());
   228             print(">");
   237             print(">");
   230             throw new UncheckedIOException(e);
   239             throw new UncheckedIOException(e);
   231         }
   240         }
   232         return null;
   241         return null;
   233     }
   242     }
   234 
   243 
       
   244     @DefinedBy(Api.COMPILER_TREE)
   235     public Void visitEntity(EntityTree node, Void p) {
   245     public Void visitEntity(EntityTree node, Void p) {
   236         try {
   246         try {
   237             print("&");
   247             print("&");
   238             print(node.getName());
   248             print(node.getName());
   239             print(";");
   249             print(";");
   241             throw new UncheckedIOException(e);
   251             throw new UncheckedIOException(e);
   242         }
   252         }
   243         return null;
   253         return null;
   244     }
   254     }
   245 
   255 
       
   256     @DefinedBy(Api.COMPILER_TREE)
   246     public Void visitErroneous(ErroneousTree node, Void p) {
   257     public Void visitErroneous(ErroneousTree node, Void p) {
   247         try {
   258         try {
   248             print(node.getBody());
   259             print(node.getBody());
   249         } catch (IOException e) {
   260         } catch (IOException e) {
   250             throw new UncheckedIOException(e);
   261             throw new UncheckedIOException(e);
   251         }
   262         }
   252         return null;
   263         return null;
   253     }
   264     }
   254 
   265 
       
   266     @DefinedBy(Api.COMPILER_TREE)
   255     public Void visitIdentifier(IdentifierTree node, Void p) {
   267     public Void visitIdentifier(IdentifierTree node, Void p) {
   256         try {
   268         try {
   257             print(node.getName());
   269             print(node.getName());
   258         } catch (IOException e) {
   270         } catch (IOException e) {
   259             throw new UncheckedIOException(e);
   271             throw new UncheckedIOException(e);
   260         }
   272         }
   261         return null;
   273         return null;
   262     }
   274     }
   263 
   275 
       
   276     @DefinedBy(Api.COMPILER_TREE)
   264     public Void visitInheritDoc(InheritDocTree node, Void p) {
   277     public Void visitInheritDoc(InheritDocTree node, Void p) {
   265         try {
   278         try {
   266             print("{");
   279             print("{");
   267             printTagName(node);
   280             printTagName(node);
   268             print("}");
   281             print("}");
   270             throw new UncheckedIOException(e);
   283             throw new UncheckedIOException(e);
   271         }
   284         }
   272         return null;
   285         return null;
   273     }
   286     }
   274 
   287 
       
   288     @DefinedBy(Api.COMPILER_TREE)
   275     public Void visitLink(LinkTree node, Void p) {
   289     public Void visitLink(LinkTree node, Void p) {
   276         try {
   290         try {
   277             print("{");
   291             print("{");
   278             printTagName(node);
   292             printTagName(node);
   279             print(" ");
   293             print(" ");
   287             throw new UncheckedIOException(e);
   301             throw new UncheckedIOException(e);
   288         }
   302         }
   289         return null;
   303         return null;
   290     }
   304     }
   291 
   305 
       
   306     @DefinedBy(Api.COMPILER_TREE)
   292     public Void visitLiteral(LiteralTree node, Void p) {
   307     public Void visitLiteral(LiteralTree node, Void p) {
   293         try {
   308         try {
   294             print("{");
   309             print("{");
   295             printTagName(node);
   310             printTagName(node);
   296             print(" ");
   311             print(" ");
   300             throw new UncheckedIOException(e);
   315             throw new UncheckedIOException(e);
   301         }
   316         }
   302         return null;
   317         return null;
   303     }
   318     }
   304 
   319 
       
   320     @DefinedBy(Api.COMPILER_TREE)
   305     public Void visitParam(ParamTree node, Void p) {
   321     public Void visitParam(ParamTree node, Void p) {
   306         try {
   322         try {
   307             printTagName(node);
   323             printTagName(node);
   308             print(" ");
   324             print(" ");
   309             if (node.isTypeParameter()) print("<");
   325             if (node.isTypeParameter()) print("<");
   317             throw new UncheckedIOException(e);
   333             throw new UncheckedIOException(e);
   318         }
   334         }
   319         return null;
   335         return null;
   320     }
   336     }
   321 
   337 
       
   338     @DefinedBy(Api.COMPILER_TREE)
   322     public Void visitReference(ReferenceTree node, Void p) {
   339     public Void visitReference(ReferenceTree node, Void p) {
   323         try {
   340         try {
   324             print(node.getSignature());
   341             print(node.getSignature());
   325         } catch (IOException e) {
   342         } catch (IOException e) {
   326             throw new UncheckedIOException(e);
   343             throw new UncheckedIOException(e);
   327         }
   344         }
   328         return null;
   345         return null;
   329     }
   346     }
   330 
   347 
       
   348     @DefinedBy(Api.COMPILER_TREE)
   331     public Void visitReturn(ReturnTree node, Void p) {
   349     public Void visitReturn(ReturnTree node, Void p) {
   332         try {
   350         try {
   333             printTagName(node);
   351             printTagName(node);
   334             print(" ");
   352             print(" ");
   335             print(node.getDescription());
   353             print(node.getDescription());
   337             throw new UncheckedIOException(e);
   355             throw new UncheckedIOException(e);
   338         }
   356         }
   339         return null;
   357         return null;
   340     }
   358     }
   341 
   359 
       
   360     @DefinedBy(Api.COMPILER_TREE)
   342     public Void visitSee(SeeTree node, Void p) {
   361     public Void visitSee(SeeTree node, Void p) {
   343         try {
   362         try {
   344             printTagName(node);
   363             printTagName(node);
   345             boolean first = true;
   364             boolean first = true;
   346             boolean needSep = true;
   365             boolean needSep = true;
   354             throw new UncheckedIOException(e);
   373             throw new UncheckedIOException(e);
   355         }
   374         }
   356         return null;
   375         return null;
   357     }
   376     }
   358 
   377 
       
   378     @DefinedBy(Api.COMPILER_TREE)
   359     public Void visitSerial(SerialTree node, Void p) {
   379     public Void visitSerial(SerialTree node, Void p) {
   360         try {
   380         try {
   361             printTagName(node);
   381             printTagName(node);
   362             if (!node.getDescription().isEmpty()) {
   382             if (!node.getDescription().isEmpty()) {
   363                 print(" ");
   383                 print(" ");
   367             throw new UncheckedIOException(e);
   387             throw new UncheckedIOException(e);
   368         }
   388         }
   369         return null;
   389         return null;
   370     }
   390     }
   371 
   391 
       
   392     @DefinedBy(Api.COMPILER_TREE)
   372     public Void visitSerialData(SerialDataTree node, Void p) {
   393     public Void visitSerialData(SerialDataTree node, Void p) {
   373         try {
   394         try {
   374             printTagName(node);
   395             printTagName(node);
   375             if (!node.getDescription().isEmpty()) {
   396             if (!node.getDescription().isEmpty()) {
   376                 print(" ");
   397                 print(" ");
   380             throw new UncheckedIOException(e);
   401             throw new UncheckedIOException(e);
   381         }
   402         }
   382         return null;
   403         return null;
   383     }
   404     }
   384 
   405 
       
   406     @DefinedBy(Api.COMPILER_TREE)
   385     public Void visitSerialField(SerialFieldTree node, Void p) {
   407     public Void visitSerialField(SerialFieldTree node, Void p) {
   386         try {
   408         try {
   387             printTagName(node);
   409             printTagName(node);
   388             print(" ");
   410             print(" ");
   389             print(node.getName());
   411             print(node.getName());
   397             throw new UncheckedIOException(e);
   419             throw new UncheckedIOException(e);
   398         }
   420         }
   399         return null;
   421         return null;
   400     }
   422     }
   401 
   423 
       
   424     @DefinedBy(Api.COMPILER_TREE)
   402     public Void visitSince(SinceTree node, Void p) {
   425     public Void visitSince(SinceTree node, Void p) {
   403         try {
   426         try {
   404             printTagName(node);
   427             printTagName(node);
   405             print(" ");
   428             print(" ");
   406             print(node.getBody());
   429             print(node.getBody());
   408             throw new UncheckedIOException(e);
   431             throw new UncheckedIOException(e);
   409         }
   432         }
   410         return null;
   433         return null;
   411     }
   434     }
   412 
   435 
       
   436     @DefinedBy(Api.COMPILER_TREE)
   413     public Void visitStartElement(StartElementTree node, Void p) {
   437     public Void visitStartElement(StartElementTree node, Void p) {
   414         try {
   438         try {
   415             print("<");
   439             print("<");
   416             print(node.getName());
   440             print(node.getName());
   417             List<? extends DocTree> attrs = node.getAttributes();
   441             List<? extends DocTree> attrs = node.getAttributes();
   430             throw new UncheckedIOException(e);
   454             throw new UncheckedIOException(e);
   431         }
   455         }
   432         return null;
   456         return null;
   433     }
   457     }
   434 
   458 
       
   459     @DefinedBy(Api.COMPILER_TREE)
   435     public Void visitText(TextTree node, Void p) {
   460     public Void visitText(TextTree node, Void p) {
   436         try {
   461         try {
   437             print(node.getBody());
   462             print(node.getBody());
   438         } catch (IOException e) {
   463         } catch (IOException e) {
   439             throw new UncheckedIOException(e);
   464             throw new UncheckedIOException(e);
   440         }
   465         }
   441         return null;
   466         return null;
   442     }
   467     }
   443 
   468 
       
   469     @DefinedBy(Api.COMPILER_TREE)
   444     public Void visitThrows(ThrowsTree node, Void p) {
   470     public Void visitThrows(ThrowsTree node, Void p) {
   445         try {
   471         try {
   446             printTagName(node);
   472             printTagName(node);
   447             print(" ");
   473             print(" ");
   448             print(node.getExceptionName());
   474             print(node.getExceptionName());
   454             throw new UncheckedIOException(e);
   480             throw new UncheckedIOException(e);
   455         }
   481         }
   456         return null;
   482         return null;
   457     }
   483     }
   458 
   484 
       
   485     @DefinedBy(Api.COMPILER_TREE)
   459     public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
   486     public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
   460         try {
   487         try {
   461             print("@");
   488             print("@");
   462             print(node.getTagName());
   489             print(node.getTagName());
   463             print(" ");
   490             print(" ");
   466             throw new UncheckedIOException(e);
   493             throw new UncheckedIOException(e);
   467         }
   494         }
   468         return null;
   495         return null;
   469     }
   496     }
   470 
   497 
       
   498     @DefinedBy(Api.COMPILER_TREE)
   471     public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) {
   499     public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) {
   472         try {
   500         try {
   473             print("{");
   501             print("{");
   474             print("@");
   502             print("@");
   475             print(node.getTagName());
   503             print(node.getTagName());
   480             throw new UncheckedIOException(e);
   508             throw new UncheckedIOException(e);
   481         }
   509         }
   482         return null;
   510         return null;
   483     }
   511     }
   484 
   512 
       
   513     @DefinedBy(Api.COMPILER_TREE)
   485     public Void visitValue(ValueTree node, Void p) {
   514     public Void visitValue(ValueTree node, Void p) {
   486         try {
   515         try {
   487             print("{");
   516             print("{");
   488             printTagName(node);
   517             printTagName(node);
   489             if (node.getReference() != null) {
   518             if (node.getReference() != null) {
   495             throw new UncheckedIOException(e);
   524             throw new UncheckedIOException(e);
   496         }
   525         }
   497         return null;
   526         return null;
   498     }
   527     }
   499 
   528 
       
   529     @DefinedBy(Api.COMPILER_TREE)
   500     public Void visitVersion(VersionTree node, Void p) {
   530     public Void visitVersion(VersionTree node, Void p) {
   501         try {
   531         try {
   502             printTagName(node);
   532             printTagName(node);
   503             print(" ");
   533             print(" ");
   504             print(node.getBody());
   534             print(node.getBody());
   506             throw new UncheckedIOException(e);
   536             throw new UncheckedIOException(e);
   507         }
   537         }
   508         return null;
   538         return null;
   509     }
   539     }
   510 
   540 
       
   541     @DefinedBy(Api.COMPILER_TREE)
   511     public Void visitOther(DocTree node, Void p) {
   542     public Void visitOther(DocTree node, Void p) {
   512         try {
   543         try {
   513             print("(UNKNOWN: " + node + ")");
   544             print("(UNKNOWN: " + node + ")");
   514             println();
   545             println();
   515         } catch (IOException e) {
   546         } catch (IOException e) {