aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-12-23 10:47:53 +0000
committerMichael Williamson <mike@zwobble.org>2024-12-23 10:47:53 +0000
commit85a2a0a7bc643798241ed361c8501ca6288082bf (patch)
tree113767c4d0f5f31c671b96fdacacc6e97d7a8389 /src/main/java
parent50a74171bad57572bb70d78854bff177fbe206a7 (diff)
Check types for shed.examples and shed.profiles
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/config/ProjectConfig.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/main/java/org/shedlang/compiler/config/ProjectConfig.java b/src/main/java/org/shedlang/compiler/config/ProjectConfig.java
index c45725cc..4b1c9ff9 100644
--- a/src/main/java/org/shedlang/compiler/config/ProjectConfig.java
+++ b/src/main/java/org/shedlang/compiler/config/ProjectConfig.java
@@ -67,19 +67,27 @@ public record ProjectConfig(
}
public static List<ExampleConfig> examplesFromToml(TomlTableWithSource table) {
- var examplesArray = table.table().getArrayOrEmpty(List.of("shed", "examples"));
-
- return IntStream.range(0, examplesArray.size())
- .mapToObj(exampleIndex -> ExampleConfig.fromToml(examplesArray.getTable(exampleIndex)))
- .toList();
+ return table
+ .getTable("shed")
+ .flatMap(shed -> shed.getArray("examples"))
+ .map(examples ->
+ IntStream.range(0, examples.size())
+ .mapToObj(exampleIndex -> ExampleConfig.fromToml(examples.getTable(exampleIndex)))
+ .toList()
+ )
+ .orElseGet(() -> List.of());
}
public static List<ProfileConfig> profilesFromToml(TomlTableWithSource table) {
- var profilesArray = table.table().getArrayOrEmpty(List.of("shed", "profiles"));
-
- return IntStream.range(0, profilesArray.size())
- .mapToObj(profileIndex -> ProfileConfig.fromToml(profilesArray.getTable(profileIndex)))
- .toList();
+ return table
+ .getTable("shed")
+ .flatMap(shed -> shed.getArray("profiles"))
+ .map(profiles ->
+ IntStream.range(0, profiles.size())
+ .mapToObj(profileIndex -> ProfileConfig.fromToml(profiles.getTable(profileIndex)))
+ .toList()
+ )
+ .orElseGet(() -> List.of());
}
public Path targetDir() {