src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -21,24 +21,26 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package com.sun.tools.doclets.internal.toolkit.taglets;
+package jdk.javadoc.internal.doclets.toolkit.taglets;
 
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.formats.html.markup.RawHtml;
-import com.sun.tools.doclets.internal.toolkit.Content;
+import java.util.List;
 
+import javax.lang.model.element.Element;
+
+import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+import static jdk.javadoc.doclet.taglet.Taglet.Location.*;
+
 /**
- * This taglet acts as a wrapper to enable
- * {@link com.sun.tools.doclets.Taglet} type taglets to work
- * with the current version of Javadoc.
- * Note: this taglet only works with legacy taglets (those compatible with
- * Javadoc 1.4.x) that writes strings.
- * This taglet is able to wrap most most legacy taglets because
- * the standard doclet is the only known doclet to use legacy taglets.
+ * A taglet wrapper, allows the public taglet {@link jdk.javadoc.doclet.taglet.Taglet}
+ * wrapped into an internal Taglet representation.
  *
  *  <p><b>This is NOT part of any supported API.
  *  If you write code that depends on this, you do so at your own risk.
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>

@@ -45,96 +47,103 @@
  *
  * @since 1.5
  * @author Jamie Ho
  */
 
-public class LegacyTaglet implements Taglet {
+public class UserTaglet implements Taglet {
 
-    private com.sun.tools.doclets.Taglet legacyTaglet;
+    final private jdk.javadoc.doclet.taglet.Taglet userTaglet;
 
-    public LegacyTaglet(com.sun.tools.doclets.Taglet t) {
-        legacyTaglet = t;
+    public UserTaglet(jdk.javadoc.doclet.taglet.Taglet t) {
+        userTaglet = t;
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean inField() {
-        return legacyTaglet.isInlineTag() || legacyTaglet.inField();
+        return userTaglet.isInlineTag() ||
+                userTaglet.getAllowedLocations().contains(FIELD);
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean inConstructor() {
-        return legacyTaglet.isInlineTag() || legacyTaglet.inConstructor();
+        return userTaglet.isInlineTag() ||
+                userTaglet.getAllowedLocations().contains(CONSTRUCTOR);
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean inMethod() {
-        return legacyTaglet.isInlineTag() || legacyTaglet.inMethod();
+             return userTaglet.isInlineTag() ||
+                     userTaglet.getAllowedLocations().contains(METHOD);
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean inOverview() {
-        return legacyTaglet.isInlineTag() || legacyTaglet.inOverview();
+             return userTaglet.isInlineTag() ||
+                     userTaglet.getAllowedLocations().contains(OVERVIEW);
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean inPackage() {
-        return legacyTaglet.isInlineTag() || legacyTaglet.inPackage();
+             return userTaglet.isInlineTag() ||
+                     userTaglet.getAllowedLocations().contains(PACKAGE);
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean inType() {
-        return legacyTaglet.isInlineTag() || legacyTaglet.inType();
+             return userTaglet.isInlineTag() ||
+                     userTaglet.getAllowedLocations().contains(TYPE);
     }
 
     /**
      * Return true if this <code>Taglet</code>
      * is an inline tag.
      * @return true if this <code>Taglet</code>
      * is an inline tag and false otherwise.
      */
     public boolean isInlineTag() {
-        return legacyTaglet.isInlineTag();
+        return userTaglet.isInlineTag();
     }
 
     /**
      * {@inheritDoc}
      */
     public String getName() {
-        return legacyTaglet.getName();
+        return userTaglet.getName();
     }
 
     /**
      * {@inheritDoc}
      */
-    public Content getTagletOutput(Tag tag, TagletWriter writer)
+    public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer)
             throws IllegalArgumentException {
         Content output = writer.getOutputInstance();
-        output.addContent(new RawHtml(legacyTaglet.toString(tag)));
+        output.addContent(new RawHtml(userTaglet.toString(tag)));
         return output;
     }
 
     /**
      * {@inheritDoc}
      */
-    public Content getTagletOutput(Doc holder, TagletWriter writer)
+    public Content getTagletOutput(Element holder, TagletWriter writer)
             throws IllegalArgumentException {
         Content output = writer.getOutputInstance();
-        Tag[] tags = holder.tags(getName());
-        if (tags.length > 0) {
-            String tagString = legacyTaglet.toString(tags);
+        Utils utils = writer.configuration().utils;
+        List<? extends DocTree> tags = utils.getBlockTags(holder, getName());
+        if (!tags.isEmpty()) {
+            String tagString = userTaglet.toString(tags);
             if (tagString != null) {
                 output.addContent(new RawHtml(tagString));
             }
         }
         return output;