Skip to content

Commit

Permalink
chore: small naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
worstell committed Sep 28, 2023
1 parent 92db013 commit 1e27e57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class ModuleGenerator() {
}
}

internal fun generateModule(schema: Module): FileSpec {
val namespace = "ftl.${schema.name}"
val className = schema.name.replaceFirstChar(Char::titlecase)
internal fun generateModule(module: Module): FileSpec {
val namespace = "ftl.${module.name}"
val className = module.name.replaceFirstChar(Char::titlecase)
val file = FileSpec.builder(namespace, className)
.addFileComment("Code generated by FTL-Plugin, do not edit.")
.addFileComment("Code generated by FTL-Generator, do not edit.")

schema.comments.let {
module.comments.let {
file.addFileComment("\n")
file.addFileComment(it.joinToString("\n"))
}
Expand All @@ -58,10 +58,10 @@ class ModuleGenerator() {
FunSpec.constructorBuilder().build()
)

val types = schema.decls.mapNotNull { it.data_ }
val types = module.decls.mapNotNull { it.data_ }
types.forEach { file.addType(buildDataClass(it)) }

val verbs = schema.decls.mapNotNull { it.verb }
val verbs = module.decls.mapNotNull { it.verb }
verbs.forEach { moduleClass.addFunction(buildVerbFunction(className, it)) }

file.addType(moduleClass.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ModuleGeneratorTest {
@Test
fun `should generate basic module`() {
val file = generator.generateModule(Module(name = "test"))
val expected = """// Code generated by FTL-Plugin, do not edit.
val expected = """// Code generated by FTL-Generator, do not edit.
//
package ftl.test
Expand Down Expand Up @@ -83,7 +83,7 @@ public class Test()
val module = Module(name = "test", comments = listOf("Module comments"), decls = decls)

val file = generator.generateModule(module)
val expected = """// Code generated by FTL-Plugin, do not edit.
val expected = """// Code generated by FTL-Generator, do not edit.
// Module comments
package ftl.test
Expand Down Expand Up @@ -156,7 +156,7 @@ public class Test()
)
val module = Module(name = "test", comments = listOf("Module comments"), decls = decls)
val file = generator.generateModule(module)
val expected = """// Code generated by FTL-Plugin, do not edit.
val expected = """// Code generated by FTL-Generator, do not edit.
// Module comments
package ftl.test
Expand Down

0 comments on commit 1e27e57

Please sign in to comment.