-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
547 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
modules/bootstrapped/src/generated/smithy4s/example/_package/MyPackageStringTrait.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package smithy4s.example._package | ||
|
||
import smithy4s.Hints | ||
import smithy4s.Newtype | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.schema.Schema.bijection | ||
import smithy4s.schema.Schema.recursive | ||
import smithy4s.schema.Schema.string | ||
|
||
object MyPackageStringTrait extends Newtype[String] { | ||
val id: ShapeId = ShapeId("smithy4s.example.package", "MyPackageStringTrait") | ||
val hints: Hints = Hints( | ||
smithy.api.Trait(selector = None, structurallyExclusive = None, conflicts = None, breakingChanges = None), | ||
).lazily | ||
val underlyingSchema: Schema[String] = string.withId(id).addHints(hints) | ||
implicit val schema: Schema[MyPackageStringTrait] = recursive(bijection(underlyingSchema, asBijection)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
modules/bootstrapped/src/generated/smithy4s/example/collision/Class.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package smithy4s.example.collision | ||
|
||
import smithy4s.Hints | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.ShapeTag | ||
import smithy4s.schema.Schema.constant | ||
import smithy4s.schema.Schema.recursive | ||
import smithy4s.schema.Schema.union | ||
|
||
sealed trait Class extends scala.Product with scala.Serializable { self => | ||
@inline final def widen: Class = this | ||
def $ordinal: Int | ||
|
||
object project { | ||
def _package: Option[Class.AdtStruct] = Class.AdtStruct.alt.project.lift(self) | ||
} | ||
|
||
def accept[A](visitor: Class.Visitor[A]): A = this match { | ||
case value: Class.AdtStruct => visitor._package(value) | ||
} | ||
} | ||
object Class extends ShapeTag.Companion[Class] { | ||
|
||
def adtStruct():AdtStruct = AdtStruct() | ||
|
||
val id: ShapeId = ShapeId("smithy4s.example.collision", "class") | ||
|
||
val hints: Hints = Hints( | ||
smithy.api.Trait(selector = None, structurallyExclusive = None, conflicts = None, breakingChanges = None), | ||
).lazily | ||
|
||
final case class AdtStruct() extends Class { | ||
def $ordinal: Int = 0 | ||
} | ||
|
||
object AdtStruct { | ||
val id: ShapeId = ShapeId("smithy4s.example.collision", "AdtStruct") | ||
|
||
val hints: Hints = Hints.empty | ||
|
||
|
||
val schema: Schema[AdtStruct] = constant(AdtStruct()).withId(id).addHints(hints) | ||
|
||
val alt = schema.oneOf[Class]("package") | ||
} | ||
|
||
|
||
trait Visitor[A] { | ||
def _package(value: Class.AdtStruct): A | ||
} | ||
|
||
object Visitor { | ||
trait Default[A] extends Visitor[A] { | ||
def default: A | ||
def _package(value: Class.AdtStruct): A = default | ||
} | ||
} | ||
|
||
implicit val schema: Schema[Class] = recursive(union( | ||
Class.AdtStruct.alt, | ||
){ | ||
_.$ordinal | ||
}.withId(id).addHints(hints)) | ||
} |
17 changes: 17 additions & 0 deletions
17
modules/bootstrapped/src/generated/smithy4s/example/collision/ReservedNameUnionTrait.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package smithy4s.example.collision | ||
|
||
import smithy4s.Hints | ||
import smithy4s.Newtype | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.schema.Schema.bijection | ||
import smithy4s.schema.Schema.string | ||
|
||
object ReservedNameUnionTrait extends Newtype[java.lang.String] { | ||
val id: ShapeId = ShapeId("smithy4s.example.collision", "ReservedNameUnionTrait") | ||
val hints: Hints = Hints( | ||
smithy4s.example.collision.Class.AdtStruct().widen, | ||
).lazily | ||
val underlyingSchema: Schema[java.lang.String] = string.withId(id).addHints(hints) | ||
implicit val schema: Schema[ReservedNameUnionTrait] = bijection(underlyingSchema, asBijection) | ||
} |
17 changes: 17 additions & 0 deletions
17
...es/bootstrapped/src/generated/smithy4s/example/collision/TestReservedNamespaceTrait.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package smithy4s.example.collision | ||
|
||
import smithy4s.Hints | ||
import smithy4s.Newtype | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.schema.Schema.bijection | ||
import smithy4s.schema.Schema.string | ||
|
||
object TestReservedNamespaceTrait extends Newtype[java.lang.String] { | ||
val id: ShapeId = ShapeId("smithy4s.example.collision", "TestReservedNamespaceTrait") | ||
val hints: Hints = Hints( | ||
smithy4s.example._package.MyPackageStringTrait("test"), | ||
).lazily | ||
val underlyingSchema: Schema[java.lang.String] = string.withId(id).addHints(hints) | ||
implicit val schema: Schema[TestReservedNamespaceTrait] = bijection(underlyingSchema, asBijection) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
modules/codegen-plugin/src/sbt-test/codegen-plugin/cross-builds/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
lazy val root = (project in file(".")) | ||
.enablePlugins(Smithy4sCodegenPlugin) | ||
.settings( | ||
crossScalaVersions := Seq("2.13.15", "3.3.3"), | ||
libraryDependencies ++= Seq( | ||
"com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value | ||
) | ||
) |
1 change: 1 addition & 0 deletions
1
modules/codegen-plugin/src/sbt-test/codegen-plugin/cross-builds/project/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=1.8.0 |
9 changes: 9 additions & 0 deletions
9
modules/codegen-plugin/src/sbt-test/codegen-plugin/cross-builds/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sys.props.get("plugin.version") match { | ||
case Some(x) => | ||
addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % x) | ||
case _ => | ||
sys.error( | ||
"""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
...les/codegen-plugin/src/sbt-test/codegen-plugin/cross-builds/src/main/smithy/simple.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace smithy4s.example | ||
|
||
structure Simple {} |
19 changes: 19 additions & 0 deletions
19
modules/codegen-plugin/src/sbt-test/codegen-plugin/cross-builds/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# generate for Scala 2.13 | ||
> ++ 2.13 | ||
> compile | ||
|
||
$ exists target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy | ||
$ exists target/scala-2.13/src_managed/main/smithy4s/smithy4s/example/Simple.scala | ||
|
||
> ++ 3 | ||
> compile | ||
|
||
$ exists target/scala-3.3.3/src_managed/main/smithy/generated-metadata.smithy | ||
$ exists target/scala-3.3.3/src_managed/main/smithy4s/smithy4s/example/Simple.scala | ||
|
||
# switch back to Scala 2.13 and compile again; codegen should not happen a second time | ||
> ++ 2.13 | ||
> compile | ||
|
||
$ newer target/scala-3.3.3/src_managed/main/smithy/generated-metadata.smithy target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy | ||
$ newer target/scala-3.3.3/src_managed/main/smithy4s/smithy4s/example/Simple.scala target/scala-2.13/src_managed/main/smithy4s/smithy4s/example/Simple.scala |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.