Skip to content

Commit

Permalink
Merge pull request #32717 from radcortez/fix-32666
Browse files Browse the repository at this point in the history
Get element type without annotations
  • Loading branch information
gsmet authored Apr 19, 2023
2 parents f571ba9 + 3e87a01 commit d43d9e1
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ private List<ConfigDocItem> recursivelyFindConfigItems(Element element, String r
String name = null;
String defaultValue = NO_DEFAULT;
String defaultValueDoc = EMPTY;
final TypeMirror typeMirror = unwrapTypeMirror(enclosedElement.asType());
String type = typeMirror.toString();
List<String> acceptedValues = null;
final TypeElement clazz = (TypeElement) element;
final String fieldName = enclosedElement.getSimpleName().toString();
Expand Down Expand Up @@ -250,6 +248,9 @@ private List<ConfigDocItem> recursivelyFindConfigItems(Element element, String r
defaultValue = EMPTY;
}

TypeMirror typeMirror = unwrapTypeMirror(enclosedElement.asType());
String type = getType(typeMirror);

if (isConfigGroup(type)) {
List<ConfigDocItem> groupConfigItems = readConfigGroupItems(configPhase, rootName, name, type,
configSection, withinAMap, generateSeparateConfigGroupDocsFiles);
Expand Down Expand Up @@ -387,6 +388,15 @@ private TypeMirror unwrapTypeMirror(TypeMirror typeMirror) {
return typeMirror;
}

private String getType(TypeMirror typeMirror) {
if (typeMirror instanceof DeclaredType) {
DeclaredType declaredType = (DeclaredType) typeMirror;
TypeElement typeElement = (TypeElement) declaredType.asElement();
return typeElement.getQualifiedName().toString();
}
return typeMirror.toString();
}

private boolean isConfigGroup(String type) {
if (type.startsWith("java.") || PRIMITIVE_TYPES.contains(type)) {
return false;
Expand Down

0 comments on commit d43d9e1

Please sign in to comment.