Skip to content

Update scalafmt-core to 3.9.7 in 0.11.x #1887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 0.11.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ f84d366235b9104d60a589cff5d3aed7291c5312

# Scala Steward: Reformat with scalafmt 3.7.0
fc3306ef4aea224b3be56707f096884f43f0340a

# Scala Steward: Reformat with scalafmt 3.9.7
bae6c19a978538a0ea1bd0bea6c05d37f0be9e01
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.17
version = 3.9.7
style = defaultWithAlign
maxColumn = 100
assumeStandardLibraryStripMargin = true
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lazy val root = project
crossScalaVersions := Seq(Scala213, Scala212),
scalaVersion := Scala213,
Compile / PB.protocVersion := "-v" + ProtobufJavaVersion,
Compile / PB.targets := Seq(
Compile / PB.targets := Seq(
PB.gens.java(ProtobufJavaVersion) -> (Compile / sourceManaged).value / "protos",
scalapb.gen(javaConversions = true) -> (Compile / sourceManaged).value / "protos"
),
Expand Down
23 changes: 13 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
(protocCacheCoursier % "test").cross(CrossVersion.for3Use2_13),
scalaTest.value % "test"
),
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
mimaBinaryIssueFilters := Seq(
ProblemFilters.exclude[ReversedMissingMethodProblem]("scalapb.options.*"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scalapb.compiler.GeneratorParams.*"),
Expand All @@ -165,7 +165,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
"scalapb.compiler.ProtobufGenerator.generateTypeMappers"
)
),
PB.protocVersion := protobufCompilerVersion,
PB.protocVersion := protobufCompilerVersion,
Compile / PB.targets := Seq(
PB.gens.java(protobufCompilerVersion) -> (Compile / sourceManaged).value / "java_out"
),
Expand Down Expand Up @@ -462,15 +462,18 @@ lazy val conformance = (projectMatrix in file("conformance"))
),
codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value,
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1" exclude ("com.thesamet.scalapb", "scalapb-runtime_2.13")
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1" exclude (
"com.thesamet.scalapb",
"scalapb-runtime_2.13"
)
),
maintainer := "[email protected]",
Compile / mainClass := Some("scalapb.ConformanceScala"),
assemblyJarName := "conformance",
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
maintainer := "[email protected]",
Compile / mainClass := Some("scalapb.ConformanceScala"),
assemblyJarName := "conformance",
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
assembly / assemblyMergeStrategy := {
case x if x.endsWith("module-info.class") => MergeStrategy.discard
case x =>
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
}
Expand All @@ -492,7 +495,7 @@ lazy val docs = project
"com.lihaoyi" %% "os-lib" % "0.5.0",
"org.plotly-scala" %% "plotly-render" % "0.7.2"
),
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(
lensesJVM2_12,
runtimeJVM2_12,
Expand All @@ -502,7 +505,7 @@ lazy val docs = project
cleanFiles += (ScalaUnidoc / unidoc / target).value,
docusaurusCreateSite := docusaurusCreateSite.dependsOn(Compile / unidoc).value,
docusaurusPublishGhpages := docusaurusPublishGhpages.dependsOn(Compile / unidoc).value,
mdocVariables := Map(
mdocVariables := Map(
"scalapb" -> "0.11.11",
"scalapb_latest" -> "0.11.11",
"scala3" -> Dependencies.Scala3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class DescriptorImplicits private[compiler] (
fd.getName match {
case ("number" | "value") if fd.isInOneof => "_" + fd.getName
case "serialized_size" => "_serializedSize"
case x =>
case x =>
getNameWithFallback(x, Case.CamelCase, Appendage.Prefix)
}

Expand Down Expand Up @@ -389,7 +389,7 @@ class DescriptorImplicits private[compiler] (
case FieldDescriptor.JavaType.BOOLEAN => "_root_.scala.Boolean"
case FieldDescriptor.JavaType.BYTE_STRING => "_root_.com.google.protobuf.ByteString"
case FieldDescriptor.JavaType.STRING => "_root_.scala.Predef.String"
case FieldDescriptor.JavaType.MESSAGE =>
case FieldDescriptor.JavaType.MESSAGE =>
fd.getMessageType.scalaType
.fullNameWithMaybeRoot(fd.getContainingType.fields.map(_.scalaName))
case FieldDescriptor.JavaType.ENUM =>
Expand Down Expand Up @@ -511,7 +511,7 @@ class DescriptorImplicits private[compiler] (
def scalaType: ScalaName = {
val name = message.getName match {
case "Option" => "OptionProto"
case name =>
case name =>
if (message.isSealedOneofType) name + OneofMessageSuffix
else name
}
Expand Down Expand Up @@ -783,7 +783,7 @@ class DescriptorImplicits private[compiler] (

lazy val scalaType: ScalaName = {
val name: String = enumDescriptor.getName match {
case "Option" => "OptionEnum"
case "Option" => "OptionEnum"
case "ValueType" =>
"ValueTypeEnum" // Issue 348, conflicts with "type ValueType" in GeneratedEnumCompanion.
case n => n
Expand Down Expand Up @@ -1057,7 +1057,7 @@ class DescriptorImplicits private[compiler] (

/** Returns a vector with all messages (both top-level and nested) in the file. */
def allMessages: Vector[Descriptor] = {
val messages = Vector.newBuilder[Descriptor]
val messages = Vector.newBuilder[Descriptor]
def visitMessage(d: Descriptor): Unit = {
messages += d
d.getNestedTypes.asScala.foreach(visitMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ object ExpressionBuilder {
def convertCollection(expr: String, targetType: EnclosingType): String = {
val convert = List(targetType match {
case Collection(_, Some(tc)) => FunctionApplication(s"${tc}.fromIteratorUnsafe")
case Collection(DescriptorImplicits.ScalaVector, _) => MethodApplication("toVector")
case Collection(DescriptorImplicits.ScalaSeq, _) => MethodApplication("toSeq")
case Collection(DescriptorImplicits.ScalaMap, _) => MethodApplication("toMap")
case Collection(DescriptorImplicits.ScalaVector, _) => MethodApplication("toVector")
case Collection(DescriptorImplicits.ScalaSeq, _) => MethodApplication("toSeq")
case Collection(DescriptorImplicits.ScalaMap, _) => MethodApplication("toMap")
case Collection(DescriptorImplicits.ScalaIterable, _) =>
FunctionApplication("_root_.scalapb.internal.compat.toIterable")
case Collection(_, _) => FunctionApplication("_root_.scalapb.internal.compat.convertTo")
Expand All @@ -84,7 +84,7 @@ object ExpressionBuilder {
)(e0: String, sourceType: EnclosingType, targetType: EnclosingType, mustCopy: Boolean): String = {
require(sourceType != EnclosingType.None)
val nontrivial: List[LiteralExpression] = es.filterNot(_.isIdentity)
val needVariable =
val needVariable =
nontrivial
.filterNot(_.isIdentity)
.dropRight(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private[compiler] object FieldTransformations {
transformation.whenFields,
ExtensionResolutionContext(currentFile, transformation.extensions)
)
case MatchType.EXACT => input == transformation.whenFields
case MatchType.EXACT => input == transformation.whenFields
case MatchType.PRESENCE =>
matchPresence(
input,
Expand Down Expand Up @@ -154,7 +154,7 @@ private[compiler] object FieldTransformations {
): Seq[AuxFieldOptions] =
if (transforms.isEmpty) Seq.empty
else {
val extensions: Set[FieldDescriptor] = fieldExtensionsForFile(f)
val extensions: Set[FieldDescriptor] = fieldExtensionsForFile(f)
def processFile: Seq[AuxFieldOptions] =
f.getMessageTypes().asScala.flatMap(processMessage(_)).toSeq

Expand Down Expand Up @@ -283,7 +283,7 @@ private[compiler] object FieldTransformations {
): Either[String, String] = {
for {
fieldName <- path.headOption.toRight("Got an empty path")
fd <-
fd <-
if (fieldName.startsWith("["))
context.extensions
.find(_.getFullName == fieldName.substring(1, fieldName.length() - 1))
Expand Down Expand Up @@ -317,7 +317,7 @@ private[compiler] object FieldTransformations {
else Right(())
v = if (fd.isExtension) getExtensionField(message, fd) else message.getField(fd)
res <- path match {
case _ :: Nil => Right(v.toString())
case _ :: Nil => Right(v.toString())
case _ :: tail =>
if (fd.getType() == Type.MESSAGE)
fieldByPath(v.asInstanceOf[Message], tail, allPath, context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object GeneratorParams {
Right((params.copy(singleLineToProtoString = true), unrecognized))
case "ascii_format_to_string" =>
Right((params.copy(asciiFormatToString = true), unrecognized))
case "no_lenses" => Right((params.copy(lenses = false), unrecognized))
case "no_lenses" => Right((params.copy(lenses = false), unrecognized))
case "retain_source_code_info" =>
Right((params.copy(retainSourceCodeInfo = true), unrecognized))
case "scala3_sources" =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private[compiler] class ParseFromGenerator(
def hexBits(n: Int): String = "0x%xL".format((0 to (n - 1)).map(i => (1L << i)).sum)
val requiredFieldCount = requiredFieldMap.size
val fullWords = (requiredFieldCount - 1) / 64
val bits: Seq[String] = (1 to fullWords).map(_ => hexBits(64)) :+ hexBits(
val bits: Seq[String] = (1 to fullWords).map(_ => hexBits(64)) :+ hexBits(
requiredFieldCount - 64 * fullWords
)
fp.print(bits.zipWithIndex) { case (fp, (bn, index)) =>
Expand All @@ -150,7 +150,7 @@ private[compiler] class ParseFromGenerator(
// since the references message may have been generated using an older version of
// ScalaPB.
val baseName = field.baseSingleScalaTypeName
val read =
val read =
if (field.isRepeated)
s"_root_.scalapb.LiteParser.readMessage[$baseName](_input__)"
else if (usesBaseTypeInBuilder(field)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class ProtobufGenerator(
def defaultValue = field.getDefaultValue

val baseDefaultValue: String = field.getJavaType match {
case FieldDescriptor.JavaType.INT => defaultValue.toString
case FieldDescriptor.JavaType.LONG => defaultValue.toString + "L"
case FieldDescriptor.JavaType.INT => defaultValue.toString
case FieldDescriptor.JavaType.LONG => defaultValue.toString + "L"
case FieldDescriptor.JavaType.FLOAT =>
val f = defaultValue.asInstanceOf[Float]
if (f.isPosInfinity) "Float.PositiveInfinity"
Expand All @@ -184,7 +184,7 @@ class ProtobufGenerator(
d.asScala
.map(_.toString)
.mkString("_root_.com.google.protobuf.ByteString.copyFrom(Array[Byte](", ", ", "))")
case FieldDescriptor.JavaType.STRING => escapeScalaString(defaultValue.asInstanceOf[String])
case FieldDescriptor.JavaType.STRING => escapeScalaString(defaultValue.asInstanceOf[String])
case FieldDescriptor.JavaType.MESSAGE =>
field.getMessageType.scalaType
.fullNameWithMaybeRoot(field.getContainingType) + ".defaultInstance"
Expand Down Expand Up @@ -214,7 +214,7 @@ class ProtobufGenerator(
case FieldDescriptor.JavaType.BOOLEAN => MethodApplication("booleanValue")
case FieldDescriptor.JavaType.BYTE_STRING => Identity
case FieldDescriptor.JavaType.STRING => Identity
case FieldDescriptor.JavaType.MESSAGE =>
case FieldDescriptor.JavaType.MESSAGE =>
FunctionApplication(field.getMessageType.scalaType.fullName + ".fromJavaProto")
case FieldDescriptor.JavaType.ENUM =>
if (field.getFile.isProto3)
Expand Down Expand Up @@ -242,7 +242,7 @@ class ProtobufGenerator(
}

def javaFieldToScala(container: String, field: FieldDescriptor): String = {
val javaHazzer = container + ".has" + field.upperJavaName
val javaHazzer = container + ".has" + field.upperJavaName
val upperJavaName =
if (field.isEnum && field.getFile.isProto3) (field.upperJavaName + "Value")
else field.upperJavaName
Expand Down Expand Up @@ -284,7 +284,7 @@ class ProtobufGenerator(
case FieldDescriptor.JavaType.BOOLEAN => maybeBox("_root_.scala.Boolean.box")
case FieldDescriptor.JavaType.BYTE_STRING => Identity
case FieldDescriptor.JavaType.STRING => Identity
case FieldDescriptor.JavaType.MESSAGE =>
case FieldDescriptor.JavaType.MESSAGE =>
FunctionApplication(field.getMessageType.scalaType.fullName + ".toJavaProto")
case FieldDescriptor.JavaType.ENUM =>
if (field.getFile.isProto3)
Expand Down Expand Up @@ -609,10 +609,10 @@ class ProtobufGenerator(
).add("}")
case None =>
val capTypeName = Types.capitalizedType(field.getType)
val sizeFunc = FunctionApplication(
val sizeFunc = FunctionApplication(
s"_root_.com.google.protobuf.CodedOutputStream.compute${capTypeName}SizeNoTag"
)
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
val fromCustom =
if (field.customSingleScalaTypeName.isDefined)
FunctionApplication(s"${field.typeMapper.fullName}.toBase")
Expand Down Expand Up @@ -722,7 +722,7 @@ class ProtobufGenerator(

val regularFields = message.fields.collect {
case field if !field.isInOneof =>
val typeName = field.scalaTypeName
val typeName = field.scalaTypeName
val ctorDefaultValue: Option[String] =
if (field.noDefaultValueInConstructor) None
else if (field.isOptional && field.supportsPresence) Some(C.None)
Expand Down Expand Up @@ -870,7 +870,7 @@ class ProtobufGenerator(
else if (field.isRepeated) {
val empty = readsEnclosing match {
case EnclosingType.Collection(s, _) => s"$s.empty"
case _ =>
case _ =>
throw new GeneratorException(
"Expected a collection enclosing. Pleae report this as a bug."
)
Expand Down Expand Up @@ -1195,7 +1195,7 @@ class ProtobufGenerator(
case Type.INT32 => ("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
case Type.FIXED64 => ("fixed64Lens", Identity, Identity)
case Type.FIXED32 => ("fixed32Lens", Identity, Identity)
case Type.BOOL =>
case Type.BOOL =>
(
"varintLens",
OperatorApplication("!= 0"),
Expand All @@ -1207,7 +1207,7 @@ class ProtobufGenerator(
MethodApplication("toStringUtf8()"),
FunctionApplication("_root_.com.google.protobuf.ByteString.copyFromUtf8")
)
case Type.GROUP => throw new RuntimeException("Not supported")
case Type.GROUP => throw new RuntimeException("Not supported")
case Type.MESSAGE =>
(
"lengthDelimitedLens",
Expand All @@ -1216,7 +1216,7 @@ class ProtobufGenerator(
),
MethodApplication(s"toByteString")
)
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
case Type.UINT32 =>
("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
case Type.ENUM =>
Expand All @@ -1229,7 +1229,7 @@ class ProtobufGenerator(
)
case Type.SFIXED32 => ("fixed32Lens", Identity, Identity)
case Type.SFIXED64 => ("fixed64Lens", Identity, Identity)
case Type.SINT32 =>
case Type.SINT32 =>
(
"varintLens",
MethodApplication("toInt") andThen FunctionApplication(
Expand Down Expand Up @@ -1262,8 +1262,8 @@ class ProtobufGenerator(
Seq(fd.getType match {
case Type.DOUBLE | Type.FIXED64 | Type.SFIXED64 => "_.readFixed64()"
case Type.FLOAT | Type.FIXED32 | Type.SFIXED32 => "_.readFixed32()"
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM |
Type.BOOL | Type.SINT32 | Type.SINT64 =>
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM | Type.BOOL |
Type.SINT32 | Type.SINT64 =>
"_.readInt64()"
case _ =>
throw new GeneratorException(s"Unexpected packable type: ${fd.getType.name()}")
Expand Down Expand Up @@ -1369,7 +1369,7 @@ class ProtobufGenerator(

def printMessage(printer: FunctionalPrinter, message: Descriptor): FunctionalPrinter = {
val fullName = message.scalaType.fullNameWithMaybeRoot(message)
val derives =
val derives =
if (message.derives.nonEmpty) message.derives.mkString(" derives ", ", ", "") else ""
printer
.call(new SealedOneofsGenerator(message, implicits).generateSealedOneofTrait)
Expand Down Expand Up @@ -1536,7 +1536,7 @@ class ProtobufGenerator(
def updateEnumValue(
enumValue: EnumValueDescriptor
): DescriptorProtos.EnumValueDescriptorProto = {
val ev = enumValue.toProto().toBuilder()
val ev = enumValue.toProto().toBuilder()
val extBuilder =
enumValue.getOptions().getExtension[Scalapb.EnumValueOptions](Scalapb.enumValue).toBuilder
assert(!extBuilder.hasScalaName || extBuilder.getScalaName == enumValue.scalaName)
Expand Down Expand Up @@ -1623,7 +1623,7 @@ class ProtobufGenerator(
def generateServiceFiles(file: FileDescriptor): Seq[CodeGeneratorResponse.File] = {
if (params.grpc) {
file.getServices.asScala.map { service =>
val p = new GrpcServicePrinter(service, implicits)
val p = new GrpcServicePrinter(service, implicits)
val code = scalaFileHeader(
file,
file.javaConversions && file.getMessageTypes.asScala.exists(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SealedOneofsGenerator(message: Descriptor, implicits: DescriptorImplicits)
val oneof = message.getRealOneofs.get(0)
val typeMapperName = message.sealedOneofTypeMapper.name
val baseClasses = message.sealedOneofBaseClasses
val derives =
val derives =
if (message.sealedOneofDerives.nonEmpty)
s"derives ${message.sealedOneofDerives.mkString(", ")} "
else ""
Expand All @@ -42,7 +42,7 @@ class SealedOneofsGenerator(message: Descriptor, implicits: DescriptorImplicits)
val sealedOneofNonEmptyName = message.sealedOneofNonEmptyScalaType.nameSymbol
val sealedOneofNonEmptyType = message.sealedOneofNonEmptyScalaType.fullName
val sealedOneofUniversalMark = if (message.isUniversalTrait) "Any with " else ""
val sealedOneofEmptyExtends =
val sealedOneofEmptyExtends =
(sealedOneofType +: message.sealedOneofEmptyExtendsOption).mkString(" with ")

fp.add(
Expand Down
Loading
Loading