Skip to content

Commit

Permalink
fixed JavaDoc resolution for more complex types;
Browse files Browse the repository at this point in the history
  • Loading branch information
sdaschner committed Nov 23, 2017
1 parent 29c0669 commit 14b6c73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.stream.Stream;

/**
* @author Sebastian Daschner
Expand Down Expand Up @@ -111,6 +112,10 @@ private boolean parameterMatch(List<String> originalTypes, List<String> types) {
}

private boolean matchesTypeBestEffort(String originalType, String type) {
// if types are generic types, use full original type signature
if (type.contains("<"))
return Stream.of(type.replace(">", "").split("<")).allMatch(originalType::contains);
// otherwise use class name (for primitives)
return JavaUtils.toClassName(originalType).contains(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ private Map<Integer, String> createResponseComments(Javadoc javadoc) {
* This is a best-effort approach.
*/
private MethodIdentifier calculateMethodIdentifier(MethodDeclaration method) {
String[] parameters = method.getParameters().stream().map(p -> p.getType().asString()).toArray(String[]::new);
String returnType = method.getType().asString();
String[] parameters = method.getParameters().stream()
.map(p -> p.getType().asString())
.map(p -> p.replace('.', '/'))
.toArray(String[]::new);
String returnType = method.getType().asString().replace('.', '/');

if (method.isStatic()) {
return ofStatic(className, method.getNameAsString(), returnType, parameters);
Expand Down

0 comments on commit 14b6c73

Please sign in to comment.