diff --git a/api/aqua-api/.js/src/main/scala/api/types/InputTypes.scala b/api/aqua-api/.js/src/main/scala/api/types/InputTypes.scala index 7d892f836..381541f0d 100644 --- a/api/aqua-api/.js/src/main/scala/api/types/InputTypes.scala +++ b/api/aqua-api/.js/src/main/scala/api/types/InputTypes.scala @@ -4,7 +4,7 @@ import aqua.api.AquaAPIConfig import aqua.api.TargetType.* import aqua.js.{FunctionDefJs, ServiceDefJs} import aqua.model.transform.TransformConfig -import cats.data.Validated.{invalidNec, validNec, Invalid, Valid} +import cats.data.Validated.{invalidNec, validNec} import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec} import scala.scalajs.js diff --git a/model/inline/src/main/scala/aqua/model/inline/raw/CallArrowRawInliner.scala b/model/inline/src/main/scala/aqua/model/inline/raw/CallArrowRawInliner.scala index b3a4a4735..0007bd190 100644 --- a/model/inline/src/main/scala/aqua/model/inline/raw/CallArrowRawInliner.scala +++ b/model/inline/src/main/scala/aqua/model/inline/raw/CallArrowRawInliner.scala @@ -60,6 +60,7 @@ object CallArrowRawInliner extends RawInliner[CallArrowRaw] with Logging { vars -> Inline( ListMap.empty, Chain.one( + // Leave meta information in tree after inlining MetaModel .CallArrowModel(fn.funcName) .wrap( diff --git a/model/inline/src/test/scala/aqua/model/inline/ArrowInlinerSpec.scala b/model/inline/src/test/scala/aqua/model/inline/ArrowInlinerSpec.scala index 323d3bab5..2ca4f0388 100644 --- a/model/inline/src/test/scala/aqua/model/inline/ArrowInlinerSpec.scala +++ b/model/inline/src/test/scala/aqua/model/inline/ArrowInlinerSpec.scala @@ -9,10 +9,8 @@ import cats.syntax.show.* import cats.data.{Chain, NonEmptyList, NonEmptyMap} import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -import aqua.raw.value.ValueRaw -import aqua.raw.value.CallArrowRaw -import aqua.raw.arrow.FuncRaw -import aqua.raw.arrow.ArrowRaw +import aqua.raw.value.{CallArrowRaw, ValueRaw} +import aqua.raw.arrow.{ArrowRaw, FuncRaw} class ArrowInlinerSpec extends AnyFlatSpec with Matchers { @@ -37,7 +35,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { model.equalsOrShowDiff( CallServiceModel( - LiteralModel("\"dumb_srv_id\"", LiteralType.string), + LiteralModel.liftString("dumb_srv_id"), "dumb", CallModel(Nil, Nil) ).leaf @@ -126,7 +124,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { CallModel.Export(canonModel.name, canonModel.`type`) ).leaf, CallServiceModel( - LiteralModel("\"test-service\"", LiteralType.string), + LiteralModel.liftString("test-service"), "some-call", CallModel(canonModel :: Nil, Nil) ).leaf @@ -221,7 +219,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { model.equalsOrShowDiff( RestrictionModel(streamVar.name, true).wrap( CallServiceModel( - LiteralModel("\"test-service\"", LiteralType.string), + LiteralModel.liftString("test-service"), "some-call", CallModel(streamModel :: Nil, Nil) ).leaf @@ -306,7 +304,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { .CallArrowModel(innerName) .wrap( CallServiceModel( - LiteralModel("\"test-service\"", LiteralType.string), + LiteralModel.liftString("test-service"), "get_records", CallModel(Nil, CallModel.Export(recordsModel.name, recordsModel.`type`) :: Nil) ).leaf @@ -314,7 +312,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { SeqModel.wrap( CanonicalizeModel(recordsModel, CallModel.Export(canonModel.name, canonType)).leaf, CallServiceModel( - LiteralModel("\"callbackSrv\"", LiteralType.string), + LiteralModel.liftString("callbackSrv"), "response", CallModel(canonModel :: Nil, Nil) ).leaf @@ -469,7 +467,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { /** * func inner() -> u16: - * res = 42 + * res = 42 * <- res * * func outer() -> u16: @@ -1051,7 +1049,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { model.equalsOrShowDiff( SeqModel.wrap( CallServiceModel( - LiteralModel("\"getSrv\"", LiteralType.string), + LiteralModel.liftString("getSrv"), "getObj", CallModel(Nil, CallModel.Export(objectVar.name, objectVar.`type`) :: Nil) ).leaf, @@ -1061,7 +1059,7 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { SeqModel.wrap( FlattenModel(ValueModel.fromRaw(objectVarLambda), flattenObject.name).leaf, CallServiceModel( - LiteralModel("\"callbackSrv\"", LiteralType.string), + LiteralModel.liftString("callbackSrv"), "response", CallModel(ValueModel.fromRaw(flattenObject) :: Nil, Nil) ).leaf @@ -1152,12 +1150,12 @@ class ArrowInlinerSpec extends AnyFlatSpec with Matchers { model.equalsOrShowDiff( SeqModel.wrap( CallServiceModel( - LiteralModel("\"getSrv\"", LiteralType.string), + LiteralModel.liftString("getSrv"), "getArr", CallModel(Nil, CallModel.Export(argArray.name, argArray.`type`) :: Nil) ).leaf, CallServiceModel( - LiteralModel("\"getSrv\"", LiteralType.string), + LiteralModel.liftString("getSrv"), "getIdx", CallModel(Nil, CallModel.Export(idxVar.name, idxVar.`type`) :: Nil) ).leaf diff --git a/model/src/main/scala/aqua/model/OpModel.scala b/model/src/main/scala/aqua/model/OpModel.scala index 75446336e..ab55a693b 100644 --- a/model/src/main/scala/aqua/model/OpModel.scala +++ b/model/src/main/scala/aqua/model/OpModel.scala @@ -39,7 +39,16 @@ object OpModel extends TreeNodeCompanion[OpModel] { } } +/** + * Meta information embedded in a tree + */ enum MetaModel extends OpModel { + + /** + * Wraps subtree that was produced after inlining arrow + * + * @param name Name of arrow inlined + */ case CallArrowModel(name: String) override def wrap(children: Tree*): Tree = diff --git a/model/transform/src/main/scala/aqua/model/transform/funcop/OpTransform.scala b/model/transform/src/main/scala/aqua/model/transform/funcop/OpTransform.scala index 046db0932..0e108db50 100644 --- a/model/transform/src/main/scala/aqua/model/transform/funcop/OpTransform.scala +++ b/model/transform/src/main/scala/aqua/model/transform/funcop/OpTransform.scala @@ -6,7 +6,15 @@ import cats.data.Chain import cats.free.Cofree import cats.Eval +/** + * Base type for [[OpModel.Tree]] -> [[OpModel.Tree]] transformation + */ trait OpTransform { + + /** + * Transformation step + * (node, child results) => node result + */ def folder: OpTransform.OpFolder def apply(tree: OpModel.Tree): Eval[OpModel.Tree] =