diff --git a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt index ceed8dc9d0..736b5e8d9d 100644 --- a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt +++ b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt @@ -55,6 +55,7 @@ import java.util.* class TestGson { companion object { + private fun explArgAdapterHelper(): Type = TypeToken.getParameterized( TypeToken.get(ArgAdapterHelper::class.java).type, @@ -100,8 +101,10 @@ class TestGson { private fun getExplBuilder(gsonSuppl: () -> Gson): GsonBuilder { val gsonBuilder = GsonBuilder() - gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, ArgAdapter( gsonSuppl, { ExplOrd.getInstance() }, { explArgAdapterHelper() })) - gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, TraceAdapter(gsonSuppl, { ExplState::class.java }, SimpleStmtAction::class.java)) + gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, + ArgAdapter(gsonSuppl, { ExplOrd.getInstance() }, { explArgAdapterHelper() })) + gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, + TraceAdapter(gsonSuppl, { ExplState::class.java }, SimpleStmtAction::class.java)) gsonBuilder.registerTypeHierarchyAdapter(SafetyResult::class.java, SafetyResultAdapter(gsonSuppl, { explArgHelper() }, { explTraceHelper() })) @@ -111,8 +114,10 @@ class TestGson { private fun getPredBuilder(gsonSuppl: () -> Gson): GsonBuilder { val gsonBuilder = GsonBuilder() - gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, ArgAdapter( gsonSuppl, { PartialOrd{ a, b -> true} }, { predArgAdapterHelper() })) - gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, TraceAdapter(gsonSuppl, { PredState::class.java }, SimpleStmtAction::class.java)) + gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, + ArgAdapter(gsonSuppl, { PartialOrd { a, b -> true } }, { predArgAdapterHelper() })) + gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, + TraceAdapter(gsonSuppl, { PredState::class.java }, SimpleStmtAction::class.java)) gsonBuilder.registerTypeHierarchyAdapter(SafetyResult::class.java, SafetyResultAdapter(gsonSuppl, { predArgHelper() }, { predTraceHelper() })) @@ -189,7 +194,8 @@ class TestGson { gson = getGson(getExplBuilder { gson }) { gson } val trace = Trace.of( - listOf(ExplState.of(ImmutableValuation.builder().put(x, Int(1)).build()), ExplState.of(ImmutableValuation.builder().put(x, Int(2)).build())), + listOf(ExplState.of(ImmutableValuation.builder().put(x, Int(1)).build()), + ExplState.of(ImmutableValuation.builder().put(x, Int(2)).build())), listOf(SimpleStmtAction(SkipStmt.getInstance())) ) @@ -215,13 +221,14 @@ class TestGson { } - class SimpleStmtAction(val stmt: Stmt): StmtAction() { + class SimpleStmtAction(val stmt: Stmt) : StmtAction() { + override fun getStmts(): List { return listOf(stmt); } } - class SimpleStmtActionAdapter(val gsonUtils: () -> Gson): TypeAdapter() { + class SimpleStmtActionAdapter(val gsonUtils: () -> Gson) : TypeAdapter() { override fun write(out: JsonWriter, value: SimpleStmtAction) { gsonUtils().toJson(gsonUtils().toJsonTree(value.stmt, Stmt::class.java), out)