Skip to content

Commit f248126

Browse files
committed
not bothering with duplicate symbol name detection (minimal viable product)
1 parent 18e6c1f commit f248126

File tree

5 files changed

+5
-10
lines changed

5 files changed

+5
-10
lines changed

TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
Ordered roughly in priority:
55

66
- Add more real world payloads
7-
- Symbol pool for class names
87
- General cleanup of weird/disgusting code areas
98
- Address all FIXME/TODOs
109
- Write Contributing guide

core/src/main/kotlin/com/fractalwrench/json2kotlin/ClassTypeHolder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal class ClassTypeHolder(val delegate: SourceBuildDelegate, groupingStrate
5959
}
6060

6161
val classType = buildClass(commonElements, fields.sortedBy {
62-
it.toKotlinIdentifier().toLowerCase() // FIXME check symbol pool!
62+
it.toKotlinIdentifier().toLowerCase()
6363
}).build()
6464

6565
return commonElements.filterNot { // reuse any types which already exist in the map
@@ -71,7 +71,7 @@ internal class ClassTypeHolder(val delegate: SourceBuildDelegate, groupingStrate
7171

7272
private fun buildClass(commonElements: List<TypedJsonElement>, fields: Collection<String>): TypeSpec.Builder {
7373
val identifier = commonElements.last().kotlinIdentifier // FIXME should only pass in one if that's all that's needed!
74-
val classBuilder = TypeSpec.classBuilder(identifier.capitalize()) // FIXME check symbol pool!
74+
val classBuilder = TypeSpec.classBuilder(identifier.capitalize())
7575
val constructor = FunSpec.constructorBuilder()
7676

7777
if (fields.isEmpty()) { // FIXME misses delegate!

core/src/main/kotlin/com/fractalwrench/json2kotlin/JsonNames.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package com.fractalwrench.json2kotlin
22

33

4-
// TODO move to a symbol pool class (or equivalent)
5-
64
internal fun nameForArrayField(index: Int, identifier: String): String =
75
if (index == 0) identifier else "$identifier${index + 1}"
86

9-
// TODO move to a symbol pool class (or equivalent)
10-
117
// FIXME pattern compilation
128

139
fun String.standardiseNewline(): String {

core/src/main/kotlin/com/fractalwrench/json2kotlin/JsonTypeDetector.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal class JsonTypeDetector {
4040
return ClassName.bestGuess(existingTypeName.name!!)
4141
}
4242

43-
val identifier = key.toKotlinIdentifier().capitalize() // FIXME check symbol pool!
43+
val identifier = key.toKotlinIdentifier().capitalize()
4444
return ClassName.bestGuess(identifier)
4545
}
4646

@@ -49,7 +49,7 @@ internal class JsonTypeDetector {
4949
var nullable = false
5050

5151
jsonArray.withIndex().forEach {
52-
val sanitisedName = key.toKotlinIdentifier() // FIXME check symbol pool!
52+
val sanitisedName = key.toKotlinIdentifier()
5353
with(it.value) {
5454
when {
5555
isJsonPrimitive -> arrayTypes.add(typeForJsonPrimitive(asJsonPrimitive))

core/src/main/kotlin/com/fractalwrench/json2kotlin/TypedJsonElement.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TypedJsonElement : JsonElement {
99
val jsonElement: JsonElement
1010
val jsonKey: String
1111
val level: Int
12-
val kotlinIdentifier: String // FIXME symbol pooling
12+
val kotlinIdentifier: String
1313

1414
constructor(jsonElement: JsonElement, jsonKey: String, level: Int) : super() {
1515
this.jsonElement = jsonElement

0 commit comments

Comments
 (0)