Skip to content

Commit

Permalink
8313253: Rename methods in javadoc Comparators class
Browse files Browse the repository at this point in the history
Reviewed-by: hannesw, prappo
  • Loading branch information
jonathan-gibbons committed Jul 28, 2023
1 parent e897041 commit 4ae75ca
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected void addExtendsImplements(TypeElement parent,
TypeElement typeElement,
Content content)
{
SortedSet<TypeElement> interfaces = new TreeSet<>(comparators.makeGeneralPurposeComparator());
SortedSet<TypeElement> interfaces = new TreeSet<>(comparators.generalPurposeComparator());
typeElement.getInterfaces().forEach(t -> interfaces.add(utils.asTypeElement(t)));
if (interfaces.size() > (utils.isPlainInterface(typeElement) ? 1 : 0)) {
boolean isFirst = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public ClassUseWriter(HtmlConfiguration configuration,
super(configuration, filename);
this.typeElement = typeElement;
if (mapper.classToPackageAnnotations.containsKey(typeElement)) {
pkgToPackageAnnotations = new TreeSet<>(comparators.makeClassUseComparator());
pkgToPackageAnnotations = new TreeSet<>(comparators.classUseComparator());
pkgToPackageAnnotations.addAll(mapper.classToPackageAnnotations.get(typeElement));
}
configuration.currentTypeElement = typeElement;
this.pkgSet = new TreeSet<>(comparators.makePackageComparator());
this.pkgSet = new TreeSet<>(comparators.packageComparator());
this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam);
this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations);
this.pkgToMethodTypeParameter = pkgDivide(mapper.classToMethodTypeParam);
Expand Down Expand Up @@ -170,7 +170,7 @@ private Map<PackageElement, List<Element>> pkgDivide(Map<TypeElement, ? extends
Map<PackageElement, List<Element>> map = new HashMap<>();
List<? extends Element> elements = classMap.get(typeElement);
if (elements != null) {
elements.sort(comparators.makeClassUseComparator());
elements.sort(comparators.classUseComparator());
for (Element e : elements) {
PackageElement pkg = utils.containingPackage(e);
pkgSet.add(pkg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public ClassWriter(HtmlConfiguration configuration, TypeElement typeElement,
this.classTree = classTree;

visibleMemberTable = configuration.getVisibleMemberTable(typeElement);
summariesComparator = utils.comparators.makeIndexElementComparator();
summariesComparator = utils.comparators.indexElementComparator();
pHelper = new PropertyUtils.PropertyHelper(configuration, typeElement);

switch (typeElement.getKind()) {
Expand Down Expand Up @@ -963,7 +963,7 @@ protected void addInterfaceUsageInfo(Content target) {
}

protected void addImplementedInterfacesInfo(Content target) {
SortedSet<TypeMirror> interfaces = new TreeSet<>(comparators.makeTypeMirrorClassUseComparator());
SortedSet<TypeMirror> interfaces = new TreeSet<>(comparators.typeMirrorClassUseComparator());
interfaces.addAll(utils.getAllInterfaces(typeElement));
if (utils.isClass(typeElement) && !interfaces.isEmpty()) {
var dl = HtmlTree.DL(HtmlStyle.notes);
Expand All @@ -975,7 +975,7 @@ protected void addImplementedInterfacesInfo(Content target) {

protected void addSuperInterfacesInfo(Content target) {
SortedSet<TypeMirror> interfaces =
new TreeSet<>(comparators.makeTypeMirrorIndexUseComparator());
new TreeSet<>(comparators.typeMirrorIndexUseComparator());
interfaces.addAll(utils.getAllInterfaces(typeElement));

if (utils.isPlainInterface(typeElement) && !interfaces.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ protected SortedSet<VariableElement> members() {
members.addAll(vmt.getVisibleMembers(VisibleMemberTable.Kind.FIELDS));
members.addAll(vmt.getVisibleMembers(VisibleMemberTable.Kind.ENUM_CONSTANTS));
SortedSet<VariableElement> includes =
new TreeSet<>(utils.comparators.makeGeneralPurposeComparator());
new TreeSet<>(utils.comparators.generalPurposeComparator());
for (Element element : members) {
VariableElement member = (VariableElement)element;
if (member.getConstantValue() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ protected static void addImplementsInfo(HtmlDocletWriter writer,
var enclosing = (TypeElement) method.getEnclosingElement();
VisibleMemberTable vmt = writer.configuration.getVisibleMemberTable(enclosing);
SortedSet<ExecutableElement> implementedMethods =
new TreeSet<>(utils.comparators.makeOverrideUseComparator());
new TreeSet<>(utils.comparators.overrideUseComparator());
implementedMethods.addAll(methods);
for (ExecutableElement implementedMeth : implementedMethods) {
TypeMirror intfac = vmt.getImplementedMethodHolder(method, implementedMeth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public class ModuleWriter extends HtmlDocletWriter {
* Map of module elements and modifiers required by this module.
*/
private final Map<ModuleElement, Content> requires
= new TreeMap<>(comparators.makeModuleComparator());
= new TreeMap<>(comparators.moduleComparator());

/**
* Map of indirect modules and modifiers, transitive closure, required by this module.
*/
private final Map<ModuleElement, Content> indirectModules
= new TreeMap<>(comparators.makeModuleComparator());
= new TreeMap<>(comparators.moduleComparator());

/**
* Details about a package in a module.
Expand Down Expand Up @@ -111,44 +111,44 @@ static class PackageEntry {
/**
* Map of packages of this module, and details of whether they are exported or opened.
*/
private final Map<PackageElement, PackageEntry> packages = new TreeMap<>(utils.comparators.makePackageComparator());
private final Map<PackageElement, PackageEntry> packages = new TreeMap<>(utils.comparators.packageComparator());

/**
* Map of indirect modules (transitive closure) and their exported packages.
*/
private final Map<ModuleElement, SortedSet<PackageElement>> indirectPackages
= new TreeMap<>(comparators.makeModuleComparator());
= new TreeMap<>(comparators.moduleComparator());

/**
* Map of indirect modules (transitive closure) and their open packages.
*/
private final Map<ModuleElement, SortedSet<PackageElement>> indirectOpenPackages
= new TreeMap<>(comparators.makeModuleComparator());
= new TreeMap<>(comparators.moduleComparator());

/**
* Set of services used by the module.
*/
private final SortedSet<TypeElement> uses
= new TreeSet<>(comparators.makeAllClassesComparator());
= new TreeSet<>(comparators.allClassesComparator());

/**
* Map of services used by the module and specified using @uses javadoc tag, and description.
*/
private final Map<TypeElement, Content> usesTrees
= new TreeMap<>(comparators.makeAllClassesComparator());
= new TreeMap<>(comparators.allClassesComparator());

/**
* Map of services provided by this module, and set of its implementations.
*/
private final Map<TypeElement, SortedSet<TypeElement>> provides
= new TreeMap<>(comparators.makeAllClassesComparator());
= new TreeMap<>(comparators.allClassesComparator());

/**
* Map of services provided by the module and specified using @provides javadoc tag, and
* description.
*/
private final Map<TypeElement, Content> providesTrees
= new TreeMap<>(comparators.makeAllClassesComparator());
= new TreeMap<>(comparators.allClassesComparator());

private final BodyContents bodyContents = new BodyContents();

Expand Down Expand Up @@ -348,7 +348,7 @@ public void computeModulesData() {
// Include package if in details mode, or exported to all (i.e. targetModules == null)
if (moduleMode == ModuleMode.ALL || targetMdles == null) {
PackageEntry packageEntry = packages.computeIfAbsent(p, pkg -> new PackageEntry());
SortedSet<ModuleElement> mdleList = new TreeSet<>(utils.comparators.makeModuleComparator());
SortedSet<ModuleElement> mdleList = new TreeSet<>(utils.comparators.moduleComparator());
if (targetMdles != null) {
mdleList.addAll(targetMdles);
}
Expand All @@ -366,7 +366,7 @@ public void computeModulesData() {
// Include package if in details mode, or opened to all (i.e. targetModules == null)
if (moduleMode == ModuleMode.ALL || targetMdles == null) {
PackageEntry packageEntry = packages.computeIfAbsent(p, pkg -> new PackageEntry());
SortedSet<ModuleElement> mdleList = new TreeSet<>(utils.comparators.makeModuleComparator());
SortedSet<ModuleElement> mdleList = new TreeSet<>(utils.comparators.moduleComparator());
if (targetMdles != null) {
mdleList.addAll(targetMdles);
}
Expand All @@ -378,7 +378,7 @@ public void computeModulesData() {
// Get all the exported and opened packages, for the transitive closure of the module, to be displayed in
// the indirect packages tables.
dependentModules.forEach((module, mod) -> {
SortedSet<PackageElement> exportedPackages = new TreeSet<>(utils.comparators.makePackageComparator());
SortedSet<PackageElement> exportedPackages = new TreeSet<>(utils.comparators.packageComparator());
ElementFilter.exportsIn(module.getDirectives()).forEach(directive -> {
PackageElement pkg = directive.getPackage();
if (shouldDocument(pkg)) {
Expand All @@ -393,7 +393,7 @@ public void computeModulesData() {
if (!exportedPackages.isEmpty()) {
indirectPackages.put(module, exportedPackages);
}
SortedSet<PackageElement> openPackages = new TreeSet<>(utils.comparators.makePackageComparator());
SortedSet<PackageElement> openPackages = new TreeSet<>(utils.comparators.packageComparator());
if (module.isOpen()) {
openPackages.addAll(utils.getModulePackageMap().getOrDefault(module, Set.of()));
} else {
Expand Down Expand Up @@ -425,7 +425,7 @@ public void computeModulesData() {
TypeElement u = directive.getService();
if (shouldDocument(u)) {
List<? extends TypeElement> implList = directive.getImplementations();
SortedSet<TypeElement> implSet = new TreeSet<>(utils.comparators.makeAllClassesComparator());
SortedSet<TypeElement> implSet = new TreeSet<>(utils.comparators.allClassesComparator());
implSet.addAll(implList);
provides.put(u, implSet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public PackageUseWriter(HtmlConfiguration configuration,
Set<TypeElement> usedClasses = usingPackageToUsedClasses
.get(utils.getPackageName(usingPackage));
if (usedClasses == null) {
usedClasses = new TreeSet<>(comparators.makeGeneralPurposeComparator());
usedClasses = new TreeSet<>(comparators.generalPurposeComparator());
usingPackageToUsedClasses.put(utils.getPackageName(usingPackage),
usedClasses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public SerializedFormWriter(HtmlConfiguration configuration) {
* @throws DocletException if there is a problem while building the documentation
*/
void build() throws DocletException {
SortedSet<TypeElement> rootclasses = new TreeSet<>(utils.comparators.makeGeneralPurposeComparator());
SortedSet<TypeElement> rootclasses = new TreeSet<>(utils.comparators.generalPurposeComparator());
rootclasses.addAll(configuration.getIncludedTypeElements());
if (!serialClassFoundToDocument(rootclasses)) {
//Nothing to document.
Expand Down Expand Up @@ -443,7 +443,7 @@ protected void buildSerialFieldTagsInfo(Content target) {
// ObjectStreamFields. Print a member for each serialField tag.
// (There should be one serialField tag per ObjectStreamField
// element.)
SortedSet<SerialFieldTree> tags = new TreeSet<>(utils.comparators.makeSerialFieldTreeComparator());
SortedSet<SerialFieldTree> tags = new TreeSet<>(utils.comparators.serialFieldTreeComparator());
// sort the elements
tags.addAll(utils.getSerialFieldTrees(field));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ protected abstract void generateClassFiles(SortedSet<TypeElement> arr, ClassTree
protected void generateClassFiles(ClassTree classTree)
throws DocletException {

SortedSet<TypeElement> classes = new TreeSet<>(utils.comparators.makeGeneralPurposeComparator());
SortedSet<TypeElement> classes = new TreeSet<>(utils.comparators.generalPurposeComparator());

// handle classes specified as files on the command line
for (PackageElement pkg : configuration.typeElementCatalog.packages()) {
classes.addAll(configuration.typeElementCatalog.allClasses(pkg));
}

// handle classes specified in modules and packages on the command line
SortedSet<PackageElement> packages = new TreeSet<>(utils.comparators.makePackageComparator());
SortedSet<PackageElement> packages = new TreeSet<>(utils.comparators.packageComparator());
packages.addAll(configuration.getSpecifiedPackageElements());
configuration.modulePackages.values().stream().forEach(packages::addAll);
for (PackageElement pkg : packages) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ public Set<TypeElement> getIncludedTypeElements() {
private void initModules() {
Comparators comparators = utils.comparators;
// Build the modules structure used by the doclet
modules = new TreeSet<>(comparators.makeModuleComparator());
modules = new TreeSet<>(comparators.moduleComparator());
modules.addAll(getSpecifiedModuleElements());

modulePackages = new TreeMap<>(comparators.makeModuleComparator());
modulePackages = new TreeMap<>(comparators.moduleComparator());
for (PackageElement p : packages) {
ModuleElement mdle = docEnv.getElementUtils().getModuleOf(p);
if (mdle != null && !mdle.isUnnamed()) {
Set<PackageElement> s = modulePackages
.computeIfAbsent(mdle, m -> new TreeSet<>(comparators.makePackageComparator()));
.computeIfAbsent(mdle, m -> new TreeSet<>(comparators.packageComparator()));
s.add(p);
}
}
Expand All @@ -303,7 +303,7 @@ private void initModules() {
ModuleElement mdle = docEnv.getElementUtils().getModuleOf(p);
if (mdle != null && !mdle.isUnnamed()) {
Set<PackageElement> s = modulePackages
.computeIfAbsent(mdle, m -> new TreeSet<>(comparators.makePackageComparator()));
.computeIfAbsent(mdle, m -> new TreeSet<>(comparators.packageComparator()));
s.add(p);
}
}
Expand All @@ -319,7 +319,7 @@ private void initModules() {
}

private void initPackages() {
packages = new TreeSet<>(utils.comparators.makePackageComparator());
packages = new TreeSet<>(utils.comparators.packageComparator());
// add all the included packages
packages.addAll(includedPackageElements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
Expand All @@ -56,11 +55,8 @@
import com.sun.tools.javac.code.Symbol.ModuleSymbol;
import com.sun.tools.javac.code.Symbol.PackageSymbol;
import com.sun.tools.javac.code.Symbol.VarSymbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
import com.sun.tools.javac.model.JavacElements;
import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Options;

Expand Down Expand Up @@ -280,8 +276,8 @@ static class NewSerializedForm {
NewSerializedForm(Utils utils, Elements elements, TypeElement te) {
this.utils = utils;
this.elements = elements;
methods = new TreeSet<>(utils.comparators.makeGeneralPurposeComparator());
fields = new TreeSet<>(utils.comparators.makeGeneralPurposeComparator());
methods = new TreeSet<>(utils.comparators.generalPurposeComparator());
fields = new TreeSet<>(utils.comparators.generalPurposeComparator());
if (utils.isExternalizable(te)) {
/* look up required public accessible methods,
* writeExternal and readExternal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public ClassTree(BaseConfiguration configuration) {
Messages messages = configuration.getMessages();
messages.notice("doclet.Building_Tree");

Comparator<Element> comparator = utils.comparators.makeClassUseComparator();
Comparator<Element> comparator = utils.comparators.classUseComparator();

hierarchies = new EnumMap<>(HierarchyKind.class);
for (var hk : HierarchyKind.values()) {
Expand All @@ -206,7 +206,7 @@ public ClassTree(SortedSet<TypeElement> classesSet, BaseConfiguration configurat
this.configuration = configuration;
this.utils = configuration.utils;

Comparator<Element> comparator = utils.comparators.makeClassUseComparator();
Comparator<Element> comparator = utils.comparators.classUseComparator();

hierarchies = new EnumMap<>(HierarchyKind.class);
for (var hk : HierarchyKind.values()) {
Expand Down

1 comment on commit 4ae75ca

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.