Skip to content

Commit

Permalink
emit top level primitives for Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
inferrinizzard committed Apr 5, 2024
1 parent da87815 commit 313a9d8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/quicktype-core/src/language/Kotlin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ export class KotlinRenderer extends ConvenienceRenderer {
this.ensureBlankLine();
}

protected emitTopLevelPrimitive(t: PrimitiveType, name: Name): void {
const elementType = this.kotlinType(t);
this.emitLine(["typealias ", name, " = ", elementType, ""]);
}

protected emitTopLevelArray(t: ArrayType, name: Name): void {
const elementType = this.kotlinType(t.items);
this.emitLine(["typealias ", name, " = ArrayList<", elementType, ">"]);
Expand Down Expand Up @@ -446,6 +451,8 @@ export class KotlinRenderer extends ConvenienceRenderer {
this.emitTopLevelArray(t, name);
} else if (t instanceof MapType) {
this.emitTopLevelMap(t, name);
} else if (t.isPrimitive()) {
this.emitTopLevelPrimitive(t, name);
}
});

Expand Down

0 comments on commit 313a9d8

Please sign in to comment.