Skip to content

Commit 9f50c30

Browse files
committed
Reformat with scalafmt 3.9.10
Executed command: scalafmt --non-interactive
1 parent aad01c0 commit 9f50c30

File tree

66 files changed

+1800
-1286
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

+1800
-1286
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
@@ -156,7 +156,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
156156
(protocCacheCoursier % "test").cross(CrossVersion.for3Use2_13),
157157
scalaTest.value % "test"
158158
),
159-
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
159+
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
160160
mimaBinaryIssueFilters := Seq(
161161
ProblemFilters.exclude[ReversedMissingMethodProblem]("scalapb.options.*"),
162162
ProblemFilters.exclude[DirectMissingMethodProblem]("scalapb.compiler.GeneratorParams.*"),
@@ -168,7 +168,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
168168
"scalapb.compiler.ProtobufGenerator.generateTypeMappers"
169169
)
170170
),
171-
PB.protocVersion := protobufCompilerVersion,
171+
PB.protocVersion := protobufCompilerVersion,
172172
Compile / PB.targets := Seq(
173173
PB.gens.java(protobufCompilerVersion) -> (Compile / sourceManaged).value / "java_out"
174174
),
@@ -466,15 +466,18 @@ lazy val conformance = (projectMatrix in file("conformance"))
466466
),
467467
codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value,
468468
libraryDependencies ++= Seq(
469-
"com.thesamet.scalapb" %% "scalapb-json4s" % "1.0.0-alpha.1" exclude ("com.thesamet.scalapb", "scalapb-runtime_2.13")
469+
"com.thesamet.scalapb" %% "scalapb-json4s" % "1.0.0-alpha.1" exclude (
470+
"com.thesamet.scalapb",
471+
"scalapb-runtime_2.13"
472+
)
470473
),
471-
maintainer := "[email protected]",
472-
Compile / mainClass := Some("scalapb.ConformanceScala"),
473-
assemblyJarName := "conformance",
474-
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
474+
maintainer := "[email protected]",
475+
Compile / mainClass := Some("scalapb.ConformanceScala"),
476+
assemblyJarName := "conformance",
477+
assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)),
475478
assembly / assemblyMergeStrategy := {
476479
case x if x.endsWith("module-info.class") => MergeStrategy.discard
477-
case x =>
480+
case x =>
478481
val oldStrategy = (assembly / assemblyMergeStrategy).value
479482
oldStrategy(x)
480483
}
@@ -496,7 +499,7 @@ lazy val docs = project
496499
"com.lihaoyi" %% "os-lib" % "0.5.0",
497500
"org.plotly-scala" %% "plotly-render" % "0.7.2"
498501
),
499-
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
502+
mdocIn := baseDirectory.value / "src" / "main" / "markdown",
500503
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(
501504
lensesJVM2_12,
502505
runtimeJVM2_12,
@@ -506,7 +509,7 @@ lazy val docs = project
506509
cleanFiles += (ScalaUnidoc / unidoc / target).value,
507510
docusaurusCreateSite := docusaurusCreateSite.dependsOn(Compile / unidoc).value,
508511
docusaurusPublishGhpages := docusaurusPublishGhpages.dependsOn(Compile / unidoc).value,
509-
mdocVariables := Map(
512+
mdocVariables := Map(
510513
"scalapb" -> "0.11.11",
511514
"scalapb_latest" -> "0.11.11",
512515
"scala3" -> Dependencies.Scala3,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class DescriptorImplicits private[compiler] (
200200
fd.getName match {
201201
case ("number" | "value") if fd.isInOneof => "_" + fd.getName
202202
case "serialized_size" => "_serializedSize"
203-
case x =>
203+
case x =>
204204
getNameWithFallback(x, Case.CamelCase, Appendage.Prefix)
205205
}
206206

@@ -493,7 +493,7 @@ class DescriptorImplicits private[compiler] (
493493
def scalaType: ScalaName = {
494494
val name = message.getName match {
495495
case "Option" => "OptionProto"
496-
case name =>
496+
case name =>
497497
if (message.isSealedOneofType) name + OneofMessageSuffix
498498
else name
499499
}
@@ -765,7 +765,7 @@ class DescriptorImplicits private[compiler] (
765765

766766
lazy val scalaType: ScalaName = {
767767
val name: String = enumDescriptor.getName match {
768-
case "Option" => "OptionEnum"
768+
case "Option" => "OptionEnum"
769769
case "ValueType" =>
770770
"ValueTypeEnum" // Issue 348, conflicts with "type ValueType" in GeneratedEnumCompanion.
771771
case n => n
@@ -1035,7 +1035,7 @@ class DescriptorImplicits private[compiler] (
10351035

10361036
/** Returns a vector with all messages (both top-level and nested) in the file. */
10371037
def allMessages: Vector[Descriptor] = {
1038-
val messages = Vector.newBuilder[Descriptor]
1038+
val messages = Vector.newBuilder[Descriptor]
10391039
def visitMessage(d: Descriptor): Unit = {
10401040
messages += d
10411041
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
@@ -162,8 +162,8 @@ class ProtobufGenerator(
162162
def defaultValue = field.getDefaultValue
163163

164164
val baseDefaultValue: String = field.getJavaType match {
165-
case FieldDescriptor.JavaType.INT => defaultValue.toString
166-
case FieldDescriptor.JavaType.LONG => defaultValue.toString + "L"
165+
case FieldDescriptor.JavaType.INT => defaultValue.toString
166+
case FieldDescriptor.JavaType.LONG => defaultValue.toString + "L"
167167
case FieldDescriptor.JavaType.FLOAT =>
168168
val f = defaultValue.asInstanceOf[Float]
169169
if (f.isPosInfinity) "Float.PositiveInfinity"
@@ -186,7 +186,7 @@ class ProtobufGenerator(
186186
d.asScala
187187
.map(_.toString)
188188
.mkString("_root_.com.google.protobuf.ByteString.copyFrom(Array[Byte](", ", ", "))")
189-
case FieldDescriptor.JavaType.STRING => escapeScalaString(defaultValue.asInstanceOf[String])
189+
case FieldDescriptor.JavaType.STRING => escapeScalaString(defaultValue.asInstanceOf[String])
190190
case FieldDescriptor.JavaType.MESSAGE =>
191191
field.getMessageType.scalaType.fullName + ".defaultInstance"
192192
case FieldDescriptor.JavaType.ENUM =>
@@ -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(
219219
field.getMessageType.scalaType.fullName + ".fromJavaProto"
220220
)
@@ -247,7 +247,7 @@ class ProtobufGenerator(
247247
}
248248

249249
def javaFieldToScala(container: String, field: FieldDescriptor): String = {
250-
val javaHazzer = container + ".has" + field.upperJavaName
250+
val javaHazzer = container + ".has" + field.upperJavaName
251251
val upperJavaName =
252252
if (field.isEnum && !field.legacyEnumFieldTreatedAsClosed()) (field.upperJavaName + "Value")
253253
else field.upperJavaName
@@ -291,7 +291,7 @@ class ProtobufGenerator(
291291
case FieldDescriptor.JavaType.BOOLEAN => maybeBox("_root_.scala.Boolean.box")
292292
case FieldDescriptor.JavaType.BYTE_STRING => Identity
293293
case FieldDescriptor.JavaType.STRING => Identity
294-
case FieldDescriptor.JavaType.MESSAGE =>
294+
case FieldDescriptor.JavaType.MESSAGE =>
295295
FunctionApplication(
296296
field.getMessageType.scalaType.fullName + ".toJavaProto"
297297
)
@@ -624,10 +624,10 @@ class ProtobufGenerator(
624624
).add("}")
625625
case None =>
626626
val capTypeName = Types.capitalizedType(field.getType)
627-
val sizeFunc = FunctionApplication(
627+
val sizeFunc = FunctionApplication(
628628
s"_root_.com.google.protobuf.CodedOutputStream.compute${capTypeName}SizeNoTag"
629629
)
630-
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
630+
val fromEnum = if (field.isEnum) MethodApplication("value") else Identity
631631
val fromCustom =
632632
if (field.customSingleScalaTypeName.isDefined)
633633
FunctionApplication(s"${field.typeMapper.fullName}.toBase")
@@ -737,7 +737,7 @@ class ProtobufGenerator(
737737

738738
val regularFields = message.fields.collect {
739739
case field if !field.isInOneof =>
740-
val typeName = field.scalaTypeName
740+
val typeName = field.scalaTypeName
741741
val ctorDefaultValue: Option[String] =
742742
if (field.noDefaultValueInConstructor) None
743743
else if (field.isSingularOptional && field.supportsPresence) Some(C.None)
@@ -885,7 +885,7 @@ class ProtobufGenerator(
885885
else if (field.isRepeated) {
886886
val empty = readsEnclosing match {
887887
case EnclosingType.Collection(s, _) => s"$s.empty"
888-
case _ =>
888+
case _ =>
889889
throw new GeneratorException(
890890
"Expected a collection enclosing. Pleae report this as a bug."
891891
)
@@ -1209,7 +1209,7 @@ class ProtobufGenerator(
12091209
case Type.INT32 => ("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
12101210
case Type.FIXED64 => ("fixed64Lens", Identity, Identity)
12111211
case Type.FIXED32 => ("fixed32Lens", Identity, Identity)
1212-
case Type.BOOL =>
1212+
case Type.BOOL =>
12131213
(
12141214
"varintLens",
12151215
OperatorApplication("!= 0"),
@@ -1221,7 +1221,7 @@ class ProtobufGenerator(
12211221
MethodApplication("toStringUtf8()"),
12221222
FunctionApplication("_root_.com.google.protobuf.ByteString.copyFromUtf8")
12231223
)
1224-
case Type.GROUP => throw new RuntimeException("Not supported")
1224+
case Type.GROUP => throw new RuntimeException("Not supported")
12251225
case Type.MESSAGE =>
12261226
(
12271227
"lengthDelimitedLens",
@@ -1230,7 +1230,7 @@ class ProtobufGenerator(
12301230
),
12311231
MethodApplication(s"toByteString")
12321232
)
1233-
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
1233+
case Type.BYTES => ("lengthDelimitedLens", Identity, Identity)
12341234
case Type.UINT32 =>
12351235
("varintLens", MethodApplication("toInt"), MethodApplication("toLong"))
12361236
case Type.ENUM =>
@@ -1243,7 +1243,7 @@ class ProtobufGenerator(
12431243
)
12441244
case Type.SFIXED32 => ("fixed32Lens", Identity, Identity)
12451245
case Type.SFIXED64 => ("fixed64Lens", Identity, Identity)
1246-
case Type.SINT32 =>
1246+
case Type.SINT32 =>
12471247
(
12481248
"varintLens",
12491249
MethodApplication("toInt") andThen FunctionApplication(
@@ -1276,8 +1276,8 @@ class ProtobufGenerator(
12761276
Seq(fd.getType match {
12771277
case Type.DOUBLE | Type.FIXED64 | Type.SFIXED64 => "_.readFixed64()"
12781278
case Type.FLOAT | Type.FIXED32 | Type.SFIXED32 => "_.readFixed32()"
1279-
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM |
1280-
Type.BOOL | Type.SINT32 | Type.SINT64 =>
1279+
case Type.UINT32 | Type.UINT64 | Type.INT32 | Type.INT64 | Type.ENUM | Type.BOOL |
1280+
Type.SINT32 | Type.SINT64 =>
12811281
"_.readInt64()"
12821282
case _ =>
12831283
throw new GeneratorException(s"Unexpected packable type: ${fd.getType.name()}")
@@ -1383,7 +1383,7 @@ class ProtobufGenerator(
13831383

13841384
def printMessage(printer: FunctionalPrinter, message: Descriptor): FunctionalPrinter = {
13851385
val fullName = message.scalaType.fullName
1386-
val derives =
1386+
val derives =
13871387
if (message.derives.nonEmpty) message.derives.mkString(" derives ", ", ", "") else ""
13881388
printer
13891389
.call(new SealedOneofsGenerator(message, implicits).generateSealedOneofTrait)
@@ -1544,7 +1544,7 @@ class ProtobufGenerator(
15441544
def updateEnumValue(
15451545
enumValue: EnumValueDescriptor
15461546
): DescriptorProtos.EnumValueDescriptorProto = {
1547-
val ev = enumValue.toProto().toBuilder()
1547+
val ev = enumValue.toProto().toBuilder()
15481548
val extBuilder =
15491549
enumValue.getOptions().getExtension[Scalapb.EnumValueOptions](Scalapb.enumValue).toBuilder
15501550
assert(!extBuilder.hasScalaName || extBuilder.getScalaName == enumValue.scalaName)
@@ -1631,7 +1631,7 @@ class ProtobufGenerator(
16311631
def generateServiceFiles(file: FileDescriptor): Seq[CodeGeneratorResponse.File] = {
16321632
if (params.grpc) {
16331633
file.getServices.asScala.map { service =>
1634-
val p = new GrpcServicePrinter(service, implicits)
1634+
val p = new GrpcServicePrinter(service, implicits)
16351635
val code = scalaFileHeader(
16361636
file,
16371637
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(

compiler-plugin/src/test/scala/scalapb/compiler/DescriptorImplicitsSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class DescriptorImplicitsSpec extends AnyFlatSpec with Matchers with ProtocInvoc
4242
)
4343

4444
"flat package" should "be overridable to false when set as generator parameter" in {
45-
val files = generateFileSet(base)
45+
val files = generateFileSet(base)
4646
val implicits = new DescriptorImplicits(
4747
GeneratorParams(flatPackage = true),
4848
files,
@@ -71,7 +71,7 @@ class DescriptorImplicitsSpec extends AnyFlatSpec with Matchers with ProtocInvoc
7171
}
7272

7373
"flat package" should "be overridable when not set as generator parameter" in {
74-
val files = generateFileSet(base)
74+
val files = generateFileSet(base)
7575
val implicits = new DescriptorImplicits(
7676
GeneratorParams(flatPackage = false),
7777
files,
@@ -100,7 +100,7 @@ class DescriptorImplicitsSpec extends AnyFlatSpec with Matchers with ProtocInvoc
100100
}
101101

102102
"disableOutput" should "be set for package option files" in {
103-
val files = generateFileSet(base)
103+
val files = generateFileSet(base)
104104
val implicits = new DescriptorImplicits(
105105
GeneratorParams(flatPackage = false),
106106
files,

0 commit comments

Comments
 (0)