Skip to content

Commit

Permalink
recursively inspect superclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
nextdayy committed Nov 18, 2024
1 parent 2d33d2f commit e462c8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=OneConfig
mod_id=oneconfig
version_major=1
version_minor=0
version_patch=0-alpha.37
version_patch=0-alpha.38

polyfrost.defaults.loom=3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,29 @@ public ReflectiveCollector(int maxDepth) {


public void handle(@NotNull Tree tree, @NotNull Object src, int depth) {
for (Field f : src.getClass().getDeclaredFields()) {
Class<?> cls = src.getClass();
for (Field f : cls.getDeclaredFields()) {
handleField(f, src, tree);
}
for (Method m : src.getClass().getDeclaredMethods()) {
for (Method m : cls.getDeclaredMethods()) {
handleMethod(m, src, tree);
}
Class<?> superClass = src.getClass().getSuperclass();
if (superClass != null) {
Class<?> superClass = cls.getSuperclass();
while (superClass != null) {
for (Field f : superClass.getDeclaredFields()) {
handleField(f, src, tree);
}
for (Method m : superClass.getDeclaredMethods()) {
handleMethod(m, src, tree);
}
superClass = superClass.getSuperclass();
}
for (Class<?> c : src.getClass().getDeclaredClasses()) {
for (Class<?> sub : cls.getDeclaredClasses()) {
if (depth >= maxDepth) {
LOGGER.warn("Reached max depth for tree {} ignoring further subclasses!", tree.getID());
return;
}
handleInnerClass(c, src, depth + 1, tree);
handleInnerClass(sub, src, depth + 1, tree);
}
}
}

0 comments on commit e462c8d

Please sign in to comment.