Skip to content

Commit

Permalink
docs: display types information for pass through Map config item
Browse files Browse the repository at this point in the history
  • Loading branch information
machi1990 committed Nov 1, 2019
1 parent d3b5615 commit 934a73b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil.getJavaDocSiteLink;
import static io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil.getKnownGenericType;
import static io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil.hyphenate;
import static io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil.stringifyType;

import java.io.BufferedReader;
import java.io.BufferedWriter;
Expand Down Expand Up @@ -365,6 +366,7 @@ private void recordConfigItems(List<ConfigDocItem> configDocItems, Element eleme
configSection, true, sectionLevel);
continue;
} else {
type = "`" + stringifyType(declaredType) + "`";
configDocKey.setPassThroughMap(true);
configDocKey.setWithinAMap(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.stream.Collectors;

import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;

import io.quarkus.annotation.processor.Constants;

Expand Down Expand Up @@ -337,4 +338,24 @@ private static boolean mergeSectionIntoPreviousExistingConfigItems(ConfigDocSect

return false;
}

static String stringifyType(TypeMirror typeMirror) {
List<? extends TypeMirror> typeArguments = ((DeclaredType) typeMirror).getTypeArguments();
String simpleName = typeSimpleName(typeMirror);
if (typeArguments.isEmpty()) {
return simpleName;
} else if (typeArguments.size() == 1) {
return String.format("%s<%s>", simpleName, stringifyType(typeArguments.get(0)));
} else if (typeArguments.size() == 2) {
return String.format("%s<%s,%s>", simpleName, stringifyType(typeArguments.get(0)),
stringifyType(typeArguments.get(1)));
}

return "unknown"; // we should not reach here
}

private static String typeSimpleName(TypeMirror typeMirror) {
String type = ((DeclaredType) typeMirror).asElement().toString();
return type.substring(1 + type.lastIndexOf(Constants.DOT));
}
}

0 comments on commit 934a73b

Please sign in to comment.