diff --git a/state_machine_exporter/src/main/java/click/kamil/springstatemachineexporter/ast/common/CodebaseContext.java b/state_machine_exporter/src/main/java/click/kamil/springstatemachineexporter/ast/common/CodebaseContext.java index 3d55478..dcbdd2c 100644 --- a/state_machine_exporter/src/main/java/click/kamil/springstatemachineexporter/ast/common/CodebaseContext.java +++ b/state_machine_exporter/src/main/java/click/kamil/springstatemachineexporter/ast/common/CodebaseContext.java @@ -244,9 +244,13 @@ public class CodebaseContext { } // Recursively index nested types - for (Object type : td.getTypes()) { - if (type instanceof TypeDeclaration nestedTd) { + for (Object decl : td.bodyDeclarations()) { + if (decl instanceof TypeDeclaration nestedTd) { indexType(nestedTd, fqn, javaFile); + } else if (decl instanceof EnumDeclaration nestedEd) { + indexEnum(nestedEd, fqn, javaFile); + } else if (decl instanceof org.eclipse.jdt.core.dom.RecordDeclaration nestedRd) { + indexRecord(nestedRd, fqn, javaFile); } } } @@ -269,10 +273,12 @@ public class CodebaseContext { } // Recursively index nested types - for (Object type : rd.bodyDeclarations()) { - if (type instanceof TypeDeclaration nestedTd) { + for (Object decl : rd.bodyDeclarations()) { + if (decl instanceof TypeDeclaration nestedTd) { indexType(nestedTd, fqn, javaFile); - } else if (type instanceof org.eclipse.jdt.core.dom.RecordDeclaration nestedRd) { + } else if (decl instanceof EnumDeclaration nestedEd) { + indexEnum(nestedEd, fqn, javaFile); + } else if (decl instanceof org.eclipse.jdt.core.dom.RecordDeclaration nestedRd) { indexRecord(nestedRd, fqn, javaFile); } } @@ -331,6 +337,17 @@ public class CodebaseContext { if (!simpleNameToFqn.containsKey(simpleName)) { simpleNameToFqn.put(simpleName, fqn); } + + // Recursively index nested types inside enum body + for (Object decl : ed.bodyDeclarations()) { + if (decl instanceof TypeDeclaration nestedTd) { + indexType(nestedTd, fqn, javaFile); + } else if (decl instanceof EnumDeclaration nestedEd) { + indexEnum(nestedEd, fqn, javaFile); + } else if (decl instanceof org.eclipse.jdt.core.dom.RecordDeclaration nestedRd) { + indexRecord(nestedRd, fqn, javaFile); + } + } } public Map> getEnumValuesMap() {