Skip to content

Commit

Permalink
[MNG-8249] Fix annotation processor to correctly handle inner-inner c…
Browse files Browse the repository at this point in the history
…lasses
  • Loading branch information
gnodet committed Sep 16, 2024
1 parent 7ea795b commit 30f5265
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import javax.tools.FileObject;
Expand Down Expand Up @@ -71,14 +72,19 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}

private String getFullClassName(TypeElement typeElement) {
String className = typeElement.getQualifiedName().toString();
StringBuilder className = new StringBuilder(typeElement.getSimpleName());
Element enclosingElement = typeElement.getEnclosingElement();
if (enclosingElement instanceof TypeElement) {
String enclosingClassName =
((TypeElement) enclosingElement).getQualifiedName().toString();
className = enclosingClassName + "$" + typeElement.getSimpleName();

while (enclosingElement instanceof TypeElement) {
className.insert(0, "$").insert(0, ((TypeElement) enclosingElement).getSimpleName());
enclosingElement = enclosingElement.getEnclosingElement();
}

if (enclosingElement instanceof PackageElement) {
className.insert(0, ".").insert(0, ((PackageElement) enclosingElement).getQualifiedName());
}
return className;

return className.toString();
}

private void updateFileIfChanged() throws IOException {
Expand Down

0 comments on commit 30f5265

Please sign in to comment.