Skip to content

Commit 8743f0b

Browse files
committed
8231122: @index tag with newline causes tag search to fail
Reviewed-by: jjg
1 parent a63b541 commit 8743f0b

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ protected Content indexTagOutput(Element element, DocTree tag) {
110110

111111
String tagText = ch.getText(itt.getSearchTerm());
112112
if (tagText.charAt(0) == '"' && tagText.charAt(tagText.length() - 1) == '"') {
113-
tagText = tagText.substring(1, tagText.length() - 1);
113+
tagText = tagText.substring(1, tagText.length() - 1)
114+
.replaceAll("\\s+", " ");
114115
}
115116
String desc = ch.getText(itt.getDescription());
116117

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public Content createLink(DocLink link, Content label, boolean isExternal) {
312312
* @return a valid HTML name
313313
*/
314314
public String getName(String name) {
315-
return name.replaceAll(" +", "");
315+
return name.replaceAll("\\s+", "");
316316
}
317317

318318
}

test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ public void testModuleSearch() throws ScriptException, IOException, NoSuchMethod
149149
checkSearch(inv, "operty", List.of());
150150

151151
// search tag
152-
checkSearch(inv, "search tag", List.of("search tag"));
153-
checkSearch(inv, "search tag", List.of("search tag"));
154-
checkSearch(inv, "search ", List.of("search tag"));
155-
checkSearch(inv, "tag", List.of("search tag"));
156-
checkSearch(inv, "sea", List.of("search tag"));
152+
checkSearch(inv, "search tag", List.of("multiline search tag", "search tag"));
153+
checkSearch(inv, "search tag", List.of("multiline search tag", "search tag"));
154+
checkSearch(inv, "search ", List.of("multiline search tag", "search tag"));
155+
checkSearch(inv, "tag", List.of("multiline search tag", "search tag"));
156+
checkSearch(inv, "sea", List.of("multiline search tag", "search tag"));
157+
checkSearch(inv, "multi", List.of("multiline search tag"));
157158
checkSearch(inv, "ear", List.of());
158159
}
159160

@@ -244,7 +245,7 @@ public void testPackageSource() throws ScriptException, IOException, NoSuchMetho
244245
List.of("listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)"));
245246
checkSearch(inv, "l . o (e,e,e,",
246247
List.of("listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)"));
247-
checkSearch(inv, "search \tt", List.of("search tag"));
248+
checkSearch(inv, "search \tt", List.of("other search tag"));
248249
checkSearch(inv, "sear ch", List.of());
249250
checkSearch(inv, "( e ..", List.of("listpkg.List.of(E...)"));
250251
checkSearch(inv, "( i [ ]", List.of("listpkg.Nolist.withArrayArg(int[])"));

test/langtools/jdk/javadoc/doclet/testSearchScript/listpkg/Nolist.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@
2727
import java.util.Map;
2828

2929
/**
30-
* Example class containing "list" but not matching at any word boundary.
31-
*
32-
* {@index "search tag"}.
30+
* Example class containing "list" but not matching at any word boundary. {@index "other
31+
* search tag"}.
3332
*/
3433
public class Nolist {
3534

test/langtools/jdk/javadoc/doclet/testSearchScript/mapmodule/mappkg/Map.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525

2626
import java.util.Iterator;
2727

28+
/**
29+
* Map interface.
30+
*
31+
* {@index "multiline
32+
* search
33+
* tag"}
34+
*/
2835
public interface Map {
2936
public void put(Object key, Object value);
3037
public boolean contains(Object key);

0 commit comments

Comments
 (0)