8297216: Search results omit some methods
Reviewed-by: jjg
This commit is contained in:
parent
33dfc7d2ef
commit
b27a61e624
@ -157,30 +157,21 @@ function createMatcher(term, camelCase) {
|
|||||||
re.upperCase = upperCase;
|
re.upperCase = upperCase;
|
||||||
return re;
|
return re;
|
||||||
}
|
}
|
||||||
function analyzeMatch(matcher, input, startOfName, category) {
|
function findMatch(matcher, input, startOfName, endOfName) {
|
||||||
var from = startOfName;
|
var from = startOfName;
|
||||||
matcher.lastIndex = from;
|
matcher.lastIndex = from;
|
||||||
var match = matcher.exec(input);
|
var match = matcher.exec(input);
|
||||||
while (!match && from > 1) {
|
// Expand search area until we get a valid result or reach the beginning of the string
|
||||||
|
while (!match || match.index + match[0].length < startOfName || endOfName < match.index) {
|
||||||
|
if (from === 0) {
|
||||||
|
return NO_MATCH;
|
||||||
|
}
|
||||||
from = input.lastIndexOf(".", from - 2) + 1;
|
from = input.lastIndexOf(".", from - 2) + 1;
|
||||||
matcher.lastIndex = from;
|
matcher.lastIndex = from;
|
||||||
match = matcher.exec(input);
|
match = matcher.exec(input);
|
||||||
}
|
}
|
||||||
if (!match) {
|
|
||||||
return NO_MATCH;
|
|
||||||
}
|
|
||||||
var boundaries = [];
|
var boundaries = [];
|
||||||
var matchEnd = match.index + match[0].length;
|
var matchEnd = match.index + match[0].length;
|
||||||
var leftParen = input.indexOf("(");
|
|
||||||
// exclude peripheral matches
|
|
||||||
if (category !== "modules" && category !== "searchTags") {
|
|
||||||
if (leftParen > -1 && leftParen < match.index) {
|
|
||||||
return NO_MATCH;
|
|
||||||
} else if (startOfName - 1 >= matchEnd) {
|
|
||||||
return NO_MATCH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var endOfName = leftParen > -1 ? leftParen : input.length;
|
|
||||||
var score = 5;
|
var score = 5;
|
||||||
var start = match.index;
|
var start = match.index;
|
||||||
var prevEnd = -1;
|
var prevEnd = -1;
|
||||||
@ -220,7 +211,6 @@ function analyzeMatch(matcher, input, startOfName, category) {
|
|||||||
return {
|
return {
|
||||||
input: input,
|
input: input,
|
||||||
score: score,
|
score: score,
|
||||||
category: category,
|
|
||||||
boundaries: boundaries
|
boundaries: boundaries
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -285,13 +275,16 @@ function doSearch(request, response) {
|
|||||||
var useQualified = useQualifiedName(category);
|
var useQualified = useQualifiedName(category);
|
||||||
var input = useQualified ? qualifiedName : simpleName;
|
var input = useQualified ? qualifiedName : simpleName;
|
||||||
var startOfName = useQualified ? prefix.length : 0;
|
var startOfName = useQualified ? prefix.length : 0;
|
||||||
var m = analyzeMatch(matcher.plainMatcher, input, startOfName, category);
|
var endOfName = category === "members" && input.indexOf("(", startOfName) > -1
|
||||||
|
? input.indexOf("(", startOfName) : input.length;
|
||||||
|
var m = findMatch(matcher.plainMatcher, input, startOfName, endOfName);
|
||||||
if (m === NO_MATCH && matcher.camelCaseMatcher) {
|
if (m === NO_MATCH && matcher.camelCaseMatcher) {
|
||||||
m = analyzeMatch(matcher.camelCaseMatcher, input, startOfName, category);
|
m = findMatch(matcher.camelCaseMatcher, input, startOfName, endOfName);
|
||||||
}
|
}
|
||||||
if (m !== NO_MATCH) {
|
if (m !== NO_MATCH) {
|
||||||
m.indexItem = item;
|
m.indexItem = item;
|
||||||
m.prefix = prefix;
|
m.prefix = prefix;
|
||||||
|
m.category = category;
|
||||||
if (!useQualified) {
|
if (!useQualified) {
|
||||||
m.input = qualifiedName;
|
m.input = qualifiedName;
|
||||||
m.boundaries = m.boundaries.map(function(b) {
|
m.boundaries = m.boundaries.map(function(b) {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8178982 8220497 8210683 8241982
|
* @bug 8178982 8220497 8210683 8241982 8297216
|
||||||
* @summary Test the search feature of javadoc.
|
* @summary Test the search feature of javadoc.
|
||||||
* @library ../../lib
|
* @library ../../lib
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
@ -60,13 +60,16 @@ public class TestSearchScript extends JavadocTester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Invocable getEngine() throws ScriptException, IOException, NoSuchMethodException {
|
private Invocable getEngine() throws ScriptException, IOException, NoSuchMethodException {
|
||||||
|
// For installing and using GraalVM JS on stock JDK see
|
||||||
|
// https://github.com/oracle/graaljs/blob/master/docs/user/RunOnJDK.md
|
||||||
|
// and https://github.com/graalvm/graal-js-jdk11-maven-demo
|
||||||
ScriptEngineManager engineManager = new ScriptEngineManager();
|
ScriptEngineManager engineManager = new ScriptEngineManager();
|
||||||
// Use "js" engine name to use any available JavaScript engine.
|
// Use "js" engine name to use any available JavaScript engine.
|
||||||
ScriptEngine engine = engineManager.getEngineByName("js");
|
ScriptEngine engine = engineManager.getEngineByName("js");
|
||||||
if (engine == null) {
|
if (engine == null) {
|
||||||
throw new SkippedException("JavaScript engine is not available.");
|
throw new SkippedException("JavaScript engine is not available.");
|
||||||
}
|
}
|
||||||
// For GraalJS set Nashorn compatibility mode via Bindings,
|
// Set Nashorn compatibility mode via Bindings for use with GraalVM JS,
|
||||||
// see https://github.com/graalvm/graaljs/blob/master/docs/user/ScriptEngine.md
|
// see https://github.com/graalvm/graaljs/blob/master/docs/user/ScriptEngine.md
|
||||||
Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
|
Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
|
||||||
bindings.put("polyglot.js.nashorn-compat", true);
|
bindings.put("polyglot.js.nashorn-compat", true);
|
||||||
@ -334,6 +337,28 @@ public class TestSearchScript extends JavadocTester {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChannelSearch() throws ScriptException, IOException, NoSuchMethodException {
|
||||||
|
javadoc("-d", "out-channel",
|
||||||
|
"-Xdoclint:none",
|
||||||
|
"-use",
|
||||||
|
"-sourcepath", testSrc,
|
||||||
|
"channels");
|
||||||
|
checkExit(Exit.OK);
|
||||||
|
|
||||||
|
Invocable inv = getEngine();
|
||||||
|
|
||||||
|
checkSearch(inv, "FileChannel", List.of("channels.FileChannel", "channels.FileChannel.Map",
|
||||||
|
"channels.FileChannel.FileChannel()"));
|
||||||
|
checkSearch(inv, "FileChannel.", List.of("channels.FileChannel.Map",
|
||||||
|
"channels.FileChannel.FileChannel()", "channels.FileChannel.map(FileChannel.Map, int)"));
|
||||||
|
checkSearch(inv, "filechannel.M", List.of("channels.FileChannel.Map",
|
||||||
|
"channels.FileChannel.map(FileChannel.Map, int)"));
|
||||||
|
checkSearch(inv, "FileChannel.map", List.of("channels.FileChannel.Map",
|
||||||
|
"channels.FileChannel.map(FileChannel.Map, int)"));
|
||||||
|
checkSearch(inv, "FileChannel.map(", List.of("channels.FileChannel.map(FileChannel.Map, int)"));
|
||||||
|
}
|
||||||
|
|
||||||
void checkSearch(Invocable inv, String query, List<String> results) throws ScriptException, NoSuchMethodException {
|
void checkSearch(Invocable inv, String query, List<String> results) throws ScriptException, NoSuchMethodException {
|
||||||
checkList(query, (List<?>) inv.invokeFunction("search", query), results);
|
checkList(query, (List<?>) inv.invokeFunction("search", query), results);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user