Skip to content

Commit

Permalink
Update scalafmt-core to 3.8.4 (#1376)
Browse files Browse the repository at this point in the history
* Update scalafmt-core to 3.8.4

* Reformat with scalafmt 3.8.4

Executed command: scalafmt --non-interactive

* Add 'Reformat with scalafmt 3.8.4' to .git-blame-ignore-revs
  • Loading branch information
vigoo authored Jan 13, 2025
1 parent 15f1b55 commit ab244f4
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 54 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# Scala Steward: Reformat with scalafmt 3.7.1
4d0c588d8af857842380b92a6b065803003463fa

# Scala Steward: Reformat with scalafmt 3.8.4
bffde1d51e4893ad0dcfb734fe314a75fc46566f
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.8.3
version = 3.8.4

runner.dialect = scala213source3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ object DynamoDbTests extends ZIOSpecDefault with Logging with Retries {
.flatMap { tableName =>
for {
_ <- Console.printLine(s"Deleting table $tableName").ignore
_ <- DynamoDb.deleteTable(DeleteTableRequest(TableArn(TableName.unwrap(tableName))))
_ <- DynamoDb.deleteTable(
DeleteTableRequest(TableArn(TableName.unwrap(tableName)))
)
} yield ()
}
.provideEnvironment(ZEnvironment(dynamodb))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ trait GeneratorBase {
if (
TypeMapping
.isBuiltIn(model.shapeName) ||
TypeMapping.resolvedToBuiltIn(wrapperType) ||
isBlacklistedNewtype(wrapperType)
TypeMapping.resolvedToBuiltIn(wrapperType) ||
isBlacklistedNewtype(wrapperType)
) {
TypeMapping.toJavaType(model).map { javaType =>
q"""$term : ${javaType.typ}"""
Expand Down Expand Up @@ -131,13 +131,14 @@ trait GeneratorBase {
case ModelType.Exception =>
ZIO.succeed(
q"""${model.generatedType.term}.wrap($term)"""
) case ModelType.Document =>
)
case ModelType.Document =>
ZIO.succeed(term)
case _ =>
if (
TypeMapping.isBuiltIn(model.shapeName) ||
TypeMapping.resolvedToBuiltIn(model.generatedType) ||
isBlacklistedNewtype(model.generatedType)
TypeMapping.resolvedToBuiltIn(model.generatedType) ||
isBlacklistedNewtype(model.generatedType)
)
ZIO.succeed(q"""$term: ${model.generatedType.typ}""")
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ trait ServiceModelGenerator {
models <- getModels
excluded = Option(models.customizationConfig.getShapeModifiers)
.map(
_.asScala.collect {
case (name, modifier) if modifier.isExcludeShape => name
}.toSet
_.asScala
.collect {
case (name, modifier) if modifier.isExcludeShape => name
}
.toSet
)
.getOrElse(Set.empty)

Expand Down Expand Up @@ -72,11 +74,11 @@ trait ServiceModelGenerator {

ZIO.succeed(members.filterNot { case (memberName, member) =>
globalExcludes.contains(memberName.toLowerCase) ||
localExcludes.contains(memberName.toLowerCase) ||
member.isStreaming || {
val shape = models.serviceModel().getShape(member.getShape)
shape.isStreaming || shape.isEventstream
}
localExcludes.contains(memberName.toLowerCase) ||
member.isStreaming || {
val shape = models.serviceModel().getShape(member.getShape)
shape.isStreaming || shape.isEventstream
}
})
}
}
Expand Down Expand Up @@ -284,10 +286,10 @@ trait ServiceModelGenerator {
None,
code = List(
q"""object ${wrapperType.termName} extends ${Types
.subtype(underlyingType)
.init}""",
.subtype(underlyingType)
.init}""",
q"""type ${wrapperType.typName} = ${Type
.Select(wrapperType.term, Type.Name("Type"))}"""
.Select(wrapperType.term, Type.Name("Type"))}"""
),
wrapperType
)
Expand Down Expand Up @@ -366,16 +368,16 @@ trait ServiceModelGenerator {
getterInterface =
q"""def $pureGetterNameTerm: ${memberRoType.typ}""",
getterImplementation = q"""override val ${Pat.Var(
pureGetterNameTerm
)}: ${memberRoType.typ} = $wrappedGet""",
pureGetterNameTerm
)}: ${memberRoType.typ} = $wrappedGet""",
zioGetterImplementation =
q"""def $effectualGetterNameTerm: ${Types
.zio(
ScalaType.any,
ScalaType.nothing,
memberRoType
)
.typ} = ZIO.succeed($pureGetterNameTerm)""",
.zio(
ScalaType.any,
ScalaType.nothing,
memberRoType
)
.typ} = ZIO.succeed($pureGetterNameTerm)""",
applyToBuilder = builder =>
q"""$builder.$fluentSetter($unwrappedGet)"""
)
Expand All @@ -395,34 +397,35 @@ trait ServiceModelGenerator {
toEditable =>
ModelFieldFragments(
paramDef = param"""$pureGetterNameTerm: ${Types
.optional(memberType)
.typ} = ${Types.optionalAbsent.term}""",
.optional(memberType)
.typ} = ${Types.optionalAbsent.term}""",
getterCall =
q"""$pureGetterNameTerm.map(value => $toEditable)""",
getterInterface =
q"""def ${pureGetterNameTerm}: ${Types
.optional(memberRoType)
.typ}""",
getterImplementation =
if (wrappedGet == valueTerm) {
q"""override val ${Pat
.optional(memberRoType)
.typ}""",
getterImplementation = if (
wrappedGet == valueTerm
) {
q"""override val ${Pat
.Var(pureGetterNameTerm)}: ${Types
.optional(memberRoType)
.typ} = ${Types.optionalFromNullable}($get)"""
} else {
q"""override val ${Pat
} else {
q"""override val ${Pat
.Var(pureGetterNameTerm)}: ${Types
.optional(memberRoType)
.typ} = ${Types.optionalFromNullable}($get).map(value => $wrappedGet)"""
},
},
zioGetterImplementation =
q"""def $effectualGetterNameTerm: ${Types
.zio(
ScalaType.any,
Types.awsError,
memberRoType
)
.typ} = ${Types.awsError.term}.unwrapOptionField($propertyNameLit, $pureGetterNameTerm)""",
.zio(
ScalaType.any,
Types.awsError,
memberRoType
)
.typ} = ${Types.awsError.term}.unwrapOptionField($propertyNameLit, $pureGetterNameTerm)""",
applyToBuilder = builder =>
q"""$builder.optionallyWith($pureGetterNameTerm.map(value => $unwrappedGet))(_.$fluentSetter)"""
)
Expand All @@ -441,17 +444,18 @@ trait ServiceModelGenerator {
case (term, fieldFragments) =>
fieldFragments.applyToBuilder(term)
}
build = if (isException) {
q"""$builderChain.build().asInstanceOf[${javaType.typ}]"""
} else {
q"""$builderChain.build()"""
}
build =
if (isException) {
q"""$builderChain.build().asInstanceOf[${javaType.typ}]"""
} else {
q"""$builderChain.build()"""
}
} yield ModelWrapper(
fileName = Some(m.generatedType.name),
code = List(
q"""final case class ${m.generatedType.typName}(..${fields.map(
_.paramDef
)}) {
_.paramDef
)}) {
def buildAwsValue(): ${javaType.typ} = {
import ${m.generatedType.termName}.zioAwsBuilderHelper.BuilderOps
$build
Expand All @@ -461,11 +465,11 @@ trait ServiceModelGenerator {
}""",
q"""object ${m.generatedType.termName} {
private lazy val zioAwsBuilderHelper: ${Types
.builderHelper(javaType)
.typ} = ${Types.builderHelper_.term}.apply
.builderHelper(javaType)
.typ} = ${Types.builderHelper_.term}.apply
trait ${readOnlyType.typName} {
def asEditable: ${m.generatedType.typ} = ${m.generatedType.term}(..${fields
.map(_.getterCall)})
.map(_.getterCall)})
..${fields.map(_.getterInterface)}
..${fields.map(_.zioGetterImplementation)}
}
Expand Down Expand Up @@ -521,8 +525,8 @@ trait ServiceModelGenerator {
} yield ModelWrapper(
fileName = None,
code = List(q"""type ${m.generatedType.typName} = ${ScalaType
.map(keyType, valueType)
.typ}"""),
.map(keyType, valueType)
.typ}"""),
generatedType = m.generatedType
)
}
Expand Down

0 comments on commit ab244f4

Please sign in to comment.