From de554bdcbfe5ae2270e12c22ab2b21e18a44ff0a Mon Sep 17 00:00:00 2001 From: Alex Michael Berry Date: Mon, 8 May 2023 22:20:26 -0400 Subject: [PATCH] fixing compiler errors --- .../dev/ligature/lig/LigInputSuite.scala | 10 ++-- .../scala/dev/ligature/lig/LigSuite.scala | 22 +++---- .../dev/ligature/http/LigatureHttp.scala | 2 +- .../scala/dev/ligature/js/LigatureJS.scala | 6 +- .../testsuite/LigatureTestSuite.scala | 58 +++++++++---------- .../dev/ligature/xodus/XodusQueryTx.scala | 12 ++-- .../dev/ligature/xodus/XodusWriteTx.scala | 16 ++--- 7 files changed, 63 insertions(+), 63 deletions(-) diff --git a/lig/shared/src/test/scala/dev/ligature/lig/LigInputSuite.scala b/lig/shared/src/test/scala/dev/ligature/lig/LigInputSuite.scala index f9d77c0a..00789098 100644 --- a/lig/shared/src/test/scala/dev/ligature/lig/LigInputSuite.scala +++ b/lig/shared/src/test/scala/dev/ligature/lig/LigInputSuite.scala @@ -5,7 +5,7 @@ package dev.ligature.lig import dev.ligature.gaze.Gaze -import dev.ligature.{Identifier, IntegerLiteral, Statement, StringLiteral} +import dev.ligature.{Identifier, Statement, LigatureLiteral} import munit.FunSuite class LigInputSuite extends FunSuite { @@ -63,12 +63,12 @@ class LigInputSuite extends FunSuite { Statement( Identifier.fromString("e").getOrElse(???), Identifier.fromString("a").getOrElse(???), - IntegerLiteral(234) + LigatureLiteral.IntegerLiteral(234) ), Statement( Identifier.fromString("e").getOrElse(???), Identifier.fromString("a").getOrElse(???), - IntegerLiteral(432) + LigatureLiteral.IntegerLiteral(432) ) ) val res = read(input) @@ -90,12 +90,12 @@ class LigInputSuite extends FunSuite { Statement( Identifier.fromString("e").getOrElse(???), Identifier.fromString("a").getOrElse(???), - IntegerLiteral(234) + LigatureLiteral.IntegerLiteral(234) ), Statement( Identifier.fromString("e2").getOrElse(???), Identifier.fromString("a").getOrElse(???), - IntegerLiteral(234) + LigatureLiteral.IntegerLiteral(234) ) ) val result = read(input) diff --git a/lig/shared/src/test/scala/dev/ligature/lig/LigSuite.scala b/lig/shared/src/test/scala/dev/ligature/lig/LigSuite.scala index 2e928926..eaba4112 100644 --- a/lig/shared/src/test/scala/dev/ligature/lig/LigSuite.scala +++ b/lig/shared/src/test/scala/dev/ligature/lig/LigSuite.scala @@ -5,7 +5,7 @@ package dev.ligature.lig import munit.FunSuite -import dev.ligature.{Identifier, IntegerLiteral, Statement, StringLiteral} +import dev.ligature.{Identifier, LigatureLiteral, Statement} import dev.ligature.gaze.Gaze class LigSuite extends FunSuite { @@ -36,12 +36,12 @@ class LigSuite extends FunSuite { Statement( identifier("e2"), identifier("a2"), - StringLiteral("string literal") + LigatureLiteral.StringLiteral("string literal") ), Statement( identifier("e2"), identifier("a3"), - IntegerLiteral(Long.MaxValue) + LigatureLiteral.IntegerLiteral(Long.MaxValue) ) ) val lines = write(statements.iterator) @@ -61,8 +61,8 @@ class LigSuite extends FunSuite { |""".stripMargin val expectedStatements = Set( Statement(identifier("a"), identifier("b"), identifier("c")), - Statement(identifier("a"), identifier("b"), IntegerLiteral(123)), - Statement(identifier("a"), identifier("b"), StringLiteral("Test")), + Statement(identifier("a"), identifier("b"), LigatureLiteral.IntegerLiteral(123)), + Statement(identifier("a"), identifier("b"), LigatureLiteral.StringLiteral("Test")), ) val resStatements = read(statements) resStatements match { @@ -88,14 +88,14 @@ class LigSuite extends FunSuite { test("parse IntegerLiteral") { val test = "3452345" - val res = parseIntegerLiteral(Gaze.from(test)) - assertEquals(res, Right(IntegerLiteral(3452345))) + val res: Either[LigError, LigatureLiteral] = parseIntegerLiteral(Gaze.from(test)) + assertEquals(res, Right(LigatureLiteral.IntegerLiteral(3452345))) } test("parse StringLiteral") { val test = "\"3452345\\nHello\"" - val res = parseStringLiteral(Gaze.from(test)) - assertEquals(res, Right(StringLiteral("3452345\\nHello"))) + val res: Either[LigError, LigatureLiteral] = parseStringLiteral(Gaze.from(test)) + assertEquals(res, Right(LigatureLiteral.StringLiteral("3452345\\nHello"))) } test("write identifiers") { @@ -104,13 +104,13 @@ class LigSuite extends FunSuite { } test("write IntegerLiteral") { - val test = IntegerLiteral(3535) + val test = LigatureLiteral.IntegerLiteral(3535) val res = writeValue(test) assertEquals(res, "3535") } test("write StringLiteral") { - val test = StringLiteral("3535 55Hello") + val test = LigatureLiteral.StringLiteral("3535 55Hello") val res = writeValue(test) assertEquals(res, "\"3535 55Hello\"") } diff --git a/ligature-http/jvm/src/main/scala/dev/ligature/http/LigatureHttp.scala b/ligature-http/jvm/src/main/scala/dev/ligature/http/LigatureHttp.scala index e66e52d0..2f94357b 100644 --- a/ligature-http/jvm/src/main/scala/dev/ligature/http/LigatureHttp.scala +++ b/ligature-http/jvm/src/main/scala/dev/ligature/http/LigatureHttp.scala @@ -20,7 +20,7 @@ import dev.ligature.{Dataset, Identifier, Ligature, LigatureError, Statement} import dev.ligature.lig.{LigError, read, write} import dev.ligature.wander.run import dev.ligature.wander.printWanderValue -import dev.ligature.wander.parser.ScriptResult +import dev.ligature.wander.ScriptResult enum AuthMode: case None diff --git a/ligature-js/js/src/main/scala/dev/ligature/js/LigatureJS.scala b/ligature-js/js/src/main/scala/dev/ligature/js/LigatureJS.scala index 3f4ec201..29bbe478 100644 --- a/ligature-js/js/src/main/scala/dev/ligature/js/LigatureJS.scala +++ b/ligature-js/js/src/main/scala/dev/ligature/js/LigatureJS.scala @@ -4,12 +4,12 @@ package dev.ligature.js -import dev.ligature.Dataset import dev.ligature.wander.run as wanderRun import scala.scalajs.js.annotation.JSExportTopLevel +import dev.ligature.wander.common @JSExportTopLevel("run") -def run(script: String, dataset: Dataset): String = { - wanderRun(script, dataset).toString +def run(script: String): String = { + wanderRun(script, common()).toString } diff --git a/ligature-test-suite/shared/src/main/scala/dev/ligature/testsuite/LigatureTestSuite.scala b/ligature-test-suite/shared/src/main/scala/dev/ligature/testsuite/LigatureTestSuite.scala index 062e4512..15abe3f2 100644 --- a/ligature-test-suite/shared/src/main/scala/dev/ligature/testsuite/LigatureTestSuite.scala +++ b/ligature-test-suite/shared/src/main/scala/dev/ligature/testsuite/LigatureTestSuite.scala @@ -148,10 +148,10 @@ abstract class LigatureTestSuite extends CatsEffectSuite { _ <- instance.write(testDataset) { tx => for { _ <- tx.addStatement(Statement(entity1, a, entity2)) - _ <- tx.addStatement(Statement(entity1, a, IntegerLiteral(100))) - _ <- tx.addStatement(Statement(entity1, a, IntegerLiteral(101))) - _ <- tx.addStatement(Statement(entity1, a, IntegerLiteral(100))) - _ <- tx.addStatement(Statement(entity2, a, IntegerLiteral(-243729))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.IntegerLiteral(100))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.IntegerLiteral(101))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.IntegerLiteral(100))) + _ <- tx.addStatement(Statement(entity2, a, LigatureLiteral.IntegerLiteral(-243729))) } yield IO.unit } statements <- instance.query(testDataset) { tx => @@ -162,9 +162,9 @@ abstract class LigatureTestSuite extends CatsEffectSuite { res, Set( Statement(entity1, a, entity2), - Statement(entity1, a, IntegerLiteral(100)), - Statement(entity1, a, IntegerLiteral(101)), - Statement(entity2, a, IntegerLiteral(-243729)) + Statement(entity1, a, LigatureLiteral.IntegerLiteral(100)), + Statement(entity1, a, LigatureLiteral.IntegerLiteral(101)), + Statement(entity2, a, LigatureLiteral.IntegerLiteral(-243729)) ) ) } @@ -176,10 +176,10 @@ abstract class LigatureTestSuite extends CatsEffectSuite { _ <- instance.write(testDataset) { tx => for { _ <- tx.addStatement(Statement(entity1, a, entity2)) - _ <- tx.addStatement(Statement(entity1, a, StringLiteral("text"))) - _ <- tx.addStatement(Statement(entity1, a, StringLiteral("text2"))) - _ <- tx.addStatement(Statement(entity1, a, StringLiteral("text"))) - _ <- tx.addStatement(Statement(entity2, a, StringLiteral("text"))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.StringLiteral("text"))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.StringLiteral("text2"))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.StringLiteral("text"))) + _ <- tx.addStatement(Statement(entity2, a, LigatureLiteral.StringLiteral("text"))) } yield IO.unit } statements <- instance.query(testDataset) { tx => @@ -190,9 +190,9 @@ abstract class LigatureTestSuite extends CatsEffectSuite { res, Set( Statement(entity1, a, entity2), - Statement(entity1, a, StringLiteral("text")), - Statement(entity1, a, StringLiteral("text2")), - Statement(entity2, a, StringLiteral("text")) + Statement(entity1, a, LigatureLiteral.StringLiteral("text")), + Statement(entity1, a, LigatureLiteral.StringLiteral("text2")), + Statement(entity2, a, LigatureLiteral.StringLiteral("text")) ) ) } @@ -266,17 +266,17 @@ abstract class LigatureTestSuite extends CatsEffectSuite { _ <- instance.createDataset(testDataset) _ <- instance.write(testDataset) { tx => for { - _ <- tx.addStatement(Statement(entity1, a, StringLiteral("hello"))) - _ <- tx.addStatement(Statement(entity1, a, StringLiteral("hello"))) - _ <- tx.addStatement(Statement(entity2, a, StringLiteral("hello"))) - _ <- tx.removeStatement(Statement(entity1, a, StringLiteral("hello"))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.StringLiteral("hello"))) + _ <- tx.addStatement(Statement(entity1, a, LigatureLiteral.StringLiteral("hello"))) + _ <- tx.addStatement(Statement(entity2, a, LigatureLiteral.StringLiteral("hello"))) + _ <- tx.removeStatement(Statement(entity1, a, LigatureLiteral.StringLiteral("hello"))) } yield () } statements <- instance.query(testDataset) { tx => tx.allStatements().compile.toList } } yield statements.toSet - assertIO(res, Set(Statement(entity2, a, StringLiteral("hello")))) + assertIO(res, Set(Statement(entity2, a, LigatureLiteral.StringLiteral("hello")))) } // test("allow canceling WriteTx by throwing exception") { @@ -312,13 +312,13 @@ abstract class LigatureTestSuite extends CatsEffectSuite { _ <- instance.write(testDataset) { tx => for { _ <- tx.addStatement( - Statement(entity1, a, StringLiteral("Hello")) + Statement(entity1, a, LigatureLiteral.StringLiteral("Hello")) ) _ <- tx.addStatement(Statement(entity2, a, entity1)) _ <- tx.addStatement(Statement(entity2, a, entity3)) _ <- tx.addStatement(Statement(entity3, b, entity2)) _ <- tx.addStatement( - Statement(entity3, b, StringLiteral("Hello")) + Statement(entity3, b, LigatureLiteral.StringLiteral("Hello")) ) } yield () } @@ -327,11 +327,11 @@ abstract class LigatureTestSuite extends CatsEffectSuite { all <- tx.matchStatements().compile.toList as <- tx.matchStatements(None, Some(a)).compile.toList hellos <- tx - .matchStatements(None, None, Some(StringLiteral("Hello"))) + .matchStatements(None, None, Some(LigatureLiteral.StringLiteral("Hello"))) .compile .toList helloa <- tx - .matchStatements(None, Some(a), Some(StringLiteral("Hello"))) + .matchStatements(None, Some(a), Some(LigatureLiteral.StringLiteral("Hello"))) .compile .toList } yield (all.toSet, as.toSet, hellos.toSet, helloa.toSet) @@ -341,17 +341,17 @@ abstract class LigatureTestSuite extends CatsEffectSuite { assertEquals( all, Set( - Statement(entity1, a, StringLiteral("Hello")), + Statement(entity1, a, LigatureLiteral.StringLiteral("Hello")), Statement(entity2, a, entity1), Statement(entity2, a, entity3), Statement(entity3, b, entity2), - Statement(entity3, b, StringLiteral("Hello")) + Statement(entity3, b, LigatureLiteral.StringLiteral("Hello")) ) ) assertEquals( as, Set( - Statement(entity1, a, StringLiteral("Hello")), + Statement(entity1, a, LigatureLiteral.StringLiteral("Hello")), Statement(entity2, a, entity1), Statement(entity2, a, entity3) ) @@ -359,14 +359,14 @@ abstract class LigatureTestSuite extends CatsEffectSuite { assertEquals( hellos, Set( - Statement(entity1, a, StringLiteral("Hello")), - Statement(entity3, b, StringLiteral("Hello")) + Statement(entity1, a, LigatureLiteral.StringLiteral("Hello")), + Statement(entity3, b, LigatureLiteral.StringLiteral("Hello")) ) ) assertEquals( helloa, Set( - Statement(entity1, a, StringLiteral("Hello")) + Statement(entity1, a, LigatureLiteral.StringLiteral("Hello")) ) ) } diff --git a/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusQueryTx.scala b/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusQueryTx.scala index de3fec00..90ea8803 100644 --- a/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusQueryTx.scala +++ b/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusQueryTx.scala @@ -44,7 +44,7 @@ class XodusQueryTx( Option(result) } - private def lookupStringLiteral(stringLiteral: StringLiteral): Option[ByteIterable] = { + private def lookupStringLiteral(stringLiteral: LigatureLiteral.StringLiteral): Option[ByteIterable] = { val store = xodusOperations.openStore(tx, LigatureStore.StringToIdStore) val result = store.get( tx, @@ -64,11 +64,11 @@ class XodusQueryTx( Array(ByteBinding.byteToEntry(LigatureValueType.Identifier.id), id) ) ) - case stringLiteral: StringLiteral => + case stringLiteral: LigatureLiteral.StringLiteral => lookupStringLiteral(stringLiteral).map(id => CompoundByteIterable(Array(ByteBinding.byteToEntry(LigatureValueType.String.id), id)) ) - case integerLiteral: IntegerLiteral => + case integerLiteral: LigatureLiteral.IntegerLiteral => Some( CompoundByteIterable( Array( @@ -80,11 +80,11 @@ class XodusQueryTx( } } - private def lookupStringLiteral(internalIdentifier: ByteIterable): StringLiteral = + private def lookupStringLiteral(internalIdentifier: ByteIterable): LigatureLiteral.StringLiteral = val idToStringStore = xodusOperations.openStore(tx, LigatureStore.IdToStringStore) val result = idToStringStore.get(tx, CompoundByteIterable(Array(datasetID, internalIdentifier))) if (result != null) { - StringLiteral(StringBinding.entryToString(result)) + LigatureLiteral.StringLiteral(StringBinding.entryToString(result)) } else { ??? } @@ -92,7 +92,7 @@ class XodusQueryTx( private def constructValue(valueTypeId: Byte, valueContent: ByteIterable): Value = LigatureValueType.getValueType(valueTypeId) match { case LigatureValueType.Identifier => lookupIdentifier(valueContent) - case LigatureValueType.Integer => IntegerLiteral(LongBinding.entryToLong(valueContent)) + case LigatureValueType.Integer => LigatureLiteral.IntegerLiteral(LongBinding.entryToLong(valueContent)) case LigatureValueType.String => lookupStringLiteral(valueContent) case LigatureValueType.Bytes => ??? } diff --git a/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusWriteTx.scala b/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusWriteTx.scala index bbd29eda..1bb24085 100644 --- a/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusWriteTx.scala +++ b/ligature-xodus/jvm/src/main/scala/dev/ligature/xodus/XodusWriteTx.scala @@ -44,7 +44,7 @@ class XodusWriteTx( internalId } - private def lookupStringLiteral(literal: StringLiteral): Option[ByteIterable] = + private def lookupStringLiteral(literal: LigatureLiteral.StringLiteral): Option[ByteIterable] = val stringToIdStore = xodusOperations.openStore(tx, LigatureStore.StringToIdStore) val encodedString = CompoundByteIterable( Array(datasetID, StringBinding.stringToEntry(literal.value)) @@ -53,7 +53,7 @@ class XodusWriteTx( Option(result) // TODO this function might be able to be merged with lookupOrCreateIdentifier - private def lookupOrCreateStringLiteral(literal: StringLiteral): ByteIterable = + private def lookupOrCreateStringLiteral(literal: LigatureLiteral.StringLiteral): ByteIterable = val stringToIdStore = xodusOperations.openStore(tx, LigatureStore.StringToIdStore) val encodedString = StringBinding.stringToEntry(literal.value) val encodedStringWithDataset = CompoundByteIterable(Array(datasetID, encodedString)) @@ -87,14 +87,14 @@ class XodusWriteTx( ) ) temp - case stringLiteral: StringLiteral => + case stringLiteral: LigatureLiteral.StringLiteral => CompoundByteIterable( Array( ByteBinding.byteToEntry(LigatureValueType.String.id), lookupOrCreateStringLiteral(stringLiteral) ) ) - case integerLiteral: IntegerLiteral => + case integerLiteral: LigatureLiteral.IntegerLiteral => CompoundByteIterable( Array( ByteBinding.byteToEntry(LigatureValueType.Integer.id), @@ -215,7 +215,7 @@ class XodusWriteTx( ) ) } - case stringLiteral: StringLiteral => + case stringLiteral: LigatureLiteral.StringLiteral => lookupStringLiteral(stringLiteral) match { case None => None case Some(stringId) => @@ -225,7 +225,7 @@ class XodusWriteTx( ) ) } - case IntegerLiteral(value) => + case LigatureLiteral.IntegerLiteral(value) => Some(LongBinding.longToEntry(value)) // TODO needs value type } @@ -311,12 +311,12 @@ class XodusWriteTx( value match { case identifier: Identifier => checkAndRemoveIdentifier(identifier, valueEncoded.subIterable(1, 8)) - case stringLiteral: StringLiteral => + case stringLiteral: LigatureLiteral.StringLiteral => val stringToIdStore = xodusOperations.openStore(tx, LigatureStore.StringToIdStore) val idToStringStore = xodusOperations.openStore(tx, LigatureStore.IdToStringStore) stringToIdStore.delete(tx, StringBinding.stringToEntry(stringLiteral.value)) idToStringStore.delete(tx, valueEncoded.subIterable(1, 8)) - case _: IntegerLiteral => () + case _: LigatureLiteral.IntegerLiteral => () // TODO support bytes } }