Skip to content

Commit 5ddee1e

Browse files
committed
Go: override out instead of wrapping it
1 parent ede1105 commit 5ddee1e

File tree

1 file changed

+4
-14
lines changed
  • translator/src/main/scala/io/kaitai/struct/testtranslator/specgenerators

1 file changed

+4
-14
lines changed

translator/src/main/scala/io/kaitai/struct/testtranslator/specgenerators/GoSG.scala

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,17 @@ class GoSG(spec: TestSpec, provider: ClassTypeProvider) extends BaseGenerator(sp
1212
* Special wrapper around StringLanguageOutputWriter that catches all attempts
1313
* to access "this.INIT_OBJ_NAME" and replaces it with "r."
1414
*/
15-
class GoOutputWriter(out: StringLanguageOutputWriter) extends StringLanguageOutputWriter(indentStr) {
16-
override def inc: Unit = out.inc
17-
override def dec: Unit = out.dec
18-
override def indentNow: String = out.indentNow
19-
20-
override def add(other: StringLanguageOutputWriter): Unit = out.add(other)
15+
class GoOutputWriter(indentStr: String) extends StringLanguageOutputWriter(indentStr) {
2116
override def puts(s: String): Unit = {
2217
val mangled = s.replace(REPLACER, "r.").replaceAll("return err$", "t.Fatal(err)")
23-
out.puts(mangled)
18+
super.puts(mangled)
2419
}
25-
override def puts = out.puts
26-
override def close = out.close
27-
override def putsLines(prefix: String, lines: String, hanging: String): Unit =
28-
out.putsLines(prefix, lines, hanging)
29-
30-
override def result: String = out.result
3120
}
3221

22+
override val out = new GoOutputWriter(indentStr)
3323
val compiler = new GoCompiler(provider, RuntimeConfig())
3424
val className = GoCompiler.types2class(List(spec.id))
35-
val translator = new GoTranslator(new GoOutputWriter(out), provider, importList)
25+
val translator = new GoTranslator(out, provider, importList)
3626

3727
override def fileName(name: String): String = s"${name}_test.go"
3828

0 commit comments

Comments
 (0)