From 0a20d3b0d20b667e810e4e294780d39655c9b374 Mon Sep 17 00:00:00 2001 From: Mikhail Yakshin Date: Mon, 8 Aug 2022 00:28:05 +0100 Subject: [PATCH] MarkupClassNames: refactored to match PrecompileStep API --- shared/src/main/scala/io/kaitai/struct/Main.scala | 2 +- .../io/kaitai/struct/precompile/MarkupClassNames.scala | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/shared/src/main/scala/io/kaitai/struct/Main.scala b/shared/src/main/scala/io/kaitai/struct/Main.scala index 910b5a02e..d1e30294d 100644 --- a/shared/src/main/scala/io/kaitai/struct/Main.scala +++ b/shared/src/main/scala/io/kaitai/struct/Main.scala @@ -56,7 +56,7 @@ object Main { def precompile(classSpecs: ClassSpecs, topClass: ClassSpec, conf: RuntimeConfig): Iterable[CompilationProblem] = { val config = updateConfigFromMeta(conf, topClass.meta) - classSpecs.foreach { case (_, curClass) => MarkupClassNames.markupClassNames(curClass) } + new MarkupClassNames(classSpecs).run() val resolveTypeProblems = new ResolveTypes(classSpecs, config.opaqueTypes).run() // For now, bail out early in case we have any type resolution problems diff --git a/shared/src/main/scala/io/kaitai/struct/precompile/MarkupClassNames.scala b/shared/src/main/scala/io/kaitai/struct/precompile/MarkupClassNames.scala index c2ebb628d..083aec982 100644 --- a/shared/src/main/scala/io/kaitai/struct/precompile/MarkupClassNames.scala +++ b/shared/src/main/scala/io/kaitai/struct/precompile/MarkupClassNames.scala @@ -1,8 +1,14 @@ package io.kaitai.struct.precompile -import io.kaitai.struct.format.ClassSpec +import io.kaitai.struct.format.{ClassSpec, ClassSpecs} +import io.kaitai.struct.problems.CompilationProblem + +class MarkupClassNames(classSpecs: ClassSpecs) extends PrecompileStep { + override def run(): Iterable[CompilationProblem] = { + classSpecs.foreach { case (_, curClass) => markupClassNames(curClass) } + None + } -object MarkupClassNames { def markupClassNames(curClass: ClassSpec): Unit = { curClass.enums.foreach { case (enumName, enumSpec) => enumSpec.name = curClass.name ::: List(enumName)