Skip to content

Commit f66fdd8

Browse files
committed
further cleanup
1 parent 46b4f17 commit f66fdd8

File tree

2 files changed

+1
-79
lines changed

2 files changed

+1
-79
lines changed

src/tools/schema2kotlin.ts

+1-38
Original file line numberDiff line numberDiff line change
@@ -198,42 +198,6 @@ export class KotlinGenerator implements ClassGenerator {
198198
}
199199
}
200200

201-
mapOf(items: string[]): string {
202-
switch (items.length) {
203-
case 0:
204-
return `emptyMap()`;
205-
case 1:
206-
return `mapOf(${items[0]})`;
207-
default:
208-
return `\
209-
mapOf(
210-
${this.leftPad(items.join(',\n'), 4)}
211-
)`;
212-
}
213-
214-
}
215-
216-
createSchema(schemaHash: string): string {
217-
const schemaNames = this.node.schema.names.map(n => `SchemaName("${n}")`);
218-
return `\
219-
Schema(
220-
listOf(${schemaNames.join(',\n' + ' '.repeat(8))}),
221-
SchemaFields(
222-
singletons = ${this.leftPad(this.mapOf(this.singletonSchemaFields), 8, true)},
223-
collections = ${this.leftPad(this.mapOf(this.collectionSchemaFields), 8, true)}
224-
),
225-
"${schemaHash}"
226-
)`;
227-
}
228-
229-
leftPad(input: string, indent: number, skipFirst: boolean = false) {
230-
return input
231-
.split('\n')
232-
.map((line: string, idx: number) => (idx === 0 && skipFirst) ? line : ' '.repeat(indent) + line)
233-
.join('\n');
234-
}
235-
236-
237201
createSchema(schemaHash: string): string {
238202
const schemaNames = this.node.schema.names.map(n => `SchemaName("${n}")`);
239203
return `\
@@ -247,7 +211,6 @@ Schema(
247211
)`;
248212
}
249213

250-
251214
generate(schemaHash: string, fieldCount: number): string {
252215
const {name, aliases} = this.node;
253216

@@ -324,7 +287,7 @@ class ${name}_Spec() : ${this.getType('EntitySpec')}<${name}> {
324287
${this.opts.wasm ? '' : `\
325288
326289
companion object {
327-
val schema = ${this.leftPad(this.createSchema(schemaHash), 8, true)}
290+
val schema = ${leftPad(this.createSchema(schemaHash), 8, true)}
328291
329292
init {
330293
SchemaRegistry.register(schema)

src/tools/tests/schema2kotlin-test.ts

-41
This file was deleted.

0 commit comments

Comments
 (0)