8238291: Fix inconsistencies in the format of the index files

Reviewed-by: jjg
This commit is contained in:
Pavel Rappo 2020-02-11 13:19:12 +00:00
parent 898a903530
commit fff1a59cfa
6 changed files with 80 additions and 78 deletions

View File

@ -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 @@ public class SearchIndexItem {
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();
}

View File

@ -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 @@ $(function() {
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 @@ $(function() {
} 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;
}

View File

@ -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 @@ public class TestModules extends JavadocTester {
"<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>"

View File

@ -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 @@ public class TestPackagePage extends JavadocTester {
+ "</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>"

View File

@ -402,15 +402,15 @@ public class TestSearch extends JavadocTester {
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 @@ public class TestSearch extends JavadocTester {
+ "<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>"

View File

@ -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 @@ public class TestUnnamedPackage extends JavadocTester {
+ "</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>"