langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
changeset 33920 bd731341c405
parent 25874 83c19f00452c
child 38617 d93a7f64e231
equal deleted inserted replaced
33919:e9fccc09cfc6 33920:bd731341c405
    72     /**
    72     /**
    73      * {@inheritDoc}
    73      * {@inheritDoc}
    74      */
    74      */
    75     protected Content codeTagOutput(Tag tag) {
    75     protected Content codeTagOutput(Tag tag) {
    76         Content result = HtmlTree.CODE(new StringContent(utils.normalizeNewlines(tag.text())));
    76         Content result = HtmlTree.CODE(new StringContent(utils.normalizeNewlines(tag.text())));
       
    77         return result;
       
    78     }
       
    79 
       
    80     protected Content indexTagOutput(Tag tag) {
       
    81         String text = tag.text();
       
    82         String tagText = "";
       
    83         String desc = "";
       
    84         if (text.isEmpty() || text.trim().isEmpty()) {
       
    85             configuration.message.warning(tag.position(), "doclet.invalid_usage_of_tag", tag.name());
       
    86         } else {
       
    87             int len = text.length();
       
    88             int tagTextEnd = 0;
       
    89             int descstart = 0;
       
    90             int start = 0;
       
    91             Character term = ' ';
       
    92             int cp = text.codePointAt(0);
       
    93             if (cp == '"') {
       
    94                 term = '"';
       
    95                 start++;
       
    96             }
       
    97             for (int i = start; i < len; i += Character.charCount(cp)) {
       
    98                 cp = text.codePointAt(i);
       
    99                 if (cp == term) {
       
   100                     tagTextEnd = i;
       
   101                     break;
       
   102                 }
       
   103             }
       
   104             if (tagTextEnd < len - 1 && tagTextEnd != 0) {
       
   105                 descstart = tagTextEnd + 1;
       
   106             }
       
   107             String desctext = "";
       
   108             if (descstart > 0) {
       
   109                 tagText = text.substring(start, tagTextEnd).trim();
       
   110                 desctext = text.substring(descstart, len).trim();
       
   111                 // strip off the white space which can be between tag description and the
       
   112                 // actual label.
       
   113                 for (int i = 0; i < desctext.length(); i++) {
       
   114                     char ch2 = desctext.charAt(i);
       
   115                     if (!(ch2 == ' ' || ch2 == '\t' || ch2 == '\n')) {
       
   116                         desc = desctext.substring(i);
       
   117                         break;
       
   118                     }
       
   119                 }
       
   120             } else {
       
   121                 if (term == '"') {
       
   122                     if (tagTextEnd == 0) {
       
   123                         // If unclosed quote, print out a warning and ignore the invalid tag text.
       
   124                         configuration.message.warning(tag.position(), "doclet.invalid_usage_of_tag", tag.name());
       
   125                         tagText = "";
       
   126                     } else {
       
   127                         tagText = text.substring(start, tagTextEnd).trim();
       
   128                     }
       
   129                 } else {
       
   130                     tagText = text.trim();
       
   131                 }
       
   132                 desc = "";
       
   133             }
       
   134         }
       
   135         String anchorName = htmlWriter.getName(tagText);
       
   136         Content result = HtmlTree.A_ID(anchorName, new StringContent(tagText));
       
   137         if (configuration.createindex && !tagText.isEmpty()) {
       
   138             SearchIndexItem si = new SearchIndexItem();
       
   139             si.setLabel(tagText);
       
   140             si.setDescription(desc);
       
   141             if (tag.holder() instanceof ProgramElementDoc) {
       
   142                 if (tag.holder() instanceof MemberDoc) {
       
   143                     si.setUrl(DocPath.forClass(((MemberDoc) tag.holder()).containingClass()).getPath()
       
   144                             + "#" + anchorName);
       
   145                     si.setHolder(((MemberDoc) tag.holder()).qualifiedName());
       
   146                 } else {
       
   147                     si.setUrl(DocPath.forClass((ClassDoc) tag.holder()).getPath() + "#" + anchorName);
       
   148                     si.setHolder(((ClassDoc) tag.holder()).qualifiedName());
       
   149                 }
       
   150             } else if (tag.holder() instanceof PackageDoc) {
       
   151                 si.setUrl(DocPath.forPackage((PackageDoc) tag.holder()).getPath()
       
   152                         + "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName);
       
   153                 si.setHolder(((PackageDoc) tag.holder()).name());
       
   154             }
       
   155             si.setCategory(configuration.getResource("doclet.SearchTags").toString());
       
   156             configuration.tagSearchIndex.add(si);
       
   157         }
    77         return result;
   158         return result;
    78     }
   159     }
    79 
   160 
    80     /**
   161     /**
    81      * {@inheritDoc}
   162      * {@inheritDoc}