Skip to content

Commit 2b1a1b1

Browse files
committed
Reformat with scalafmt 3.9.9
Executed command: scalafmt --non-interactive
1 parent acf60e3 commit 2b1a1b1

File tree

66 files changed

+1745
-1278
lines changed

Some content is hidden

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

66 files changed

+1745
-1278
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
@@ -152,7 +152,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
152152
(protocCacheCoursier % "test").cross(CrossVersion.for3Use2_13),
153153
scalaTest.value % "test"
154154
),
155-
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
155+
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
156156
mimaBinaryIssueFilters := Seq(
157157
ProblemFilters.exclude[ReversedMissingMethodProblem]("scalapb.options.*"),
158158
ProblemFilters.exclude[DirectMissingMethodProblem]("scalapb.compiler.GeneratorParams.*"),
@@ -164,7 +164,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
164164
"scalapb.compiler.ProtobufGenerator.generateTypeMappers"
165165
)
166166
),
167-
PB.protocVersion := protobufCompilerVersion,
167+
PB.protocVersion := protobufCompilerVersion,
168168
Compile / PB.targets := Seq(
169169
PB.gens.java(protobufCompilerVersion) -> (Compile / sourceManaged).value / "java_out"
170170
),
@@ -461,15 +461,18 @@ lazy val conformance = (projectMatrix in file("conformance"))
461461
),
462462
codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value,
463463
libraryDependencies ++= Seq(
464-
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1" exclude ("com.thesamet.scalapb", "scalapb-runtime_2.13")
464+
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1" exclude (
465+
"com.thesamet.scalapb",
466+
"scalapb-runtime_2.13"
467+
)
465468
),
466-
maintainer := "[email protected]",
467-
Compile / mainClass := Some("scalapb.ConformanceScala"),
468-
assemblyJarName := "conformance",
469-
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
469+
maintainer := "[email protected]",
470+
Compile / mainClass := Some("scalapb.ConformanceScala"),
471+
assemblyJarName := "conformance",
472+
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
470473
assembly / assemblyMergeStrategy := {
471474
case x if x.endsWith("module-info.class") => MergeStrategy.discard
472-
case x =>
475+
case x =>
473476
val oldStrategy = (assembly / assemblyMergeStrategy).value
474477
oldStrategy(x)
475478
}
@@ -491,7 +494,7 @@ lazy val docs = project
491494
"com.lihaoyi" %% "os-lib" % "0.5.0",
492495
"org.plotly-scala" %% "plotly-render" % "0.7.2"
493496
),
494-
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
497+
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
495498
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(
496499
lensesJVM2_12,
497500
runtimeJVM2_12,
@@ -501,7 +504,7 @@ lazy val docs = project
501504
cleanFiles += (ScalaUnidoc / unidoc / target).value,
502505
docusaurusCreateSite := docusaurusCreateSite.dependsOn(Compile / unidoc).value,
503506
docusaurusPublishGhpages := docusaurusPublishGhpages.dependsOn(Compile / unidoc).value,
504-
mdocVariables := Map(
507+
mdocVariables := Map(
505508
"scalapb" -> "0.11.11",
506509
"scalapb_latest" -> "0.11.11",
507510
"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
val contextNames = fd.getContainingType.fields.map(_.scalaName) ++
394394
fd.getContainingType.getRealOneofs.asScala.map(_.scalaName.nameSymbol)
395395
fd.getMessageType.scalaType.fullNameWithMaybeRoot(contextNames)
@@ -514,7 +514,7 @@ class DescriptorImplicits private[compiler] (
514514
def scalaType: ScalaName = {
515515
val name = message.getName match {
516516
case "Option" => "OptionProto"
517-
case name =>
517+
case name =>
518518
if (message.isSealedOneofType) name + OneofMessageSuffix
519519
else name
520520
}
@@ -786,7 +786,7 @@ class DescriptorImplicits private[compiler] (
786786

787787
lazy val scalaType: ScalaName = {
788788
val name: String = enumDescriptor.getName match {
789-
case "Option" => "OptionEnum"
789+
case "Option" => "OptionEnum"
790790
case "ValueType" =>
791791
"ValueTypeEnum" // Issue 348, conflicts with "type ValueType" in GeneratedEnumCompanion.
792792
case n => n
@@ -1060,7 +1060,7 @@ class DescriptorImplicits private[compiler] (
10601060

10611061
/** Returns a vector with all messages (both top-level and nested) in the file. */
10621062
def allMessages: Vector[Descriptor] = {
1063-
val messages = Vector.newBuilder[Descriptor]
1063+
val messages = Vector.newBuilder[Descriptor]
10641064
def visitMessage(d: Descriptor): Unit = {
10651065
messages += d
10661066
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
val contextNames = field.getContainingType.fields.map(_.scalaName) ++
190190
field.getContainingType.getRealOneofs.asScala.map(_.scalaName.nameSymbol)
@@ -218,7 +218,7 @@ class ProtobufGenerator(
218218
case FieldDescriptor.JavaType.BOOLEAN => MethodApplication("booleanValue")
219219
case FieldDescriptor.JavaType.BYTE_STRING => Identity
220220
case FieldDescriptor.JavaType.STRING => Identity
221-
case FieldDescriptor.JavaType.MESSAGE =>
221+
case FieldDescriptor.JavaType.MESSAGE =>
222222
val contextNames = field.getContainingType.fields.map(_.scalaName) ++
223223
field.getContainingType.getRealOneofs.asScala.map(_.scalaName.nameSymbol)
224224
FunctionApplication(
@@ -255,7 +255,7 @@ class ProtobufGenerator(
255255
}
256256

257257
def javaFieldToScala(container: String, field: FieldDescriptor): String = {
258-
val javaHazzer = container + ".has" + field.upperJavaName
258+
val javaHazzer = container + ".has" + field.upperJavaName
259259
val upperJavaName =
260260
if (field.isEnum && field.getFile.isProto3) (field.upperJavaName + "Value")
261261
else field.upperJavaName
@@ -297,7 +297,7 @@ class ProtobufGenerator(
297297
case FieldDescriptor.JavaType.BOOLEAN => maybeBox("_root_.scala.Boolean.box")
298298
case FieldDescriptor.JavaType.BYTE_STRING => Identity
299299
case FieldDescriptor.JavaType.STRING => Identity
300-
case FieldDescriptor.JavaType.MESSAGE =>
300+
case FieldDescriptor.JavaType.MESSAGE =>
301301
val contextNames = field.getContainingType.fields.map(_.scalaName) ++
302302
field.getContainingType.getRealOneofs.asScala.map(_.scalaName.nameSymbol)
303303
FunctionApplication(
@@ -630,10 +630,10 @@ class ProtobufGenerator(
630630
).add("}")
631631
case None =>
632632
val capTypeName = Types.capitalizedType(field.getType)
633-
val sizeFunc = FunctionApplication(
633+
val sizeFunc = FunctionApplication(
634634
s"_root_.com.google.protobuf.CodedOutputStream.compute${capTypeName}SizeNoTag"
635635
)
636-
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
636+
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
637637
val fromCustom =
638638
if (field.customSingleScalaTypeName.isDefined)
639639
FunctionApplication(s"${field.typeMapper.fullName}.toBase")
@@ -743,7 +743,7 @@ class ProtobufGenerator(
743743

744744
val regularFields = message.fields.collect {
745745
case field if !field.isInOneof =>
746-
val typeName = field.scalaTypeName
746+
val typeName = field.scalaTypeName
747747
val ctorDefaultValue: Option[String] =
748748
if (field.noDefaultValueInConstructor) None
749749
else if (field.isOptional && field.supportsPresence) Some(C.None)
@@ -891,7 +891,7 @@ class ProtobufGenerator(
891891
else if (field.isRepeated) {
892892
val empty = readsEnclosing match {
893893
case EnclosingType.Collection(s, _) => s"$s.empty"
894-
case _ =>
894+
case _ =>
895895
throw new GeneratorException(
896896
"Expected a collection enclosing. Pleae report this as a bug."
897897
)
@@ -1216,7 +1216,7 @@ class ProtobufGenerator(
12161216
case Type.INT32 => ("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
12171217
case Type.FIXED64 => ("fixed64Lens", Identity, Identity)
12181218
case Type.FIXED32 => ("fixed32Lens", Identity, Identity)
1219-
case Type.BOOL =>
1219+
case Type.BOOL =>
12201220
(
12211221
"varintLens",
12221222
OperatorApplication("!= 0"),
@@ -1228,7 +1228,7 @@ class ProtobufGenerator(
12281228
MethodApplication("toStringUtf8()"),
12291229
FunctionApplication("_root_.com.google.protobuf.ByteString.copyFromUtf8")
12301230
)
1231-
case Type.GROUP => throw new RuntimeException("Not supported")
1231+
case Type.GROUP => throw new RuntimeException("Not supported")
12321232
case Type.MESSAGE =>
12331233
(
12341234
"lengthDelimitedLens",
@@ -1237,7 +1237,7 @@ class ProtobufGenerator(
12371237
),
12381238
MethodApplication(s"toByteString")
12391239
)
1240-
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
1240+
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
12411241
case Type.UINT32 =>
12421242
("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
12431243
case Type.ENUM =>
@@ -1250,7 +1250,7 @@ class ProtobufGenerator(
12501250
)
12511251
case Type.SFIXED32 => ("fixed32Lens", Identity, Identity)
12521252
case Type.SFIXED64 => ("fixed64Lens", Identity, Identity)
1253-
case Type.SINT32 =>
1253+
case Type.SINT32 =>
12541254
(
12551255
"varintLens",
12561256
MethodApplication("toInt") andThen FunctionApplication(
@@ -1283,8 +1283,8 @@ class ProtobufGenerator(
12831283
Seq(fd.getType match {
12841284
case Type.DOUBLE | Type.FIXED64 | Type.SFIXED64 => "_.readFixed64()"
12851285
case Type.FLOAT | Type.FIXED32 | Type.SFIXED32 => "_.readFixed32()"
1286-
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM |
1287-
Type.BOOL | Type.SINT32 | Type.SINT64 =>
1286+
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM | Type.BOOL |
1287+
Type.SINT32 | Type.SINT64 =>
12881288
"_.readInt64()"
12891289
case _ =>
12901290
throw new GeneratorException(s"Unexpected packable type: ${fd.getType.name()}")
@@ -1390,7 +1390,7 @@ class ProtobufGenerator(
13901390

13911391
def printMessage(printer: FunctionalPrinter, message: Descriptor): FunctionalPrinter = {
13921392
val fullName = message.scalaType.fullNameWithMaybeRoot(message)
1393-
val derives =
1393+
val derives =
13941394
if (message.derives.nonEmpty) message.derives.mkString(" derives ", ", ", "") else ""
13951395
printer
13961396
.call(new SealedOneofsGenerator(message, implicits).generateSealedOneofTrait)
@@ -1557,7 +1557,7 @@ class ProtobufGenerator(
15571557
def updateEnumValue(
15581558
enumValue: EnumValueDescriptor
15591559
): DescriptorProtos.EnumValueDescriptorProto = {
1560-
val ev = enumValue.toProto().toBuilder()
1560+
val ev = enumValue.toProto().toBuilder()
15611561
val extBuilder =
15621562
enumValue.getOptions().getExtension[Scalapb.EnumValueOptions](Scalapb.enumValue).toBuilder
15631563
assert(!extBuilder.hasScalaName || extBuilder.getScalaName == enumValue.scalaName)
@@ -1644,7 +1644,7 @@ class ProtobufGenerator(
16441644
def generateServiceFiles(file: FileDescriptor): Seq[CodeGeneratorResponse.File] = {
16451645
if (params.grpc) {
16461646
file.getServices.asScala.map { service =>
1647-
val p = new GrpcServicePrinter(service, implicits)
1647+
val p = new GrpcServicePrinter(service, implicits)
16481648
val code = scalaFileHeader(
16491649
file,
16501650
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)