Skip to content

Commit

Permalink
[MPLUGIN-521] Nested types not properly extracted cause exception whi…
Browse files Browse the repository at this point in the history
…le generating Javadoc URLs

This closes #281
  • Loading branch information
michael-o committed May 3, 2024
1 parent 1fa1805 commit 789315b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -625,7 +625,7 @@ protected void writeParameterType(
}
}

static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, String type) {
private static String extractBinaryNameForJavadoc(String type) {
final String binaryName;
int startOfParameterType = type.indexOf("<");
if (startOfParameterType != -1) {
Expand All @@ -637,10 +637,10 @@ static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, Strin
.split(",\\s*");
switch (parameterTypes.length) {
case 1: // if only one parameter type, assume collection, first parameter type is most interesting
binaryName = parameterTypes[0];
binaryName = extractBinaryNameForJavadoc(parameterTypes[0]);
break;
case 2: // if two parameter types assume map, second parameter type is most interesting
binaryName = parameterTypes[1];
binaryName = extractBinaryNameForJavadoc(parameterTypes[1]);
break;
default:
// all other cases link to main type
Expand All @@ -649,7 +649,11 @@ static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, Strin
} else {
binaryName = type;
}
return javadocLinkGenerator.createLink(binaryName);
return binaryName;
}

static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, String type) {
return javadocLinkGenerator.createLink(extractBinaryNameForJavadoc(type));
}

/**
Expand Down
Expand Up @@ -164,6 +164,10 @@ void testGetJavadocUrlForType() throws URISyntaxException {
javadocBaseUri.resolve("java/lang/Integer.html"),
PluginDescriptorFilesGenerator.getJavadocUrlForType(
linkGenerator, "java.lang.Map<java.lang.String,java.lang.Integer>"));
assertEquals(
javadocBaseUri.resolve("java/lang/Integer.html"),
PluginDescriptorFilesGenerator.getJavadocUrlForType(
linkGenerator, "java.lang.Map<java.lang.String,java.util.List<java.lang.Integer>>"));
assertEquals(
javadocBaseUri.resolve("java/util/function/BiFunction.html"),
PluginDescriptorFilesGenerator.getJavadocUrlForType(
Expand Down

0 comments on commit 789315b

Please sign in to comment.