From 8783fa09a574478d7736358617e52530617d7325 Mon Sep 17 00:00:00 2001 From: piexel Date: Sun, 18 Oct 2026 13:23:08 +0200 Subject: [PATCH] Generate schemas for snippets nested in lists and maps Snippet discovery only followed a field's raw type, so element types of KList, KMap and arrays were never visited. Snippets that only appear in collections, such as decorator, deposit and tree, got no schema and no workspace mapping. Model used: Claude Opus 5.5 --- .../com/volmit/iris/core/loader/IrisData.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/volmit/iris/core/loader/IrisData.java b/core/src/main/java/com/volmit/iris/core/loader/IrisData.java index b43f3d639..ac3e0245b 100644 --- a/core/src/main/java/com/volmit/iris/core/loader/IrisData.java +++ b/core/src/main/java/com/volmit/iris/core/loader/IrisData.java @@ -48,6 +48,9 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; @@ -424,7 +427,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { if (excluder.excludeField(field, false)) continue; - queue.add(field.getType()); + collectClasses(field.getGenericType(), queue); } } catch (Throwable ignored) { } @@ -433,6 +436,22 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { return result; } + private static void collectClasses(Type type, Collection> classes) { + switch (type) { + case Class c when c.isArray() -> collectClasses(c.getComponentType(), classes); + case Class c -> classes.add(c); + case ParameterizedType p -> { + collectClasses(p.getRawType(), classes); + for (Type argument : p.getActualTypeArguments()) { + collectClasses(argument, classes); + } + } + case GenericArrayType a -> collectClasses(a.getGenericComponentType(), classes); + default -> { + } + } + } + public String toLoadKey(File f) { if (f.getPath().startsWith(getDataFolder().getPath())) { String[] full = f.getPath().split("\\Q" + File.separator + "\\E");