mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-22 16:17:44 +00:00
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
This commit is contained in:
1 parent
87dc78934f
commit
8783fa09a5
1 file changed
+20
-1
@@ -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<Class<?>> 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");
|
||||
|
||||
Reference in new issue
Block a user