8231122: @index tag with newline causes tag search to fail
authorhannesw
Tue, 24 Sep 2019 11:49:48 +0200
changeset 58286 e4d90117c5de
parent 58285 1182ff8929cc
child 58287 a7f16447085e
8231122: @index tag with newline causes tag search to fail Reviewed-by: jjg
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java
test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java
test/langtools/jdk/javadoc/doclet/testSearchScript/listpkg/Nolist.java
test/langtools/jdk/javadoc/doclet/testSearchScript/mapmodule/mappkg/Map.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Wed Aug 28 15:51:03 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Tue Sep 24 11:49:48 2019 +0200
@@ -110,7 +110,8 @@
 
         String tagText =  ch.getText(itt.getSearchTerm());
         if (tagText.charAt(0) == '"' && tagText.charAt(tagText.length() - 1) == '"') {
-            tagText = tagText.substring(1, tagText.length() - 1);
+            tagText = tagText.substring(1, tagText.length() - 1)
+                             .replaceAll("\\s+", " ");
         }
         String desc = ch.getText(itt.getDescription());
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java	Wed Aug 28 15:51:03 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java	Tue Sep 24 11:49:48 2019 +0200
@@ -312,7 +312,7 @@
      * @return a valid HTML name
      */
     public String getName(String name) {
-        return name.replaceAll(" +", "");
+        return name.replaceAll("\\s+", "");
     }
 
 }
--- a/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java	Wed Aug 28 15:51:03 2019 +0200
+++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java	Tue Sep 24 11:49:48 2019 +0200
@@ -149,11 +149,12 @@
         checkSearch(inv, "operty", List.of());
 
         // search tag
-        checkSearch(inv, "search tag", List.of("search tag"));
-        checkSearch(inv, "search   tag", List.of("search tag"));
-        checkSearch(inv, "search ", List.of("search tag"));
-        checkSearch(inv, "tag", List.of("search tag"));
-        checkSearch(inv, "sea", List.of("search tag"));
+        checkSearch(inv, "search tag", List.of("multiline search tag", "search tag"));
+        checkSearch(inv, "search   tag", List.of("multiline search tag", "search tag"));
+        checkSearch(inv, "search ", List.of("multiline search tag", "search tag"));
+        checkSearch(inv, "tag", List.of("multiline search tag", "search tag"));
+        checkSearch(inv, "sea", List.of("multiline search tag", "search tag"));
+        checkSearch(inv, "multi", List.of("multiline search tag"));
         checkSearch(inv, "ear", List.of());
     }
 
@@ -244,7 +245,7 @@
                 List.of("listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)"));
         checkSearch(inv, "l . o (e,e,e,",
                 List.of("listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)"));
-        checkSearch(inv, "search    \tt", List.of("search tag"));
+        checkSearch(inv, "search    \tt", List.of("other search tag"));
         checkSearch(inv, "sear ch", List.of());
         checkSearch(inv, "( e ..", List.of("listpkg.List.of(E...)"));
         checkSearch(inv, "( i [ ]", List.of("listpkg.Nolist.withArrayArg(int[])"));
--- a/test/langtools/jdk/javadoc/doclet/testSearchScript/listpkg/Nolist.java	Wed Aug 28 15:51:03 2019 +0200
+++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/listpkg/Nolist.java	Tue Sep 24 11:49:48 2019 +0200
@@ -27,9 +27,8 @@
 import java.util.Map;
 
 /**
- * Example class containing "list" but not matching at any word boundary.
- *
- * {@index "search tag"}.
+ * Example class containing "list" but not matching at any word boundary. {@index "other
+ * search tag"}.
  */
 public class Nolist {
 
--- a/test/langtools/jdk/javadoc/doclet/testSearchScript/mapmodule/mappkg/Map.java	Wed Aug 28 15:51:03 2019 +0200
+++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/mapmodule/mappkg/Map.java	Tue Sep 24 11:49:48 2019 +0200
@@ -25,6 +25,13 @@
 
 import java.util.Iterator;
 
+/**
+ * Map interface.
+ *
+ * {@index "multiline
+ *          search
+ *          tag"}
+ */
 public interface Map {
     public void put(Object key, Object value);
     public boolean contains(Object key);