Stop relying on toString() to detect package name.

Fix for #15
This commit is contained in:
Mikaël Barbero
2020-12-11 18:18:32 +00:00
committed by GitHub
parent 24b85e7ad5
commit 9c8e3626ba

View File

@@ -86,8 +86,9 @@ public class ElementUtils {
break;
}
}
String name = typeElement.getEnclosingElement().toString();
return !name.equals("unnamed package") ? name : "";
String name = typeElement.getQualifiedName().toString();
int index = name.lastIndexOf(".");
return (index > -1) ? name.substring(0, index) : "";
}
public static ClassType getClassType(String packageName, String simpleName, List<? extends TypeParameterElement> typeParameters) {