Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8183026

minor cleanup for IndexUseComparator

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 10
    • Component/s: tools
    • Labels:

      Description

      The attached patch did not make it into JDK-8182736, but simplifies the logic in the IndexUseComparator a bit.
      diff -r 0d0ac75b0f6c src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
      --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Mon Jun 26 18:48:31 2017 -0700
      +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Tue Jun 27 13:10:45 2017 -0700
      @@ -1799,15 +1799,11 @@
                    */
                   @Override
                   public int compare(Element e1, Element e2) {
      - int result = 0;
      + int result;
      + // first, compare names as appropriate
                       if ((isModule(e1) || isPackage(e1)) && (isModule(e2) || isPackage(e2))) {
                           result = compareFullyQualifiedNames(e1, e2);
      - if (result != 0) {
      - return result;
      - }
      - return compareElementTypeKinds(e1, e2);
      - }
      - if (isModule(e1) || isPackage(e1)) {
      + } else if (isModule(e1) || isPackage(e1)) {
                           result = compareStrings(getFullyQualifiedName(e1), getSimpleName(e2));
                       } else if (isModule(e2) || isPackage(e2)) {
                           result = compareStrings(getSimpleName(e1), getFullyQualifiedName(e2));
      @@ -1817,10 +1813,12 @@
                       if (result != 0) {
                           return result;
                       }
      + // if names are the same, compare element kinds
                       result = compareElementTypeKinds(e1, e2);
                       if (result != 0) {
                           return result;
                       }
      + // if element kinds are the same, and are methods, compare the parameters
                       if (hasParameters(e1)) {
                           List<? extends VariableElement> parameters1 = ((ExecutableElement)e1).getParameters();
                           List<? extends VariableElement> parameters2 = ((ExecutableElement)e2).getParameters();
      @@ -1833,6 +1831,7 @@
                               return result;
                           }
                       }
      + // else fall back on fully qualified names
                       return compareFullyQualifiedNames(e1, e2);
                   }
               };

        Attachments

          Activity

            People

            Assignee:
            ksrini Kumar Srinivasan
            Reporter:
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: