langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
changeset 37009 476d8d615222
parent 36526 3b41f1c69604
child 37752 4243173b58db
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Sat Apr 09 19:49:59 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Sun Apr 10 08:41:00 2016 -0700
@@ -85,6 +85,7 @@
 import static javax.lang.model.type.TypeKind.*;
 
 import static com.sun.source.doctree.DocTree.Kind.*;
+import com.sun.source.util.SimpleDocTreeVisitor;
 import static jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.MAX_CONSTANT_VALUE_INDEX_LENGTH;
 
 
@@ -1231,8 +1232,9 @@
             superType = getObjectType();
         }
         TypeElement superClass = asTypeElement(superType);
-
-        while (superClass != null && !isPublic(superClass) && !isLinkable(superClass)) {
+        // skip "hidden" classes
+        while ((superClass != null && isHidden(superClass))
+                || (superClass != null &&  !isPublic(superClass) && !isLinkable(superClass))) {
             TypeMirror supersuperType = superClass.getSuperclass();
             TypeElement supersuperClass = asTypeElement(supersuperType);
             if (supersuperClass == null
@@ -1448,9 +1450,28 @@
     }
 
     /**
+     * Returns true if the element is included, contains @hidden tag,
+     * or if javafx flag is present and element contains @treatAsPrivate
+     * tag.
+     * @param e the queried element
+     * @return true if it exists, false otherwise
+     */
+    public boolean isHidden(Element e) {
+        // prevent needless tests on elements which are not included
+        if (!isIncluded(e)) {
+            return false;
+        }
+        if (configuration.javafx &&
+                hasBlockTag(e, DocTree.Kind.UNKNOWN_BLOCK_TAG, "treatAsPrivate")) {
+            return true;
+        }
+        return hasBlockTag(e, DocTree.Kind.HIDDEN);
+    }
+
+    /**
      * In case of JavaFX mode on, filters out classes that are private,
-     * package private or having the @treatAsPrivate annotation. Those are not
-     * documented in JavaFX mode.
+     * package private, these are not documented in JavaFX mode, also
+     * remove those classes that have @hidden or @treatAsPrivate comment tag.
      *
      * @param classlist a collection of TypeElements
      * @param javafx set to true if in JavaFX mode.
@@ -1462,16 +1483,14 @@
                 new TreeSet<>(makeGeneralPurposeComparator());
         if (!javafx) {
             for (Element te : classlist) {
-                filteredOutClasses.add((TypeElement)te);
+                if (!isHidden(te)) {
+                    filteredOutClasses.add((TypeElement)te);
+                }
             }
             return filteredOutClasses;
         }
         for (Element e : classlist) {
-            if (isPrivate(e) || isPackagePrivate(e)) {
-                continue;
-            }
-            List<? extends DocTree> aspTags = getBlockTags(e, "treatAsPrivate");
-            if (aspTags != null && !aspTags.isEmpty()) {
+            if (isPrivate(e) || isPackagePrivate(e) || isHidden(e)) {
                 continue;
             }
             filteredOutClasses.add((TypeElement)e);
@@ -2711,6 +2730,7 @@
         switch (tagName) {
             case "author":
             case "deprecated":
+            case "hidden":
             case "param":
             case "return":
             case "see":
@@ -2734,7 +2754,7 @@
         List<? extends DocTree> blockTags = getBlockTags(element, kind);
         List<DocTree> out = new ArrayList<>();
         String tname = tagName.startsWith("@") ? tagName.substring(1) : tagName;
-        CommentHelper ch = wksMap.get(element);
+        CommentHelper ch = getCommentHelper(element);
         for (DocTree dt : blockTags) {
             if (ch.getTagName(dt).equals(tname)) {
                 out.add(dt);
@@ -2743,6 +2763,25 @@
         return out;
     }
 
+    public boolean hasBlockTag(Element element, DocTree.Kind kind) {
+        return hasBlockTag(element, kind, null);
+    }
+
+    public boolean hasBlockTag(Element element, DocTree.Kind kind, final String tagName) {
+        CommentHelper ch = getCommentHelper(element);
+        String tname = tagName != null && tagName.startsWith("@")
+                ? tagName.substring(1)
+                : tagName;
+        for (DocTree dt : getBlockTags(element, kind)) {
+            if (dt.getKind() == kind) {
+                if (tname == null || ch.getTagName(dt).equals(tname)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     /**
      * Gets a TreePath for an Element. Note this method is called very
      * frequently, care must be taken to ensure this method is lithe