From f6d414fb4352eae551b3f80f0543dd18d91f889f Mon Sep 17 00:00:00 2001 From: Christian De Angelis Date: Sat, 10 Feb 2024 02:37:00 -0500 Subject: [PATCH] Recognize when reference types are arrays. Fixes #5. --- bluesky/api/bluesky.api | 20 +++++++++---------- .../ozone/api/generator/builder/util.kt | 8 +++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/bluesky/api/bluesky.api b/bluesky/api/bluesky.api index 1f96ab1f..a31b40e6 100644 --- a/bluesky/api/bluesky.api +++ b/bluesky/api/bluesky.api @@ -61,12 +61,12 @@ public final class app/bsky/actor/FeedViewPref$Companion { public final class app/bsky/actor/GetPreferencesResponse { public static final field Companion Lapp/bsky/actor/GetPreferencesResponse$Companion; - public fun (Lapp/bsky/actor/PreferencesUnion;)V - public final fun component1 ()Lapp/bsky/actor/PreferencesUnion; - public final fun copy (Lapp/bsky/actor/PreferencesUnion;)Lapp/bsky/actor/GetPreferencesResponse; - public static synthetic fun copy$default (Lapp/bsky/actor/GetPreferencesResponse;Lapp/bsky/actor/PreferencesUnion;ILjava/lang/Object;)Lapp/bsky/actor/GetPreferencesResponse; + public fun (Lkotlinx/collections/immutable/ImmutableList;)V + public final fun component1 ()Lkotlinx/collections/immutable/ImmutableList; + public final fun copy (Lkotlinx/collections/immutable/ImmutableList;)Lapp/bsky/actor/GetPreferencesResponse; + public static synthetic fun copy$default (Lapp/bsky/actor/GetPreferencesResponse;Lkotlinx/collections/immutable/ImmutableList;ILjava/lang/Object;)Lapp/bsky/actor/GetPreferencesResponse; public fun equals (Ljava/lang/Object;)Z - public final fun getPreferences ()Lapp/bsky/actor/PreferencesUnion; + public final fun getPreferences ()Lkotlinx/collections/immutable/ImmutableList; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -564,12 +564,12 @@ public final class app/bsky/actor/ProfileViewDetailed$Companion { public final class app/bsky/actor/PutPreferencesRequest { public static final field Companion Lapp/bsky/actor/PutPreferencesRequest$Companion; - public fun (Lapp/bsky/actor/PreferencesUnion;)V - public final fun component1 ()Lapp/bsky/actor/PreferencesUnion; - public final fun copy (Lapp/bsky/actor/PreferencesUnion;)Lapp/bsky/actor/PutPreferencesRequest; - public static synthetic fun copy$default (Lapp/bsky/actor/PutPreferencesRequest;Lapp/bsky/actor/PreferencesUnion;ILjava/lang/Object;)Lapp/bsky/actor/PutPreferencesRequest; + public fun (Lkotlinx/collections/immutable/ImmutableList;)V + public final fun component1 ()Lkotlinx/collections/immutable/ImmutableList; + public final fun copy (Lkotlinx/collections/immutable/ImmutableList;)Lapp/bsky/actor/PutPreferencesRequest; + public static synthetic fun copy$default (Lapp/bsky/actor/PutPreferencesRequest;Lkotlinx/collections/immutable/ImmutableList;ILjava/lang/Object;)Lapp/bsky/actor/PutPreferencesRequest; public fun equals (Ljava/lang/Object;)Z - public final fun getPreferences ()Lapp/bsky/actor/PreferencesUnion; + public final fun getPreferences ()Lkotlinx/collections/immutable/ImmutableList; public fun hashCode ()I public fun toString ()Ljava/lang/String; } diff --git a/generator/src/main/kotlin/sh/christian/ozone/api/generator/builder/util.kt b/generator/src/main/kotlin/sh/christian/ozone/api/generator/builder/util.kt index a8527301..a81f9d7b 100644 --- a/generator/src/main/kotlin/sh/christian/ozone/api/generator/builder/util.kt +++ b/generator/src/main/kotlin/sh/christian/ozone/api/generator/builder/util.kt @@ -288,7 +288,13 @@ fun LexiconSingleReference.typeName( if (objectRef == "main") "" else objectRef.capitalized() + if (isUnionType) "Union" else "" - return ClassName(packageName, className) + val referenceClassName = ClassName(packageName, className) + + return if (lexiconRefType is LexiconArray) { + TypeNames.ReadOnlyList.parameterizedBy(referenceClassName) + } else { + referenceClassName + } } fun String.parseLexiconRef(source: LexiconDocument): Pair {