changeset 40511:1b3c502e0bdc

8155995: Update javadoc to include module search Reviewed-by: jjg, ksrini
author bpatel
date Fri, 19 Aug 2016 12:54:02 -0700
parents 722c82994682
children b9359154240c
files langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java langtools/test/jdk/javadoc/doclet/testModules/TestModules.java langtools/test/jdk/javadoc/doclet/testModules/module1/module-info.java langtools/test/jdk/javadoc/doclet/testModules/module2/module-info.java langtools/test/jdk/javadoc/doclet/testOrdering/TestOrdering.java
diffstat 15 files changed, 228 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Fri Aug 19 12:54:02 2016 -0700
@@ -32,6 +32,7 @@
 
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.util.SimpleElementVisitor9;
@@ -183,6 +184,15 @@
         new SimpleElementVisitor9<Void, Void>() {
 
             @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+            public Void visitModule(ModuleElement e, Void p) {
+                if (configuration.showModules) {
+                    addDescription(e, dl, si);
+                    configuration.moduleSearchIndex.add(si);
+                }
+                return null;
+            }
+
+            @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
             public Void visitPackage(PackageElement e, Void p) {
                 addDescription(e, dl, si);
                 configuration.packageSearchIndex.add(si);
@@ -207,6 +217,27 @@
     }
 
     /**
+     * Add one line summary comment for the module.
+     *
+     * @param mdle the module to be documented
+     * @param dlTree the content tree to which the description will be added
+     */
+    protected void addDescription(ModuleElement mdle, Content dlTree, SearchIndexItem si) {
+        String moduleName = utils.getSimpleName(mdle);
+        Content link = getModuleLink(mdle, new StringContent(moduleName));
+        si.setLabel(moduleName);
+        si.setCategory(resources.getText("doclet.Modules"));
+        Content dt = HtmlTree.DT(link);
+        dt.addContent(" - ");
+        dt.addContent(contents.module_);
+        dt.addContent(" " + moduleName);
+        dlTree.addContent(dt);
+        Content dd = new HtmlTree(HtmlTag.DD);
+        addSummaryComment(mdle, dd);
+        dlTree.addContent(dd);
+    }
+
+    /**
      * Add one line summary comment for the package.
      *
      * @param pkg the package to be documented
@@ -214,6 +245,9 @@
      */
     protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) {
         Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)));
+        if (configuration.showModules) {
+            si.setContainingModule(utils.getSimpleName(utils.containingModule(pkg)));
+        }
         si.setLabel(utils.getPackageName(pkg));
         si.setCategory(resources.getText("doclet.Packages"));
         Content dt = HtmlTree.DT(link);
@@ -397,6 +431,10 @@
     }
 
     protected void createSearchIndexFiles() {
+        if (configuration.showModules) {
+            createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JSON, DocPaths.MODULE_SEARCH_INDEX_ZIP,
+                    configuration.moduleSearchIndex);
+        }
         createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JSON, DocPaths.PACKAGE_SEARCH_INDEX_ZIP,
                 configuration.packageSearchIndex);
         createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JSON, DocPaths.TYPE_SEARCH_INDEX_ZIP,
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Fri Aug 19 12:54:02 2016 -0700
@@ -223,6 +223,8 @@
 
     protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
 
+    protected List<SearchIndexItem> moduleSearchIndex = new ArrayList<>();
+
     protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
 
     protected List<SearchIndexItem> tagSearchIndex = new ArrayList<>();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Fri Aug 19 12:54:02 2016 -0700
@@ -104,6 +104,7 @@
     public final Content methodSummary;
     public final Content methods;
     public final Content moduleLabel;
+    public final Content module_;
     public final Content moduleSubNavLabel;
     public final Content modulesLabel;
     public final Content navAnnotationTypeMember;
@@ -216,6 +217,7 @@
         methodSummary = getContent("doclet.Method_Summary");
         methods = getContent("doclet.Methods");
         moduleLabel = getContent("doclet.Module");
+        module_ = getContent("doclet.module");
         moduleSubNavLabel = getContent("doclet.Module_Sub_Nav");
         modulesLabel = getContent("doclet.Modules");
         navAnnotationTypeMember = getContent("doclet.navAnnotationTypeMember");
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java	Fri Aug 19 12:54:02 2016 -0700
@@ -38,6 +38,7 @@
     private String label = "";
     private String url = "";
     private String category = "";
+    private String containingModule = "";
     private String containingPackage = "";
     private String containingClass = "";
     private String holder = "";
@@ -59,6 +60,10 @@
         return url;
     }
 
+    public void setContainingModule(String m) {
+        containingModule = m;
+    }
+
     public void setContainingPackage(String p) {
         containingPackage = p;
     }
@@ -89,10 +94,17 @@
 
     public String toString() {
         StringBuilder item = new StringBuilder("");
-        if (category.equals("Packages")) {
+        if (category.equals("Modules")) {
             item.append("{")
                     .append("\"l\":\"").append(label).append("\"")
                     .append("}");
+        } else if (category.equals("Packages")) {
+            item.append("{");
+            if (!containingModule.isEmpty()) {
+                item.append("\"m\":\"").append(containingModule).append("\",");
+            }
+            item.append("\"l\":\"").append(label).append("\"")
+                    .append("}");
         } else if (category.equals("Types")) {
             item.append("{")
                     .append("\"p\":\"").append(containingPackage).append("\",")
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Fri Aug 19 12:54:02 2016 -0700
@@ -28,6 +28,7 @@
 import java.util.List;
 
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
@@ -37,7 +38,6 @@
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.IndexTree;
 import com.sun.tools.javac.util.DefinedBy;
-
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -114,6 +114,13 @@
             si.setDescription(desc);
             new SimpleElementVisitor9<Void, Void>() {
                 @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+                public Void visitModule(ModuleElement e, Void p) {
+                    si.setUrl(DocPaths.moduleSummary(e).getPath() + "#" + anchorName);
+                    si.setHolder(utils.getSimpleName(element));
+                    return null;
+                }
+
+                @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
                 public Void visitPackage(PackageElement e, Void p) {
                     si.setUrl(DocPath.forPackage(e).getPath()
                             + "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Fri Aug 19 12:54:02 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -25,6 +25,7 @@
 
 var noResult = {l: "No results found"};
 var category = "category";
+var catModules = "Modules";
 var catPackages = "Packages";
 var catTypes = "Types";
 var catMembers = "Members";
@@ -115,8 +116,12 @@
         var regexp = new RegExp($.ui.autocomplete.escapeRegex(result), "i");
         highlight = "<span class=\"resultHighlight\">$&</span>";
         var label = "";
-        if (item.category === catPackages) {
+        if (item.category === catModules) {
             label = item.l.replace(regexp, highlight);
+        } else if (item.category === catPackages) {
+            label = (item.m)
+                    ? (item.m + "/" + item.l).replace(regexp, highlight)
+                    : item.l.replace(regexp, highlight);
         } else if (item.category === catTypes) {
             label += (item.p + "." + item.l).replace(regexp, highlight);
         } else if (item.category === catMembers) {
@@ -152,24 +157,43 @@
         delay: 100,
         source: function(request, response) {
             var result = new Array();
+            var presult = new Array();
             var tresult = new Array();
             var mresult = new Array();
             var tgresult = new Array();
             var displayCount = 0;
             var exactMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term) + "$", "i");
             var secondaryMatcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
-            if (packageSearchIndex) {
-                var pCount = 0;
-                $.each(packageSearchIndex, function(index, item) {
-                    item[category] = catPackages;
+            if (moduleSearchIndex) {
+                var mdleCount = 0;
+                $.each(moduleSearchIndex, function(index, item) {
+                    item[category] = catModules;
                     if (exactMatcher.test(item.l)) {
                         result.unshift(item);
-                        pCount++;
+                        mdleCount++;
                     } else if (secondaryMatcher.test(item.l)) {
                         result.push(item);
                     }
                 });
-                displayCount = pCount;
+                displayCount = mdleCount;
+            }
+            if (packageSearchIndex) {
+                var pCount = 0;
+                var pkg = "";
+                $.each(packageSearchIndex, function(index, item) {
+                    item[category] = catPackages;
+                    pkg = (item.m)
+                            ? (item.m + "/" + item.l)
+                            : item.l;
+                    if (exactMatcher.test(item.l)) {
+                        presult.unshift(item);
+                        pCount++;
+                    } else if (secondaryMatcher.test(pkg)) {
+                        presult.push(item);
+                    }
+                });
+                result = result.concat(presult);
+                displayCount = (pCount > displayCount) ? pCount : displayCount;
             }
             if (typeSearchIndex) {
                 var tCount = 0;
@@ -215,7 +239,7 @@
             }
             displayCount = (displayCount > 500) ? displayCount : 500;
             var counter = function() {
-                var count = {Packages: 0, Types: 0, Members: 0, SearchTags: 0};
+                var count = {Modules: 0, Packages: 0, Types: 0, Members: 0, SearchTags: 0};
                 var f = function(item) {
                     count[item.category] += 1;
                     return (count[item.category] <= displayCount);
@@ -238,7 +262,9 @@
         select: function(event, ui) {
             if (ui.item.l !== noResult.l) {
                 var url = "";
-                if (ui.item.category === catPackages) {
+                if (ui.item.category === catModules) {
+                    url = "/" + ui.item.l + "-summary.html";
+                } else if (ui.item.category === catPackages) {
                     url = ui.item.l.replace(/\./g, '/') + "/package-summary.html";
                 } else if (ui.item.category === catTypes) {
                     if (ui.item.p === "<Unnamed>") {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Fri Aug 19 12:54:02 2016 -0700
@@ -62,6 +62,7 @@
 doclet.Static_method_in=Static method in {0}
 doclet.Search_tag_in=Search tag in {0}
 doclet.Method_in=Method in {0}
+doclet.module=module
 doclet.package=package
 doclet.MalformedURL=Malformed URL: {0}
 doclet.File_error=Error reading file: {0}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Fri Aug 19 12:54:02 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -23,6 +23,7 @@
  * questions.
  */
 
+var moduleSearchIndex;
 var packageSearchIndex;
 var typeSearchIndex;
 var memberSearchIndex;
@@ -36,6 +37,14 @@
     }
     createElem(doc, tag, 'search.js');
     
+    $.get(pathtoroot + "module-search-index.zip")
+            .done(function() {
+                JSZipUtils.getBinaryContent(pathtoroot + "module-search-index.zip", function(e, data) {
+                    var zip = new JSZip(data);
+                    zip.load(data);
+                    moduleSearchIndex = JSON.parse(zip.file("module-search-index.json").asText());
+                });
+            });
     $.get(pathtoroot + "package-search-index.zip")
             .done(function() {
                 JSZipUtils.getBinaryContent(pathtoroot + "package-search-index.zip", function(e, data) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Fri Aug 19 12:54:02 2016 -0700
@@ -121,6 +121,12 @@
     /** The name of the member search index zip file. */
     public static final DocPath MEMBER_SEARCH_INDEX_ZIP = DocPath.create("member-search-index.zip");
 
+    /** The name of the module search index file. */
+    public static final DocPath MODULE_SEARCH_INDEX_JSON = DocPath.create("module-search-index.json");
+
+    /** The name of the module search index zipfile. */
+    public static final DocPath MODULE_SEARCH_INDEX_ZIP = DocPath.create("module-search-index.zip");
+
     /** The name of the file for the overview frame. */
     public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java	Fri Aug 19 12:54:02 2016 -0700
@@ -28,6 +28,7 @@
 import java.util.*;
 
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
@@ -148,6 +149,9 @@
                     putMembersInIndexMap(aClass);
                 }
             }
+            if (configuration.showModules) {
+                addModulesToIndexMap();
+            }
         }
     }
 
@@ -190,6 +194,22 @@
     }
 
     /**
+     * Add all the modules to index map.
+     */
+    protected void addModulesToIndexMap() {
+        for (ModuleElement mdle : configuration.modules) {
+            String mdleName = mdle.getSimpleName().toString();
+            char ch = (mdleName.length() == 0)
+                    ? '*'
+                    : Character.toUpperCase(mdleName.charAt(0));
+            Character unicode = ch;
+            SortedSet<Element> list = indexmap.computeIfAbsent(unicode,
+                    c -> new TreeSet<>(comparator));
+            list.add(mdle);
+        }
+    }
+
+    /**
      * Should this element be added to the index map?
      */
     protected boolean shouldAddToIndexMap(Element element) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Fri Aug 19 12:54:02 2016 -0700
@@ -380,6 +380,10 @@
         return e.getKind() == METHOD;
     }
 
+    public boolean isModule(Element e) {
+        return e.getKind() == ElementKind.MODULE;
+    }
+
     public boolean isPackage(Element e) {
         return e.getKind() == ElementKind.PACKAGE;
     }
@@ -1726,9 +1730,10 @@
 
     /**
      * Returns a Comparator for index file presentations, and are sorted as follows.
-     *  If comparing packages then simply compare the qualified names, otherwise
-     *  1. sort on simple names of entities
-     *  2. if equal, then compare the ElementKind ex: Package, Interface etc.
+     *  If comparing modules then simply compare the simple names,
+     *  comparing packages then simply compare the qualified names, otherwise
+     *  1. if equal, then compare the ElementKind ex: Module, Package, Interface etc.
+     *  2. sort on simple names of entities
      *  3a. if equal and if the type is of ExecutableElement(Constructor, Methods),
      *      a case insensitive comparison of parameter the type signatures
      *  3b. if equal, case sensitive comparison of the type signatures
@@ -1739,9 +1744,10 @@
     public Comparator<Element> makeIndexUseComparator() {
         return new Utils.ElementComparator<Element>() {
             /**
-             * Compare two given elements, if comparing two packages, return the
-             * comparison of FullyQualifiedName, first sort on names, then on the
-             * kinds, then on the parameters only if the type is an ExecutableElement,
+             * Compare two given elements, if comparing two modules, return the
+             * comparison of SimpleName, if comparing two packages, return the
+             * comparison of FullyQualifiedName, first sort on kinds, then on the
+             * names, then on the parameters only if the type is an ExecutableElement,
              * the parameters are compared and finally the qualified names.
              *
              * @param e1 - an element.
@@ -1752,14 +1758,17 @@
             @Override
             public int compare(Element e1, Element e2) {
                 int result = 0;
+                if (isModule(e1) && isModule(e2)) {
+                    return compareNames(e1, e2);
+                }
                 if (isPackage(e1) && isPackage(e2)) {
                     return compareFullyQualifiedNames(e1, e2);
                 }
-                result = compareNames(e1, e2);
+                result = compareElementTypeKinds(e1, e2);
                 if (result != 0) {
                     return result;
                 }
-                result = compareElementTypeKinds(e1, e2);
+                result = compareNames(e1, e2);
                 if (result != 0) {
                     return result;
                 }
@@ -1945,15 +1954,16 @@
         final EnumMap<ElementKind, Integer> elementKindOrder;
         public ElementComparator() {
             elementKindOrder = new EnumMap<>(ElementKind.class);
-            elementKindOrder.put(ElementKind.PACKAGE, 0);
-            elementKindOrder.put(ElementKind.CLASS, 1);
-            elementKindOrder.put(ElementKind.ENUM, 2);
-            elementKindOrder.put(ElementKind.ENUM_CONSTANT, 3);
-            elementKindOrder.put(ElementKind.INTERFACE, 4);
-            elementKindOrder.put(ElementKind.ANNOTATION_TYPE, 5);
-            elementKindOrder.put(ElementKind.FIELD, 6);
-            elementKindOrder.put(ElementKind.CONSTRUCTOR, 7);
-            elementKindOrder.put(ElementKind.METHOD, 8);
+            elementKindOrder.put(ElementKind.MODULE, 0);
+            elementKindOrder.put(ElementKind.PACKAGE, 1);
+            elementKindOrder.put(ElementKind.CLASS, 2);
+            elementKindOrder.put(ElementKind.ENUM, 3);
+            elementKindOrder.put(ElementKind.ENUM_CONSTANT, 4);
+            elementKindOrder.put(ElementKind.INTERFACE, 5);
+            elementKindOrder.put(ElementKind.ANNOTATION_TYPE, 6);
+            elementKindOrder.put(ElementKind.FIELD, 7);
+            elementKindOrder.put(ElementKind.CONSTRUCTOR, 8);
+            elementKindOrder.put(ElementKind.METHOD, 9);
         }
 
         protected int compareParameters(boolean caseSensitive, List<? extends VariableElement> params1,
@@ -2378,6 +2388,11 @@
         if (snvisitor == null) {
             snvisitor = new SimpleElementVisitor9<String, Void>() {
                 @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                public String visitModule(ModuleElement e, Void p) {
+                    return e.getSimpleName().toString();
+                }
+
+                @Override @DefinedBy(Api.LANGUAGE_MODEL)
                 public String visitType(TypeElement e, Void p) {
                     StringBuilder sb = new StringBuilder(e.getSimpleName());
                     Element enclosed = e.getEnclosingElement();
@@ -2981,6 +2996,10 @@
         return out;
     }
 
+    public ModuleElement containingModule(Element e) {
+        return elementUtils.getModuleOf(e);
+    }
+
     public PackageElement containingPackage(Element e) {
         return elementUtils.getPackageOf(e);
     }
--- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Fri Aug 19 12:54:02 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291
+ * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../lib
@@ -55,6 +55,7 @@
         checkModuleClickThroughLinks();
         checkModuleClickThrough(true);
         checkModuleFilesAndLinks(true);
+        checkModulesInSearch(true);
     }
 
     /**
@@ -74,6 +75,7 @@
         checkModuleClickThroughLinks();
         checkModuleClickThrough(true);
         checkModuleFilesAndLinks(true);
+        checkModulesInSearch(true);
     }
 
     /**
@@ -120,6 +122,7 @@
         checkOverviewSummaryPackages();
         checkModuleClickThrough(false);
         checkModuleFilesAndLinks(false);
+        checkModulesInSearch(false);
     }
 
     /**
@@ -133,6 +136,7 @@
         checkExit(Exit.OK);
         checkHtml5OverviewSummaryPackages();
         checkModuleFilesAndLinks(false);
+        checkModulesInSearch(false);
     }
 
     /**
@@ -183,13 +187,15 @@
                 + "<a name=\"module.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
-                + "<div class=\"block\">This is a test description for the module1 module.</div>");
+                + "<div class=\"block\">This is a test description for the module1 module. Search "
+                + "phrase <a id=\"searchphrase\">search phrase</a>.</div>");
         checkOutput("module2-summary.html", found,
                 "<!-- ============ MODULE DESCRIPTION =========== -->\n"
                 + "<a name=\"module.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
-                + "<div class=\"block\">This is a test description for the module2 module.</div>");
+                + "<div class=\"block\">This is a test description for the module2 module. Search "
+                + "word <a id=\"search_word\">search_word</a> with no description.</div>");
     }
 
     void checkNoDescription(boolean found) {
@@ -216,16 +222,16 @@
                 + "<a id=\"module.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
-                + "<div class=\"block\">This is a test description for the module1 module.</div>\n"
-                + "</section>");
+                + "<div class=\"block\">This is a test description for the module1 module. Search "
+                + "phrase <a id=\"searchphrase\">search phrase</a>.</div>");
         checkOutput("module2-summary.html", found,
                 "<section role=\"region\">\n"
                 + "<!-- ============ MODULE DESCRIPTION =========== -->\n"
                 + "<a id=\"module.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
-                + "<div class=\"block\">This is a test description for the module2 module.</div>\n"
-                + "</section>");
+                + "<div class=\"block\">This is a test description for the module2 module. Search "
+                + "word <a id=\"search_word\">search_word</a> with no description.</div>");
     }
 
     void checkHtml5NoDescription(boolean found) {
@@ -527,4 +533,27 @@
                 "module1-summary.html",
                 "module-overview-frame.html");
     }
+
+    void checkModulesInSearch(boolean found) {
+        checkOutput("index-all.html", found,
+                "<dl>\n"
+                + "<dt><a href=\"module1-summary.html\">module1</a> - module module1</dt>\n"
+                + "<dd>\n"
+                + "<div class=\"block\">This is a test description for the module1 module.</div>\n"
+                + "</dd>\n"
+                + "<dt><a href=\"module2-summary.html\">module2</a> - module module2</dt>\n"
+                + "<dd>\n"
+                + "<div class=\"block\">This is a test description for the module2 module.</div>\n"
+                + "</dd>\n"
+                + "</dl>");
+        checkOutput("index-all.html", found,
+                "<dl>\n"
+                + "<dt><span class=\"searchTagLink\"><a href=\"module1-summary.html#searchphrase\">"
+                + "search phrase</a></span> - Search tag in module1</dt>\n"
+                + "<dd>with description</dd>\n"
+                + "<dt><span class=\"searchTagLink\"><a href=\"module2-summary.html#search_word\">"
+                + "search_word</a></span> - Search tag in module2</dt>\n"
+                + "<dd>&nbsp;</dd>\n"
+                + "</dl>");
 }
+}
--- a/langtools/test/jdk/javadoc/doclet/testModules/module1/module-info.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/test/jdk/javadoc/doclet/testModules/module1/module-info.java	Fri Aug 19 12:54:02 2016 -0700
@@ -24,7 +24,7 @@
  */
 
 /**
-  * This is a test description for the module1 module.
+  * This is a test description for the module1 module. Search phrase {@index "search phrase" with description}.
   */
 module module1 {
     requires module2;
--- a/langtools/test/jdk/javadoc/doclet/testModules/module2/module-info.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/test/jdk/javadoc/doclet/testModules/module2/module-info.java	Fri Aug 19 12:54:02 2016 -0700
@@ -24,7 +24,7 @@
  */
 
 /**
-  * This is a test description for the module2 module.
+  * This is a test description for the module2 module. Search word {@index search_word} with no description.
   */
 module module2 {
     exports testpkgmdl2;
--- a/langtools/test/jdk/javadoc/doclet/testOrdering/TestOrdering.java	Fri Aug 19 16:45:22 2016 +0100
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/TestOrdering.java	Fri Aug 19 12:54:02 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8039410 8042601 8042829 8049393 8050031 8155061
+ * @bug 8039410 8042601 8042829 8049393 8050031 8155061 8155995
  * @summary test to determine if members are ordered correctly
  * @author ksrini
  * @library ../lib/
@@ -179,10 +179,27 @@
         "something()</a></span> - Method in class a.<a href=\"a/something.html\"",
         "something()</a></span> - Method in class something.<a href=\"something/J.html\""
     };
+
     String[] composeTestVectors() {
         List<String> testList = new ArrayList<>();
 
         testList.addAll(Arrays.asList(expectedPackageOrdering));
+        for (String x : expectedEnumOrdering) {
+            testList.add(x.replace("REPLACE_ME", "&lt;Unnamed&gt;"));
+            for (int i = 0; i < MAX_PACKAGES; i++) {
+                String wpkg = "add" + i;
+                testList.add(wpkg + "/" + x.replace("REPLACE_ME",
+                        wpkg));
+                String dpkg = wpkg;
+                for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
+                    dpkg = dpkg + "/" + "add";
+                    testList.add(dpkg + "/" + x.replace("REPLACE_ME",
+                            pathToPackage(dpkg)));
+                }
+            }
+        }
+
+        testList.addAll(Arrays.asList(expectedFieldOrdering));
 
         for (String x : expectedMethodOrdering) {
             testList.add(x);
@@ -197,21 +214,6 @@
             }
         }
 
-        for (String x : expectedEnumOrdering) {
-            testList.add(x.replace("REPLACE_ME", "&lt;Unnamed&gt;"));
-            for (int i = 0; i < MAX_PACKAGES; i++) {
-                String wpkg = "add" + i;
-                testList.add(wpkg + "/" + x.replace("REPLACE_ME", wpkg));
-                String dpkg = wpkg;
-                for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
-                    dpkg = dpkg + "/" + "add";
-                    testList.add(dpkg + "/" + x.replace("REPLACE_ME", pathToPackage(dpkg)));
-                }
-            }
-        }
-
-        testList.addAll(Arrays.asList(expectedFieldOrdering));
-
         return testList.toArray(new String[testList.size()]);
     }