Skip to content

Commit 08260de

Browse files
committed
Reformat with scalafmt 3.9.9
Executed command: scalafmt --non-interactive
1 parent 7075b6f commit 08260de

File tree

65 files changed

+1744
-1277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1744
-1277
lines changed

benchmarks/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lazy val root = project
1212
crossScalaVersions := Seq(Scala213, Scala212),
1313
scalaVersion := Scala213,
1414
Compile / PB.protocVersion := "-v" + ProtobufJavaVersion,
15-
Compile / PB.targets := Seq(
15+
Compile / PB.targets := Seq(
1616
PB.gens.java(ProtobufJavaVersion) -> (Compile / sourceManaged).value / "protos",
1717
scalapb.gen(javaConversions = true) -> (Compile / sourceManaged).value / "protos"
1818
),

build.sbt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
153153
(protocCacheCoursier % "test").cross(CrossVersion.for3Use2_13),
154154
scalaTest.value % "test"
155155
),
156-
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
156+
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
157157
mimaBinaryIssueFilters := Seq(
158158
ProblemFilters.exclude[ReversedMissingMethodProblem]("scalapb.options.*"),
159159
ProblemFilters.exclude[DirectMissingMethodProblem]("scalapb.compiler.GeneratorParams.*"),
@@ -165,7 +165,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
165165
"scalapb.compiler.ProtobufGenerator.generateTypeMappers"
166166
)
167167
),
168-
PB.protocVersion := protobufCompilerVersion,
168+
PB.protocVersion := protobufCompilerVersion,
169169
Compile / PB.targets := Seq(
170170
PB.gens.java(protobufCompilerVersion) -> (Compile / sourceManaged).value / "java_out"
171171
),
@@ -462,15 +462,18 @@ lazy val conformance = (projectMatrix in file("conformance"))
462462
),
463463
codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value,
464464
libraryDependencies ++= Seq(
465-
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1" exclude ("com.thesamet.scalapb", "scalapb-runtime_2.13")
465+
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1" exclude (
466+
"com.thesamet.scalapb",
467+
"scalapb-runtime_2.13"
468+
)
466469
),
467-
maintainer := "[email protected]",
468-
Compile / mainClass := Some("scalapb.ConformanceScala"),
469-
assemblyJarName := "conformance",
470-
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
470+
maintainer := "[email protected]",
471+
Compile / mainClass := Some("scalapb.ConformanceScala"),
472+
assemblyJarName := "conformance",
473+
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
471474
assembly / assemblyMergeStrategy := {
472475
case x if x.endsWith("module-info.class") => MergeStrategy.discard
473-
case x =>
476+
case x =>
474477
val oldStrategy = (assembly / assemblyMergeStrategy).value
475478
oldStrategy(x)
476479
}
@@ -492,7 +495,7 @@ lazy val docs = project
492495
"com.lihaoyi" %% "os-lib" % "0.5.0",
493496
"org.plotly-scala" %% "plotly-render" % "0.7.2"
494497
),
495-
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
498+
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
496499
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(
497500
lensesJVM2_12,
498501
runtimeJVM2_12,
@@ -502,7 +505,7 @@ lazy val docs = project
502505
cleanFiles += (ScalaUnidoc / unidoc / target).value,
503506
docusaurusCreateSite := docusaurusCreateSite.dependsOn(Compile / unidoc).value,
504507
docusaurusPublishGhpages := docusaurusPublishGhpages.dependsOn(Compile / unidoc).value,
505-
mdocVariables := Map(
508+
mdocVariables := Map(
506509
"scalapb" -> "0.11.11",
507510
"scalapb_latest" -> "0.11.11",
508511
"scala3" -> Dependencies.Scala3,

compiler-plugin/src/main/scala/scalapb/compiler/DescriptorImplicits.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class DescriptorImplicits private[compiler] (
209209
fd.getName match {
210210
case ("number" | "value") if fd.isInOneof => "_" + fd.getName
211211
case "serialized_size" => "_serializedSize"
212-
case x =>
212+
case x =>
213213
getNameWithFallback(x, Case.CamelCase, Appendage.Prefix)
214214
}
215215

@@ -389,7 +389,7 @@ class DescriptorImplicits private[compiler] (
389389
case FieldDescriptor.JavaType.BOOLEAN => "_root_.scala.Boolean"
390390
case FieldDescriptor.JavaType.BYTE_STRING => "_root_.com.google.protobuf.ByteString"
391391
case FieldDescriptor.JavaType.STRING => "_root_.scala.Predef.String"
392-
case FieldDescriptor.JavaType.MESSAGE =>
392+
case FieldDescriptor.JavaType.MESSAGE =>
393393
fd.getMessageType.scalaType
394394
.fullNameWithMaybeRoot(fd.getContainingType.fields.map(_.scalaName))
395395
case FieldDescriptor.JavaType.ENUM =>
@@ -511,7 +511,7 @@ class DescriptorImplicits private[compiler] (
511511
def scalaType: ScalaName = {
512512
val name = message.getName match {
513513
case "Option" => "OptionProto"
514-
case name =>
514+
case name =>
515515
if (message.isSealedOneofType) name + OneofMessageSuffix
516516
else name
517517
}
@@ -783,7 +783,7 @@ class DescriptorImplicits private[compiler] (
783783

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

10581058
/** Returns a vector with all messages (both top-level and nested) in the file. */
10591059
def allMessages: Vector[Descriptor] = {
1060-
val messages = Vector.newBuilder[Descriptor]
1060+
val messages = Vector.newBuilder[Descriptor]
10611061
def visitMessage(d: Descriptor): Unit = {
10621062
messages += d
10631063
d.getNestedTypes.asScala.foreach(visitMessage)

compiler-plugin/src/main/scala/scalapb/compiler/ExpressionBuilder.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ object ExpressionBuilder {
6868
def convertCollection(expr: String, targetType: EnclosingType): String = {
6969
val convert = List(targetType match {
7070
case Collection(_, Some(tc)) => FunctionApplication(s"${tc}.fromIteratorUnsafe")
71-
case Collection(DescriptorImplicits.ScalaVector, _) => MethodApplication("toVector")
72-
case Collection(DescriptorImplicits.ScalaSeq, _) => MethodApplication("toSeq")
73-
case Collection(DescriptorImplicits.ScalaMap, _) => MethodApplication("toMap")
71+
case Collection(DescriptorImplicits.ScalaVector, _) => MethodApplication("toVector")
72+
case Collection(DescriptorImplicits.ScalaSeq, _) => MethodApplication("toSeq")
73+
case Collection(DescriptorImplicits.ScalaMap, _) => MethodApplication("toMap")
7474
case Collection(DescriptorImplicits.ScalaIterable, _) =>
7575
FunctionApplication("_root_.scalapb.internal.compat.toIterable")
7676
case Collection(_, _) => FunctionApplication("_root_.scalapb.internal.compat.convertTo")
@@ -84,7 +84,7 @@ object ExpressionBuilder {
8484
)(e0: String, sourceType: EnclosingType, targetType: EnclosingType, mustCopy: Boolean): String = {
8585
require(sourceType != EnclosingType.None)
8686
val nontrivial: List[LiteralExpression] = es.filterNot(_.isIdentity)
87-
val needVariable =
87+
val needVariable =
8888
nontrivial
8989
.filterNot(_.isIdentity)
9090
.dropRight(1)

compiler-plugin/src/main/scala/scalapb/compiler/FieldTransformations.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private[compiler] object FieldTransformations {
7777
transformation.whenFields,
7878
ExtensionResolutionContext(currentFile, transformation.extensions)
7979
)
80-
case MatchType.EXACT => input == transformation.whenFields
80+
case MatchType.EXACT => input == transformation.whenFields
8181
case MatchType.PRESENCE =>
8282
matchPresence(
8383
input,
@@ -154,7 +154,7 @@ private[compiler] object FieldTransformations {
154154
): Seq[AuxFieldOptions] =
155155
if (transforms.isEmpty) Seq.empty
156156
else {
157-
val extensions: Set[FieldDescriptor] = fieldExtensionsForFile(f)
157+
val extensions: Set[FieldDescriptor] = fieldExtensionsForFile(f)
158158
def processFile: Seq[AuxFieldOptions] =
159159
f.getMessageTypes().asScala.flatMap(processMessage(_)).toSeq
160160

@@ -283,7 +283,7 @@ private[compiler] object FieldTransformations {
283283
): Either[String, String] = {
284284
for {
285285
fieldName <- path.headOption.toRight("Got an empty path")
286-
fd <-
286+
fd <-
287287
if (fieldName.startsWith("["))
288288
context.extensions
289289
.find(_.getFullName == fieldName.substring(1, fieldName.length() - 1))
@@ -317,7 +317,7 @@ private[compiler] object FieldTransformations {
317317
else Right(())
318318
v = if (fd.isExtension) getExtensionField(message, fd) else message.getField(fd)
319319
res <- path match {
320-
case _ :: Nil => Right(v.toString())
320+
case _ :: Nil => Right(v.toString())
321321
case _ :: tail =>
322322
if (fd.getType() == Type.MESSAGE)
323323
fieldByPath(v.asInstanceOf[Message], tail, allPath, context)

compiler-plugin/src/main/scala/scalapb/compiler/GeneratorParams.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object GeneratorParams {
4747
Right((params.copy(singleLineToProtoString = true), unrecognized))
4848
case "ascii_format_to_string" =>
4949
Right((params.copy(asciiFormatToString = true), unrecognized))
50-
case "no_lenses" => Right((params.copy(lenses = false), unrecognized))
50+
case "no_lenses" => Right((params.copy(lenses = false), unrecognized))
5151
case "retain_source_code_info" =>
5252
Right((params.copy(retainSourceCodeInfo = true), unrecognized))
5353
case "scala3_sources" =>

compiler-plugin/src/main/scala/scalapb/compiler/ParseFromGenerator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private[compiler] class ParseFromGenerator(
126126
def hexBits(n: Int): String = "0x%xL".format((0 to (n - 1)).map(i => (1L << i)).sum)
127127
val requiredFieldCount = requiredFieldMap.size
128128
val fullWords = (requiredFieldCount - 1) / 64
129-
val bits: Seq[String] = (1 to fullWords).map(_ => hexBits(64)) :+ hexBits(
129+
val bits: Seq[String] = (1 to fullWords).map(_ => hexBits(64)) :+ hexBits(
130130
requiredFieldCount - 64 * fullWords
131131
)
132132
fp.print(bits.zipWithIndex) { case (fp, (bn, index)) =>
@@ -150,7 +150,7 @@ private[compiler] class ParseFromGenerator(
150150
// since the references message may have been generated using an older version of
151151
// ScalaPB.
152152
val baseName = field.baseSingleScalaTypeName
153-
val read =
153+
val read =
154154
if (field.isRepeated)
155155
s"_root_.scalapb.LiteParser.readMessage[$baseName](_input__)"
156156
else if (usesBaseTypeInBuilder(field)) {

compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ class ProtobufGenerator(
160160
def defaultValue = field.getDefaultValue
161161

162162
val baseDefaultValue: String = field.getJavaType match {
163-
case FieldDescriptor.JavaType.INT => defaultValue.toString
164-
case FieldDescriptor.JavaType.LONG => defaultValue.toString + "L"
163+
case FieldDescriptor.JavaType.INT => defaultValue.toString
164+
case FieldDescriptor.JavaType.LONG => defaultValue.toString + "L"
165165
case FieldDescriptor.JavaType.FLOAT =>
166166
val f = defaultValue.asInstanceOf[Float]
167167
if (f.isPosInfinity) "Float.PositiveInfinity"
@@ -184,7 +184,7 @@ class ProtobufGenerator(
184184
d.asScala
185185
.map(_.toString)
186186
.mkString("_root_.com.google.protobuf.ByteString.copyFrom(Array[Byte](", ", ", "))")
187-
case FieldDescriptor.JavaType.STRING => escapeScalaString(defaultValue.asInstanceOf[String])
187+
case FieldDescriptor.JavaType.STRING => escapeScalaString(defaultValue.asInstanceOf[String])
188188
case FieldDescriptor.JavaType.MESSAGE =>
189189
field.getMessageType.scalaType
190190
.fullNameWithMaybeRoot(field.getContainingType) + ".defaultInstance"
@@ -214,7 +214,7 @@ class ProtobufGenerator(
214214
case FieldDescriptor.JavaType.BOOLEAN => MethodApplication("booleanValue")
215215
case FieldDescriptor.JavaType.BYTE_STRING => Identity
216216
case FieldDescriptor.JavaType.STRING => Identity
217-
case FieldDescriptor.JavaType.MESSAGE =>
217+
case FieldDescriptor.JavaType.MESSAGE =>
218218
FunctionApplication(field.getMessageType.scalaType.fullName + ".fromJavaProto")
219219
case FieldDescriptor.JavaType.ENUM =>
220220
if (field.getFile.isProto3)
@@ -242,7 +242,7 @@ class ProtobufGenerator(
242242
}
243243

244244
def javaFieldToScala(container: String, field: FieldDescriptor): String = {
245-
val javaHazzer = container + ".has" + field.upperJavaName
245+
val javaHazzer = container + ".has" + field.upperJavaName
246246
val upperJavaName =
247247
if (field.isEnum && field.getFile.isProto3) (field.upperJavaName + "Value")
248248
else field.upperJavaName
@@ -284,7 +284,7 @@ class ProtobufGenerator(
284284
case FieldDescriptor.JavaType.BOOLEAN => maybeBox("_root_.scala.Boolean.box")
285285
case FieldDescriptor.JavaType.BYTE_STRING => Identity
286286
case FieldDescriptor.JavaType.STRING => Identity
287-
case FieldDescriptor.JavaType.MESSAGE =>
287+
case FieldDescriptor.JavaType.MESSAGE =>
288288
FunctionApplication(field.getMessageType.scalaType.fullName + ".toJavaProto")
289289
case FieldDescriptor.JavaType.ENUM =>
290290
if (field.getFile.isProto3)
@@ -609,10 +609,10 @@ class ProtobufGenerator(
609609
).add("}")
610610
case None =>
611611
val capTypeName = Types.capitalizedType(field.getType)
612-
val sizeFunc = FunctionApplication(
612+
val sizeFunc = FunctionApplication(
613613
s"_root_.com.google.protobuf.CodedOutputStream.compute${capTypeName}SizeNoTag"
614614
)
615-
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
615+
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
616616
val fromCustom =
617617
if (field.customSingleScalaTypeName.isDefined)
618618
FunctionApplication(s"${field.typeMapper.fullName}.toBase")
@@ -722,7 +722,7 @@ class ProtobufGenerator(
722722

723723
val regularFields = message.fields.collect {
724724
case field if !field.isInOneof =>
725-
val typeName = field.scalaTypeName
725+
val typeName = field.scalaTypeName
726726
val ctorDefaultValue: Option[String] =
727727
if (field.noDefaultValueInConstructor) None
728728
else if (field.isOptional && field.supportsPresence) Some(C.None)
@@ -870,7 +870,7 @@ class ProtobufGenerator(
870870
else if (field.isRepeated) {
871871
val empty = readsEnclosing match {
872872
case EnclosingType.Collection(s, _) => s"$s.empty"
873-
case _ =>
873+
case _ =>
874874
throw new GeneratorException(
875875
"Expected a collection enclosing. Pleae report this as a bug."
876876
)
@@ -1195,7 +1195,7 @@ class ProtobufGenerator(
11951195
case Type.INT32 => ("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
11961196
case Type.FIXED64 => ("fixed64Lens", Identity, Identity)
11971197
case Type.FIXED32 => ("fixed32Lens", Identity, Identity)
1198-
case Type.BOOL =>
1198+
case Type.BOOL =>
11991199
(
12001200
"varintLens",
12011201
OperatorApplication("!= 0"),
@@ -1207,7 +1207,7 @@ class ProtobufGenerator(
12071207
MethodApplication("toStringUtf8()"),
12081208
FunctionApplication("_root_.com.google.protobuf.ByteString.copyFromUtf8")
12091209
)
1210-
case Type.GROUP => throw new RuntimeException("Not supported")
1210+
case Type.GROUP => throw new RuntimeException("Not supported")
12111211
case Type.MESSAGE =>
12121212
(
12131213
"lengthDelimitedLens",
@@ -1216,7 +1216,7 @@ class ProtobufGenerator(
12161216
),
12171217
MethodApplication(s"toByteString")
12181218
)
1219-
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
1219+
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
12201220
case Type.UINT32 =>
12211221
("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
12221222
case Type.ENUM =>
@@ -1229,7 +1229,7 @@ class ProtobufGenerator(
12291229
)
12301230
case Type.SFIXED32 => ("fixed32Lens", Identity, Identity)
12311231
case Type.SFIXED64 => ("fixed64Lens", Identity, Identity)
1232-
case Type.SINT32 =>
1232+
case Type.SINT32 =>
12331233
(
12341234
"varintLens",
12351235
MethodApplication("toInt") andThen FunctionApplication(
@@ -1262,8 +1262,8 @@ class ProtobufGenerator(
12621262
Seq(fd.getType match {
12631263
case Type.DOUBLE | Type.FIXED64 | Type.SFIXED64 => "_.readFixed64()"
12641264
case Type.FLOAT | Type.FIXED32 | Type.SFIXED32 => "_.readFixed32()"
1265-
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM |
1266-
Type.BOOL | Type.SINT32 | Type.SINT64 =>
1265+
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM | Type.BOOL |
1266+
Type.SINT32 | Type.SINT64 =>
12671267
"_.readInt64()"
12681268
case _ =>
12691269
throw new GeneratorException(s"Unexpected packable type: ${fd.getType.name()}")
@@ -1369,7 +1369,7 @@ class ProtobufGenerator(
13691369

13701370
def printMessage(printer: FunctionalPrinter, message: Descriptor): FunctionalPrinter = {
13711371
val fullName = message.scalaType.fullNameWithMaybeRoot(message)
1372-
val derives =
1372+
val derives =
13731373
if (message.derives.nonEmpty) message.derives.mkString(" derives ", ", ", "") else ""
13741374
printer
13751375
.call(new SealedOneofsGenerator(message, implicits).generateSealedOneofTrait)
@@ -1536,7 +1536,7 @@ class ProtobufGenerator(
15361536
def updateEnumValue(
15371537
enumValue: EnumValueDescriptor
15381538
): DescriptorProtos.EnumValueDescriptorProto = {
1539-
val ev = enumValue.toProto().toBuilder()
1539+
val ev = enumValue.toProto().toBuilder()
15401540
val extBuilder =
15411541
enumValue.getOptions().getExtension[Scalapb.EnumValueOptions](Scalapb.enumValue).toBuilder
15421542
assert(!extBuilder.hasScalaName || extBuilder.getScalaName == enumValue.scalaName)
@@ -1623,7 +1623,7 @@ class ProtobufGenerator(
16231623
def generateServiceFiles(file: FileDescriptor): Seq[CodeGeneratorResponse.File] = {
16241624
if (params.grpc) {
16251625
file.getServices.asScala.map { service =>
1626-
val p = new GrpcServicePrinter(service, implicits)
1626+
val p = new GrpcServicePrinter(service, implicits)
16271627
val code = scalaFileHeader(
16281628
file,
16291629
file.javaConversions && file.getMessageTypes.asScala.exists(

compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SealedOneofsGenerator(message: Descriptor, implicits: DescriptorImplicits)
2424
val oneof = message.getRealOneofs.get(0)
2525
val typeMapperName = message.sealedOneofTypeMapper.name
2626
val baseClasses = message.sealedOneofBaseClasses
27-
val derives =
27+
val derives =
2828
if (message.sealedOneofDerives.nonEmpty)
2929
s"derives ${message.sealedOneofDerives.mkString(", ")} "
3030
else ""
@@ -42,7 +42,7 @@ class SealedOneofsGenerator(message: Descriptor, implicits: DescriptorImplicits)
4242
val sealedOneofNonEmptyName = message.sealedOneofNonEmptyScalaType.nameSymbol
4343
val sealedOneofNonEmptyType = message.sealedOneofNonEmptyScalaType.fullName
4444
val sealedOneofUniversalMark = if (message.isUniversalTrait) "Any with " else ""
45-
val sealedOneofEmptyExtends =
45+
val sealedOneofEmptyExtends =
4646
(sealedOneofType +: message.sealedOneofEmptyExtendsOption).mkString(" with ")
4747

4848
fp.add(

0 commit comments

Comments
 (0)