src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
changeset 51862 c319db69099c
parent 51861 f7d40158eb2f
child 52487 5d1d07b72f15
equal deleted inserted replaced
51861:f7d40158eb2f 51862:c319db69099c
   353     }
   353     }
   354 
   354 
   355     /**
   355     /**
   356      * Returns a TagletWriter that knows how to write HTML.
   356      * Returns a TagletWriter that knows how to write HTML.
   357      *
   357      *
       
   358      * @param isFirstSentence  true if we want to write the first sentence
   358      * @return a TagletWriter that knows how to write HTML.
   359      * @return a TagletWriter that knows how to write HTML.
   359      */
   360      */
   360     public TagletWriter getTagletWriterInstance(boolean isFirstSentence) {
   361     public TagletWriter getTagletWriterInstance(boolean isFirstSentence) {
   361         return new TagletWriterImpl(this, isFirstSentence);
   362         return new TagletWriterImpl(this, isFirstSentence);
       
   363     }
       
   364 
       
   365     /**
       
   366      * Returns a TagletWriter that knows how to write HTML.
       
   367      *
       
   368      * @param isFirstSentence  true if we want to write the first sentence
       
   369      * @param inSummary  true if tags are to be added in a summary section
       
   370      * @return a TagletWriter
       
   371      */
       
   372     public TagletWriter getTagletWriterInstance(boolean isFirstSentence, boolean inSummary) {
       
   373         return new TagletWriterImpl(this, isFirstSentence, inSummary);
   362     }
   374     }
   363 
   375 
   364     /**
   376     /**
   365      * Get Package link, with target frame.
   377      * Get Package link, with target frame.
   366      *
   378      *
  1125      * @param htmltree the content tree to which the comment will be added
  1137      * @param htmltree the content tree to which the comment will be added
  1126      */
  1138      */
  1127     public void addInlineComment(Element element, DocTree tag, Content htmltree) {
  1139     public void addInlineComment(Element element, DocTree tag, Content htmltree) {
  1128         CommentHelper ch = utils.getCommentHelper(element);
  1140         CommentHelper ch = utils.getCommentHelper(element);
  1129         List<? extends DocTree> description = ch.getDescription(configuration, tag);
  1141         List<? extends DocTree> description = ch.getDescription(configuration, tag);
  1130         addCommentTags(element, tag, description, false, false, htmltree);
  1142         addCommentTags(element, tag, description, false, false, false, htmltree);
  1131     }
  1143     }
  1132 
  1144 
  1133     /**
  1145     /**
  1134      * Get the deprecated phrase as content.
  1146      * Get the deprecated phrase as content.
  1135      *
  1147      *
  1149      * @param tag the inline tag to be added
  1161      * @param tag the inline tag to be added
  1150      * @param htmltree the content tree to which the comment will be added
  1162      * @param htmltree the content tree to which the comment will be added
  1151      */
  1163      */
  1152     public void addInlineDeprecatedComment(Element e, DocTree tag, Content htmltree) {
  1164     public void addInlineDeprecatedComment(Element e, DocTree tag, Content htmltree) {
  1153         CommentHelper ch = utils.getCommentHelper(e);
  1165         CommentHelper ch = utils.getCommentHelper(e);
  1154         addCommentTags(e, ch.getBody(configuration, tag), true, false, htmltree);
  1166         addCommentTags(e, ch.getBody(configuration, tag), true, false, false, htmltree);
  1155     }
  1167     }
  1156 
  1168 
  1157     /**
  1169     /**
  1158      * Adds the summary content.
  1170      * Adds the summary content.
  1159      *
  1171      *
  1170      * @param element the Element for which the summary will be generated
  1182      * @param element the Element for which the summary will be generated
  1171      * @param firstSentenceTags the first sentence tags for the doc
  1183      * @param firstSentenceTags the first sentence tags for the doc
  1172      * @param htmltree the documentation tree to which the summary will be added
  1184      * @param htmltree the documentation tree to which the summary will be added
  1173      */
  1185      */
  1174     public void addSummaryComment(Element element, List<? extends DocTree> firstSentenceTags, Content htmltree) {
  1186     public void addSummaryComment(Element element, List<? extends DocTree> firstSentenceTags, Content htmltree) {
  1175         addCommentTags(element, firstSentenceTags, false, true, htmltree);
  1187         addCommentTags(element, firstSentenceTags, false, true, true, htmltree);
  1176     }
  1188     }
  1177 
  1189 
  1178     public void addSummaryDeprecatedComment(Element element, DocTree tag, Content htmltree) {
  1190     public void addSummaryDeprecatedComment(Element element, DocTree tag, Content htmltree) {
  1179         CommentHelper ch = utils.getCommentHelper(element);
  1191         CommentHelper ch = utils.getCommentHelper(element);
  1180         List<? extends DocTree> body = ch.getBody(configuration, tag);
  1192         List<? extends DocTree> body = ch.getBody(configuration, tag);
  1181         addCommentTags(element, ch.getFirstSentenceTrees(configuration, body), true, true, htmltree);
  1193         addCommentTags(element, ch.getFirstSentenceTrees(configuration, body), true, true, true, htmltree);
  1182     }
  1194     }
  1183 
  1195 
  1184     /**
  1196     /**
  1185      * Adds the inline comment.
  1197      * Adds the inline comment.
  1186      *
  1198      *
  1187      * @param element the Element for which the inline comments will be generated
  1199      * @param element the Element for which the inline comments will be generated
  1188      * @param htmltree the documentation tree to which the inline comments will be added
  1200      * @param htmltree the documentation tree to which the inline comments will be added
  1189      */
  1201      */
  1190     public void addInlineComment(Element element, Content htmltree) {
  1202     public void addInlineComment(Element element, Content htmltree) {
  1191         addCommentTags(element, utils.getFullBody(element), false, false, htmltree);
  1203         addCommentTags(element, utils.getFullBody(element), false, false, false, htmltree);
  1192     }
  1204     }
  1193 
  1205 
  1194     /**
  1206     /**
  1195      * Adds the comment tags.
  1207      * Adds the comment tags.
  1196      *
  1208      *
  1197      * @param element the Element for which the comment tags will be generated
  1209      * @param element the Element for which the comment tags will be generated
  1198      * @param tags the first sentence tags for the doc
  1210      * @param tags the first sentence tags for the doc
  1199      * @param depr true if it is deprecated
  1211      * @param depr true if it is deprecated
  1200      * @param first true if the first sentence tags should be added
  1212      * @param first true if the first sentence tags should be added
       
  1213      * @param inSummary true if the comment tags are added into the summary section
  1201      * @param htmltree the documentation tree to which the comment tags will be added
  1214      * @param htmltree the documentation tree to which the comment tags will be added
  1202      */
  1215      */
  1203     private void addCommentTags(Element element, List<? extends DocTree> tags, boolean depr,
  1216     private void addCommentTags(Element element, List<? extends DocTree> tags, boolean depr,
  1204             boolean first, Content htmltree) {
  1217             boolean first, boolean inSummary, Content htmltree) {
  1205         addCommentTags(element, null, tags, depr, first, htmltree);
  1218         addCommentTags(element, null, tags, depr, first, inSummary, htmltree);
  1206     }
  1219     }
  1207 
  1220 
  1208     /**
  1221     /**
  1209      * Adds the comment tags.
  1222      * Adds the comment tags.
  1210      *
  1223      *
  1211      * @param element for which the comment tags will be generated
  1224      * @param element for which the comment tags will be generated
  1212      * @param holderTag the block tag context for the inline tags
  1225      * @param holderTag the block tag context for the inline tags
  1213      * @param tags the first sentence tags for the doc
  1226      * @param tags the first sentence tags for the doc
  1214      * @param depr true if it is deprecated
  1227      * @param depr true if it is deprecated
  1215      * @param first true if the first sentence tags should be added
  1228      * @param first true if the first sentence tags should be added
       
  1229      * @param inSummary true if the comment tags are added into the summary section
  1216      * @param htmltree the documentation tree to which the comment tags will be added
  1230      * @param htmltree the documentation tree to which the comment tags will be added
  1217      */
  1231      */
  1218     private void addCommentTags(Element element, DocTree holderTag, List<? extends DocTree> tags, boolean depr,
  1232     private void addCommentTags(Element element, DocTree holderTag, List<? extends DocTree> tags, boolean depr,
  1219             boolean first, Content htmltree) {
  1233             boolean first, boolean inSummary, Content htmltree) {
  1220         if(configuration.nocomment){
  1234         if(configuration.nocomment){
  1221             return;
  1235             return;
  1222         }
  1236         }
  1223         Content div;
  1237         Content div;
  1224         Content result = commentTagsToContent(null, element, tags, first);
  1238         Content result = commentTagsToContent(null, element, tags, first, inSummary);
  1225         if (depr) {
  1239         if (depr) {
  1226             div = HtmlTree.DIV(HtmlStyle.deprecationComment, result);
  1240             div = HtmlTree.DIV(HtmlStyle.deprecationComment, result);
  1227             htmltree.addContent(div);
  1241             htmltree.addContent(div);
  1228         }
  1242         }
  1229         else {
  1243         else {
  1265 
  1279 
  1266     // Notify the next DocTree handler to take necessary action
  1280     // Notify the next DocTree handler to take necessary action
  1267     private boolean commentRemoved = false;
  1281     private boolean commentRemoved = false;
  1268 
  1282 
  1269     /**
  1283     /**
  1270      * Converts inline tags and text to text strings, expanding the
  1284      * Converts inline tags and text to Content, expanding the
  1271      * inline tags along the way.  Called wherever text can contain
  1285      * inline tags along the way.  Called wherever text can contain
  1272      * an inline tag, such as in comments or in free-form text arguments
  1286      * an inline tag, such as in comments or in free-form text arguments
  1273      * to non-inline tags.
  1287      * to block tags.
  1274      *
  1288      *
  1275      * @param holderTag    specific tag where comment resides
  1289      * @param holderTag    specific tag where comment resides
  1276      * @param element    specific element where comment resides
  1290      * @param element    specific element where comment resides
  1277      * @param tags   array of text tags and inline tags (often alternating)
  1291      * @param tags   array of text tags and inline tags (often alternating)
  1278                present in the text of interest for this element
  1292                present in the text of interest for this element
  1279      * @param isFirstSentence  true if text is first sentence
  1293      * @param isFirstSentence  true if text is first sentence
  1280      * @return a Content object
  1294      * @return a Content object
  1281      */
  1295      */
  1282     public Content commentTagsToContent(DocTree holderTag, Element element,
  1296     public Content commentTagsToContent(DocTree holderTag, Element element,
  1283             List<? extends DocTree> tags, boolean isFirstSentence) {
  1297             List<? extends DocTree> tags, boolean isFirstSentence) {
       
  1298         return commentTagsToContent(holderTag, element, tags, isFirstSentence, false);
       
  1299     }
       
  1300 
       
  1301     /**
       
  1302      * Converts inline tags and text to text strings, expanding the
       
  1303      * inline tags along the way.  Called wherever text can contain
       
  1304      * an inline tag, such as in comments or in free-form text arguments
       
  1305      * to block tags.
       
  1306      *
       
  1307      * @param holderTag    specific tag where comment resides
       
  1308      * @param element    specific element where comment resides
       
  1309      * @param tags   array of text tags and inline tags (often alternating)
       
  1310     present in the text of interest for this element
       
  1311      * @param isFirstSentence  true if text is first sentence
       
  1312      * @param inSummary   if the comment tags are added into the summary section
       
  1313      * @return a Content object
       
  1314      */
       
  1315     public Content commentTagsToContent(DocTree holderTag, Element element,
       
  1316             List<? extends DocTree> tags, boolean isFirstSentence, boolean inSummary) {
  1284 
  1317 
  1285         final Content result = new ContentBuilder() {
  1318         final Content result = new ContentBuilder() {
  1286             @Override
  1319             @Override
  1287             public void addContent(CharSequence text) {
  1320             public void addContent(CharSequence text) {
  1288                 super.addContent(utils.normalizeNewlines(text));
  1321                 super.addContent(utils.normalizeNewlines(text));
  1443 
  1476 
  1444                 @Override
  1477                 @Override
  1445                 public Boolean visitIndex(IndexTree node, Content p) {
  1478                 public Boolean visitIndex(IndexTree node, Content p) {
  1446                     Content output = TagletWriter.getInlineTagOutput(element,
  1479                     Content output = TagletWriter.getInlineTagOutput(element,
  1447                             configuration.tagletManager, holderTag, tag,
  1480                             configuration.tagletManager, holderTag, tag,
  1448                             getTagletWriterInstance(isFirstSentence));
  1481                             getTagletWriterInstance(isFirstSentence, inSummary));
  1449                     if (output != null) {
  1482                     if (output != null) {
  1450                         result.addContent(output);
  1483                         result.addContent(output);
  1451                     }
  1484                     }
  1452                     return false;
  1485                     return false;
  1453                 }
  1486                 }