changeset 58017:cc5c578e1af6

8238291: Fix inconsistencies in the format of the index files Reviewed-by: jjg
author prappo
date Tue, 11 Feb 2020 13:19:12 +0000
parents aef4920d5b30
children 396a47e0860f
files src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js test/langtools/jdk/javadoc/doclet/testModules/TestModules.java test/langtools/jdk/javadoc/doclet/testPackagePage/TestPackagePage.java test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java
diffstat 6 files changed, 80 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java	Tue Feb 11 14:55:45 2020 +0300
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java	Tue Feb 11 13:19:12 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, 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
@@ -109,58 +109,60 @@
         return systemProperty;
     }
 
+    @Override
     public String toString() {
-        StringBuilder item = new StringBuilder("");
+        // TODO: Additional processing is required, see JDK-8238495
+        StringBuilder item = new StringBuilder();
         switch (category) {
-        case MODULES:
-            item.append("{")
-                    .append("\"l\":\"").append(label).append("\"")
-                    .append("}");
-            break;
-        case PACKAGES:
-            item.append("{");
-            if (!containingModule.isEmpty()) {
-                item.append("\"m\":\"").append(containingModule).append("\",");
-            }
-            item.append("\"l\":\"").append(label).append("\"");
-            if (!url.isEmpty()) {
-                item.append(",\"url\":\"").append(url).append("\"");
-            }
-            item.append("}");
-            break;
-        case TYPES:
-            item.append("{");
-            if (!containingPackage.isEmpty()) {
-                item.append("\"p\":\"").append(containingPackage).append("\",");
-            }
-            item.append("\"l\":\"").append(label).append("\"");
-            if (!url.isEmpty()) {
-                item.append(",\"url\":\"").append(url).append("\"");
-            }
-            item.append("}");
-            break;
-        case MEMBERS:
-            item.append("{")
-                    .append("\"p\":\"").append(containingPackage).append("\",")
-                    .append("\"c\":\"").append(containingClass).append("\",")
-                    .append("\"l\":\"").append(label).append("\"");
-            if (!url.isEmpty()) {
-                item.append(",\"url\":\"").append(url).append("\"");
-            }
-            item.append("}");
-            break;
-        case SEARCH_TAGS:
-            item.append("{")
-                    .append("\"l\":\"").append(label).append("\",")
-                    .append("\"h\":\"").append(holder).append("\",");
-            if (!description.isEmpty()) {
-                item.append("\"d\":\"").append(description).append("\",");
-            }
-            item.append("\"u\":\"").append(url).append("\"")
-                    .append("}");
-            break;
-        default:
-            throw new IllegalStateException("category not set");
+            case MODULES:
+                item.append("{")
+                        .append("\"l\":\"").append(label).append("\"")
+                        .append("}");
+                break;
+            case PACKAGES:
+                item.append("{");
+                if (!containingModule.isEmpty()) {
+                    item.append("\"m\":\"").append(containingModule).append("\",");
+                }
+                item.append("\"l\":\"").append(label).append("\"");
+                if (!url.isEmpty()) {
+                    item.append(",\"u\":\"").append(url).append("\"");
+                }
+                item.append("}");
+                break;
+            case TYPES:
+                item.append("{");
+                if (!containingPackage.isEmpty()) {
+                    item.append("\"p\":\"").append(containingPackage).append("\",");
+                }
+                item.append("\"l\":\"").append(label).append("\"");
+                if (!url.isEmpty()) {
+                    item.append(",\"u\":\"").append(url).append("\"");
+                }
+                item.append("}");
+                break;
+            case MEMBERS:
+                item.append("{")
+                        .append("\"p\":\"").append(containingPackage).append("\",")
+                        .append("\"c\":\"").append(containingClass).append("\",")
+                        .append("\"l\":\"").append(label).append("\"");
+                if (!url.isEmpty()) {
+                    item.append(",\"u\":\"").append(url).append("\"");
+                }
+                item.append("}");
+                break;
+            case SEARCH_TAGS:
+                item.append("{")
+                        .append("\"l\":\"").append(label).append("\",")
+                        .append("\"h\":\"").append(holder).append("\",");
+                if (!description.isEmpty()) {
+                    item.append("\"d\":\"").append(description).append("\",");
+                }
+                item.append("\"u\":\"").append(url).append("\"")
+                        .append("}");
+                break;
+            default:
+                throw new AssertionError("Unexpected category: " + category);
         }
         return item.toString();
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Tue Feb 11 14:55:45 2020 +0300
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Tue Feb 11 13:19:12 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, 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
@@ -319,14 +319,14 @@
                 if (ui.item.category === catModules) {
                     url += "module-summary.html";
                 } else if (ui.item.category === catPackages) {
-                    if (ui.item.url) {
-                        url = ui.item.url;
+                    if (ui.item.u) {
+                        url = ui.item.u;
                     } else {
-                    url += ui.item.l.replace(/\./g, '/') + "/package-summary.html";
+                        url += ui.item.l.replace(/\./g, '/') + "/package-summary.html";
                     }
                 } else if (ui.item.category === catTypes) {
-                    if (ui.item.url) {
-                        url = ui.item.url;
+                    if (ui.item.u) {
+                        url = ui.item.u;
                     } else if (ui.item.p === "<Unnamed>") {
                         url += ui.item.l + ".html";
                     } else {
@@ -338,8 +338,8 @@
                     } else {
                         url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.c + ".html" + "#";
                     }
-                    if (ui.item.url) {
-                        url += ui.item.url;
+                    if (ui.item.u) {
+                        url += ui.item.u;
                     } else {
                         url += ui.item.l;
                     }
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Tue Feb 11 14:55:45 2020 +0300
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Tue Feb 11 13:19:12 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2020, 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
@@ -1321,9 +1321,9 @@
                 "<div class=\"packagesSummary\">\n"
                 + "<table summary=\"Package Summary table, listing packages, and an explanation\">");
         checkOutput("type-search-index.js", true,
-                "{\"l\":\"All Classes\",\"url\":\"allclasses-index.html\"}");
+                "{\"l\":\"All Classes\",\"u\":\"allclasses-index.html\"}");
         checkOutput("package-search-index.js", true,
-                "{\"l\":\"All Packages\",\"url\":\"allpackages-index.html\"}");
+                "{\"l\":\"All Packages\",\"u\":\"allpackages-index.html\"}");
         checkOutput("index-all.html", true,
                 "<br><a href=\"allclasses-index.html\">All&nbsp;Classes</a>"
                 + "<span class=\"verticalSeparator\">|</span>"
--- a/test/langtools/jdk/javadoc/doclet/testPackagePage/TestPackagePage.java	Tue Feb 11 14:55:45 2020 +0300
+++ b/test/langtools/jdk/javadoc/doclet/testPackagePage/TestPackagePage.java	Tue Feb 11 13:19:12 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2020, 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
@@ -102,9 +102,9 @@
                 + "</tr>\n"
                 + "</thead>\n");
         checkOutput("type-search-index.js", true,
-                "{\"l\":\"All Classes\",\"url\":\"allclasses-index.html\"}");
+                "{\"l\":\"All Classes\",\"u\":\"allclasses-index.html\"}");
         checkOutput("package-search-index.js", true,
-                "{\"l\":\"All Packages\",\"url\":\"allpackages-index.html\"}");
+                "{\"l\":\"All Packages\",\"u\":\"allpackages-index.html\"}");
         checkOutput("index-all.html", true,
                 "<br><a href=\"allclasses-index.html\">All&nbsp;Classes</a>"
                 + "<span class=\"verticalSeparator\">|</span>"
--- a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Feb 11 14:55:45 2020 +0300
+++ b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Feb 11 13:19:12 2020 +0000
@@ -402,15 +402,15 @@
 
     void checkSearchIndex(boolean expectedOutput) {
         checkOutput("member-search-index.js", expectedOutput,
-                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"AnotherClass()\",\"url\":\"%3Cinit%3E()\"}",
-                "{\"p\":\"pkg1\",\"c\":\"RegClass\",\"l\":\"RegClass()\",\"url\":\"%3Cinit%3E()\"}",
-                "{\"p\":\"pkg2\",\"c\":\"TestError\",\"l\":\"TestError()\",\"url\":\"%3Cinit%3E()\"}",
-                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"url\":\"method(byte[],int,java.lang.String)\"}");
+                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"AnotherClass()\",\"u\":\"%3Cinit%3E()\"}",
+                "{\"p\":\"pkg1\",\"c\":\"RegClass\",\"l\":\"RegClass()\",\"u\":\"%3Cinit%3E()\"}",
+                "{\"p\":\"pkg2\",\"c\":\"TestError\",\"l\":\"TestError()\",\"u\":\"%3Cinit%3E()\"}",
+                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"u\":\"method(byte[],int,java.lang.String)\"}");
         checkOutput("member-search-index.js", !expectedOutput,
-                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(RegClass)\",\"url\":\"method-pkg1.RegClass-\"}",
-                "{\"p\":\"pkg2\",\"c\":\"TestClass\",\"l\":\"TestClass()\",\"url\":\"TestClass--\"}",
-                "{\"p\":\"pkg\",\"c\":\"TestError\",\"l\":\"TestError()\",\"url\":\"TestError--\"}",
-                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"url\":\"method-byte:A-int-java.lang.String-\"}");
+                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(RegClass)\",\"u\":\"method-pkg1.RegClass-\"}",
+                "{\"p\":\"pkg2\",\"c\":\"TestClass\",\"l\":\"TestClass()\",\"u\":\"TestClass--\"}",
+                "{\"p\":\"pkg\",\"c\":\"TestError\",\"l\":\"TestError()\",\"u\":\"TestError--\"}",
+                "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"u\":\"method-byte:A-int-java.lang.String-\"}");
     }
 
     void checkSearchOutput(boolean expectedOutput, boolean moduleDirectoriesVar) {
@@ -745,9 +745,9 @@
                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
                 + "</tr>\n");
         checkOutput("type-search-index.js", true,
-                "{\"l\":\"All Classes\",\"url\":\"allclasses-index.html\"}");
+                "{\"l\":\"All Classes\",\"u\":\"allclasses-index.html\"}");
         checkOutput("package-search-index.js", true,
-                "{\"l\":\"All Packages\",\"url\":\"allpackages-index.html\"}");
+                "{\"l\":\"All Packages\",\"u\":\"allpackages-index.html\"}");
         checkOutput("index-all.html", true,
                     "<br><a href=\"allclasses-index.html\">All&nbsp;Classes</a>"
                     + "<span class=\"verticalSeparator\">|</span>"
--- a/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java	Tue Feb 11 14:55:45 2020 +0300
+++ b/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java	Tue Feb 11 13:19:12 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, 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
@@ -104,10 +104,10 @@
                 + "</table>");
 
         checkOutput("type-search-index.js", true,
-                "{\"l\":\"All Classes\",\"url\":\"allclasses-index.html\"}");
+                "{\"l\":\"All Classes\",\"u\":\"allclasses-index.html\"}");
 
         checkOutput("package-search-index.js", true,
-                "{\"l\":\"All Packages\",\"url\":\"allpackages-index.html\"}");
+                "{\"l\":\"All Packages\",\"u\":\"allpackages-index.html\"}");
 
         checkOutput("index-all.html", true,
                 "<br><a href=\"allclasses-index.html\">All&nbsp;Classes</a>"