--- 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);
}