From e41a44b39b5e3b2c7d26974914c52ca9646bfdeb Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 13 Oct 2025 18:52:51 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.10.0 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index e76df7e7d..a7e628693 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.7.17 +version = 3.10.0 style = defaultWithAlign maxColumn = 100 assumeStandardLibraryStripMargin = true From 6d0416fc660bcb8aa7d630a99eac7ca1d855bc32 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 13 Oct 2025 18:53:08 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.10.0 Executed command: scalafmt --non-interactive --- benchmarks/build.sbt | 2 +- build.sbt | 23 +- .../compiler/DescriptorImplicits.scala | 8 +- .../scalapb/compiler/ExpressionBuilder.scala | 8 +- .../compiler/FieldTransformations.scala | 8 +- .../scalapb/compiler/GeneratorParams.scala | 2 +- .../scalapb/compiler/ParseFromGenerator.scala | 4 +- .../scalapb/compiler/ProtobufGenerator.scala | 38 +- .../compiler/SealedOneofsGenerator.scala | 4 +- .../compiler/DescriptorImplicitsSpec.scala | 6 +- .../compiler/FieldTransformationsSpec.scala | 2 +- .../compiler/ProtoValidationSpec.scala | 2 +- .../compiler/ProtocInvocationHelper.scala | 2 +- .../src/main/scala/ConformanceScala.scala | 2 +- .../com/thesamet/docs/json/JsonProto.scala | 34 +- .../com/thesamet/docs/json/MyContainer.scala | 188 ++++-- .../com/thesamet/docs/json/MyMessage.scala | 172 +++-- .../generated/mytypes/duration/Duration.scala | 167 +++-- .../mytypes/duration/DurationProto.scala | 34 +- .../scalapb/docs/person/Person.scala | 635 ++++++++++-------- .../scalapb/docs/person/PersonProto.scala | 32 +- .../generated/scalapb/perf/protos/Color.scala | 64 +- .../generated/scalapb/perf/protos/Enum.scala | 170 +++-- .../scalapb/perf/protos/EnumVector.scala | 200 +++--- .../scalapb/perf/protos/IntVector.scala | 187 +++--- .../perf/protos/MessageContainer.scala | 243 ++++--- .../scalapb/perf/protos/ProtosProto.scala | 34 +- .../scalapb/perf/protos/SimpleMessage.scala | 339 ++++++---- .../scalapb/perf/protos/StringMessage.scala | 228 ++++--- .../scalapb/docs/benchmarks/Charts.scala | 8 +- .../scala/GrpcServiceScalaServerSpec.scala | 6 +- .../src/test/scala/GrpcServiceSpecBase.scala | 10 +- .../src/test/scala/ProtoInputStreamSpec.scala | 6 +- .../src/test/scala/UniquePortGenerator.scala | 2 +- .../scala-3/scalapb/derives/typeclasses.scala | 14 +- .../com/thesamet/proto/e2e/TypeMappers.scala | 6 +- e2e/src/test/scala/CollectionTypesSpec.scala | 14 +- e2e/src/test/scala/CustomOptionsSpec.scala | 4 +- e2e/src/test/scala/EnumAliasSpec.scala | 2 +- e2e/src/test/scala/OneofSpec.scala | 4 +- e2e/src/test/scala/RepeatablesSpec.scala | 2 +- e2e/src/test/scala/UnknownFieldSetSpec.scala | 4 +- .../test/scala/scalapb/StructUtilsSpec.scala | 10 +- e2e/src/test/scala/scoped/WildcardSpec.scala | 6 +- .../scalajvm-3-source/Scala3CompatSpec.scala | 4 +- .../src/main/scala/AddressBookMain.scala | 2 +- project/Dependencies.scala | 4 +- proptest/src/test/scala/GenData.scala | 6 +- proptest/src/test/scala/GenTypes.scala | 10 +- proptest/src/test/scala/GraphGen.scala | 6 +- proptest/src/test/scala/Nodes.scala | 8 +- .../src/test/scala/SchemaGenerators.scala | 2 +- .../scala/scalapb/grpc/ProtoInputStream.scala | 8 +- .../src/main/scala/scalapb/Encoding.scala | 2 +- .../main/scala/scalapb/FieldMaskTree.scala | 10 +- .../main/scala/scalapb/FieldMaskUtil.scala | 2 +- .../src/main/scala/scalapb/StructUtils.scala | 22 +- .../main/scala/scalapb/UnknownFieldSet.scala | 6 +- .../scalapb/descriptors/Descriptor.scala | 8 +- .../scalapb/descriptors/SourceCodePath.scala | 2 +- .../scala/scalapb/textformat/AstUtils.scala | 8 +- .../scala/scalapb/textformat/Parser.scala | 2 +- .../scala/scalapb/textformat/Printer.scala | 2 +- .../scalapb/textformat/TextFormatUtils.scala | 28 +- .../src/main/scala/scalapb/ScalaPBC.scala | 6 +- sonatype.sbt | 2 +- 66 files changed, 1800 insertions(+), 1286 deletions(-) diff --git a/benchmarks/build.sbt b/benchmarks/build.sbt index dad19e160..a204494df 100644 --- a/benchmarks/build.sbt +++ b/benchmarks/build.sbt @@ -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" ), diff --git a/build.sbt b/build.sbt index d1dc0ee1b..66d340300 100644 --- a/build.sbt +++ b/build.sbt @@ -156,7 +156,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.*"), @@ -168,7 +168,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" ), @@ -466,15 +466,18 @@ lazy val conformance = (projectMatrix in file("conformance")) ), codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value, libraryDependencies ++= Seq( - "com.thesamet.scalapb" %% "scalapb-json4s" % "1.0.0-alpha.1" exclude ("com.thesamet.scalapb", "scalapb-runtime_2.13") + "com.thesamet.scalapb" %% "scalapb-json4s" % "1.0.0-alpha.1" exclude ( + "com.thesamet.scalapb", + "scalapb-runtime_2.13" + ) ), - maintainer := "thesamet@gmail.com", - Compile / mainClass := Some("scalapb.ConformanceScala"), - assemblyJarName := "conformance", - assemblyPrependShellScript := Some(defaultUniversalScript(shebang = true)), + maintainer := "thesamet@gmail.com", + 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) } @@ -496,7 +499,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, @@ -506,7 +509,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, diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/DescriptorImplicits.scala b/compiler-plugin/src/main/scala/scalapb/compiler/DescriptorImplicits.scala index d67e081e8..a1c8c606f 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/DescriptorImplicits.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/DescriptorImplicits.scala @@ -200,7 +200,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) } @@ -493,7 +493,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 } @@ -765,7 +765,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 @@ -1035,7 +1035,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) diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/ExpressionBuilder.scala b/compiler-plugin/src/main/scala/scalapb/compiler/ExpressionBuilder.scala index 139c786aa..a90b36196 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/ExpressionBuilder.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/ExpressionBuilder.scala @@ -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") @@ -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) diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/FieldTransformations.scala b/compiler-plugin/src/main/scala/scalapb/compiler/FieldTransformations.scala index 9b38190bd..f3c27b5c3 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/FieldTransformations.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/FieldTransformations.scala @@ -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, @@ -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 @@ -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)) @@ -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) diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/GeneratorParams.scala b/compiler-plugin/src/main/scala/scalapb/compiler/GeneratorParams.scala index cf7b592cb..7e3774677 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/GeneratorParams.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/GeneratorParams.scala @@ -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" => diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/ParseFromGenerator.scala b/compiler-plugin/src/main/scala/scalapb/compiler/ParseFromGenerator.scala index b8c92e09d..a5f85a66a 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/ParseFromGenerator.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/ParseFromGenerator.scala @@ -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)) => @@ -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)) { diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala b/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala index d8a2350cc..1f82cd1fe 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala @@ -162,8 +162,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" @@ -186,7 +186,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.fullName + ".defaultInstance" case FieldDescriptor.JavaType.ENUM => @@ -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" ) @@ -247,7 +247,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.legacyEnumFieldTreatedAsClosed()) (field.upperJavaName + "Value") else field.upperJavaName @@ -291,7 +291,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" ) @@ -624,10 +624,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") @@ -737,7 +737,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.isSingularOptional && field.supportsPresence) Some(C.None) @@ -885,7 +885,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." ) @@ -1209,7 +1209,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"), @@ -1221,7 +1221,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", @@ -1230,7 +1230,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 => @@ -1243,7 +1243,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( @@ -1276,8 +1276,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()}") @@ -1383,7 +1383,7 @@ class ProtobufGenerator( def printMessage(printer: FunctionalPrinter, message: Descriptor): FunctionalPrinter = { val fullName = message.scalaType.fullName - val derives = + val derives = if (message.derives.nonEmpty) message.derives.mkString(" derives ", ", ", "") else "" printer .call(new SealedOneofsGenerator(message, implicits).generateSealedOneofTrait) @@ -1544,7 +1544,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) @@ -1631,7 +1631,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( diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala b/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala index 615aa97aa..c9a4b0bb6 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala @@ -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 "" @@ -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( diff --git a/compiler-plugin/src/test/scala/scalapb/compiler/DescriptorImplicitsSpec.scala b/compiler-plugin/src/test/scala/scalapb/compiler/DescriptorImplicitsSpec.scala index 8c4627b52..a0e91117a 100644 --- a/compiler-plugin/src/test/scala/scalapb/compiler/DescriptorImplicitsSpec.scala +++ b/compiler-plugin/src/test/scala/scalapb/compiler/DescriptorImplicitsSpec.scala @@ -42,7 +42,7 @@ class DescriptorImplicitsSpec extends AnyFlatSpec with Matchers with ProtocInvoc ) "flat package" should "be overridable to false when set as generator parameter" in { - val files = generateFileSet(base) + val files = generateFileSet(base) val implicits = new DescriptorImplicits( GeneratorParams(flatPackage = true), files, @@ -71,7 +71,7 @@ class DescriptorImplicitsSpec extends AnyFlatSpec with Matchers with ProtocInvoc } "flat package" should "be overridable when not set as generator parameter" in { - val files = generateFileSet(base) + val files = generateFileSet(base) val implicits = new DescriptorImplicits( GeneratorParams(flatPackage = false), files, @@ -100,7 +100,7 @@ class DescriptorImplicitsSpec extends AnyFlatSpec with Matchers with ProtocInvoc } "disableOutput" should "be set for package option files" in { - val files = generateFileSet(base) + val files = generateFileSet(base) val implicits = new DescriptorImplicits( GeneratorParams(flatPackage = false), files, diff --git a/compiler-plugin/src/test/scala/scalapb/compiler/FieldTransformationsSpec.scala b/compiler-plugin/src/test/scala/scalapb/compiler/FieldTransformationsSpec.scala index 718bedca3..0f6e4f4ea 100644 --- a/compiler-plugin/src/test/scala/scalapb/compiler/FieldTransformationsSpec.scala +++ b/compiler-plugin/src/test/scala/scalapb/compiler/FieldTransformationsSpec.scala @@ -204,7 +204,7 @@ class FieldTransformationsSpec extends AnyFlatSpec with Matchers with ProtocInvo val inherits = files.find(_.getFullName() == "inherits.proto").get val hasScalapb = files.find(_.getFullName() == "has_scalapb.proto").get val ignores = files.find(_.getFullName() == "ignores.proto").get - val context = + val context = ExtensionResolutionContext("-", FieldTransformations.fieldExtensionsForFile(inherits)) val contextWithScalaPB = ExtensionResolutionContext("-", FieldTransformations.fieldExtensionsForFile(hasScalapb)) diff --git a/compiler-plugin/src/test/scala/scalapb/compiler/ProtoValidationSpec.scala b/compiler-plugin/src/test/scala/scalapb/compiler/ProtoValidationSpec.scala index 3551b1e45..c3ab3d3b4 100644 --- a/compiler-plugin/src/test/scala/scalapb/compiler/ProtoValidationSpec.scala +++ b/compiler-plugin/src/test/scala/scalapb/compiler/ProtoValidationSpec.scala @@ -9,7 +9,7 @@ class ProtoValidationSpec extends AnyFlatSpec with Matchers with ProtocInvocatio secondaryOutput: SecondaryOutputProvider, files: (String, String)* ): Unit = { - val fileset = generateFileSet(files) + val fileset = generateFileSet(files) val validation = new ProtoValidation( new DescriptorImplicits(generatorParams, fileset, secondaryOutput) ) diff --git a/compiler-plugin/src/test/scala/scalapb/compiler/ProtocInvocationHelper.scala b/compiler-plugin/src/test/scala/scalapb/compiler/ProtocInvocationHelper.scala index 1a1f31fa9..95b027eb3 100644 --- a/compiler-plugin/src/test/scala/scalapb/compiler/ProtocInvocationHelper.scala +++ b/compiler-plugin/src/test/scala/scalapb/compiler/ProtocInvocationHelper.scala @@ -12,7 +12,7 @@ import scala.jdk.CollectionConverters._ trait ProtocInvocationHelper { def generateFileSet(files: Seq[(String, String)]): Seq[FileDescriptor] = { - val tmpDir = Files.createTempDirectory("validation").toFile + val tmpDir = Files.createTempDirectory("validation").toFile val fileNames = files.map { case (name, content) => val file = new File(tmpDir, name) val pw = new PrintWriter(file) diff --git a/conformance/src/main/scala/ConformanceScala.scala b/conformance/src/main/scala/ConformanceScala.scala index 943b30172..8bca8e074 100644 --- a/conformance/src/main/scala/ConformanceScala.scala +++ b/conformance/src/main/scala/ConformanceScala.scala @@ -144,7 +144,7 @@ object ConformanceScala { def runTests(): Unit = { import ExitStatus._ doTestIO() match { - case Right(()) => runTests + case Right(()) => runTests case Left(Error(throwable)) => throwable.printStackTrace() sys.exit(1) diff --git a/docs/src/main/scala/generated/com/thesamet/docs/json/JsonProto.scala b/docs/src/main/scala/generated/com/thesamet/docs/json/JsonProto.scala index e4ab13644..eb381af04 100644 --- a/docs/src/main/scala/generated/com/thesamet/docs/json/JsonProto.scala +++ b/docs/src/main/scala/generated/com/thesamet/docs/json/JsonProto.scala @@ -7,27 +7,39 @@ object JsonProto extends _root_.scalapb.GeneratedFileObject { lazy val dependencies: Seq[_root_.scalapb.GeneratedFileObject] = Seq( _root_.com.google.protobuf.any.AnyProto ) - lazy val messagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = - Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]]( + lazy val messagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]]( _root_.com.thesamet.docs.json.MyMessage, _root_.com.thesamet.docs.json.MyContainer ) private lazy val ProtoBytes: _root_.scala.Array[Byte] = - scalapb.Encoding.fromBase64(scala.collection.immutable.Seq( - """Cgpqc29uLnByb3RvEhFjb20udGhlc2FtZXQuZG9jcxoZZ29vZ2xlL3Byb3RvYnVmL2FueS5wcm90byIhCglNeU1lc3NhZ2USF + scalapb.Encoding.fromBase64( + scala.collection.immutable + .Seq( + """Cgpqc29uLnByb3RvEhFjb20udGhlc2FtZXQuZG9jcxoZZ29vZ2xlL3Byb3RvYnVmL2FueS5wcm90byIhCglNeU1lc3NhZ2USF AoBeBgBIAEoBUIG4j8DEgF4UgF4IkYKC015Q29udGFpbmVyEjcKBm15X2FueRgBIAEoCzIULmdvb2dsZS5wcm90b2J1Zi5BbnlCC uI/BxIFbXlBbnlSBW15QW55YgZwcm90bzM=""" - ).mkString) + ) + .mkString + ) lazy val scalaDescriptor: _root_.scalapb.descriptors.FileDescriptor = { val scalaProto = com.google.protobuf.descriptor.FileDescriptorProto.parseFrom(ProtoBytes) - _root_.scalapb.descriptors.FileDescriptor.buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) + _root_.scalapb.descriptors.FileDescriptor + .buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) } lazy val javaDescriptor: com.google.protobuf.Descriptors.FileDescriptor = { val javaProto = com.google.protobuf.DescriptorProtos.FileDescriptorProto.parseFrom(ProtoBytes) - com.google.protobuf.Descriptors.FileDescriptor.buildFrom(javaProto, _root_.scala.Array( - _root_.com.google.protobuf.any.AnyProto.javaDescriptor - )) + com.google.protobuf.Descriptors.FileDescriptor.buildFrom( + javaProto, + _root_.scala.Array( + _root_.com.google.protobuf.any.AnyProto.javaDescriptor + ) + ) } - @deprecated("Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", "ScalaPB 0.5.47") + @deprecated( + "Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", + "ScalaPB 0.5.47" + ) def descriptor: com.google.protobuf.Descriptors.FileDescriptor = javaDescriptor -} \ No newline at end of file +} diff --git a/docs/src/main/scala/generated/com/thesamet/docs/json/MyContainer.scala b/docs/src/main/scala/generated/com/thesamet/docs/json/MyContainer.scala index bd7430031..06f262a1a 100644 --- a/docs/src/main/scala/generated/com/thesamet/docs/json/MyContainer.scala +++ b/docs/src/main/scala/generated/com/thesamet/docs/json/MyContainer.scala @@ -7,69 +7,85 @@ package com.thesamet.docs.json final case class MyContainer( myAny: _root_.scala.Option[_root_.com.google.protobuf.any.Any] = _root_.scala.None, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[MyContainer] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - if (myAny.isDefined) { - val __value = myAny.get - __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize - }; - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size - } - __size - 1 - - } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - myAny.foreach { __v => - val __m = __v - _output__.writeTag(1, 2) - _output__.writeUInt32NoTag(__m.serializedSize) - __m.writeTo(_output__) - }; - unknownFields.writeTo(_output__) +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[MyContainer] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + if (myAny.isDefined) { + val __value = myAny.get + __size += 1 + _root_.com.google.protobuf.CodedOutputStream + .computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize + }; + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def getMyAny: _root_.com.google.protobuf.any.Any = myAny.getOrElse(_root_.com.google.protobuf.any.Any.defaultInstance) - def clearMyAny: MyContainer = copy(myAny = _root_.scala.None) - def withMyAny(__v: _root_.com.google.protobuf.any.Any): MyContainer = copy(myAny = _root_.scala.Option(__v)) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => myAny.orNull - } + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + myAny.foreach { __v => + val __m = __v + _output__.writeTag(1, 2) + _output__.writeUInt32NoTag(__m.serializedSize) + __m.writeTo(_output__) + }; + unknownFields.writeTo(_output__) + } + def getMyAny: _root_.com.google.protobuf.any.Any = + myAny.getOrElse(_root_.com.google.protobuf.any.Any.defaultInstance) + def clearMyAny: MyContainer = copy(myAny = _root_.scala.None) + def withMyAny(__v: _root_.com.google.protobuf.any.Any): MyContainer = + copy(myAny = _root_.scala.Option(__v)) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => myAny.orNull } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => myAny.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty) - } + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => myAny.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty) } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.com.thesamet.docs.json.MyContainer.type = _root_.com.thesamet.docs.json.MyContainer - // @@protoc_insertion_point(GeneratedMessage[com.thesamet.docs.MyContainer]) + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.com.thesamet.docs.json.MyContainer.type = + _root_.com.thesamet.docs.json.MyContainer + // @@protoc_insertion_point(GeneratedMessage[com.thesamet.docs.MyContainer]) } -object MyContainer extends scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyContainer] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyContainer] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.com.thesamet.docs.json.MyContainer = { +object MyContainer + extends scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyContainer] { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyContainer] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.com.thesamet.docs.json.MyContainer = { var __myAny: _root_.scala.Option[_root_.com.google.protobuf.any.Any] = _root_.scala.None - var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { - case 0 => _done__ = true + case 0 => _done__ = true case 10 => - __myAny = _root_.scala.Option(__myAny.fold(_root_.scalapb.LiteParser.readMessage[_root_.com.google.protobuf.any.Any](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _))) + __myAny = _root_.scala.Option( + __myAny.fold( + _root_.scalapb.LiteParser.readMessage[_root_.com.google.protobuf.any.Any](_input__) + )(_root_.scalapb.LiteParser.readMessage(_input__, _)) + ) case tag => if (_unknownFields__ == null) { _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder() @@ -78,39 +94,63 @@ object MyContainer extends scalapb.GeneratedMessageCompanion[_root_.com.thesamet } } _root_.com.thesamet.docs.json.MyContainer( - myAny = __myAny, - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + myAny = __myAny, + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.com.thesamet.docs.json.MyContainer] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.com.thesamet.docs.json.MyContainer( - myAny = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).flatMap(_.as[_root_.scala.Option[_root_.com.google.protobuf.any.Any]]) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.com.thesamet.docs.json.JsonProto.javaDescriptor.getMessageTypes().get(1) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.com.thesamet.docs.json.JsonProto.scalaDescriptor.messages(1) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = { - var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null - (__number: @_root_.scala.unchecked) match { + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.com.thesamet.docs.json.MyContainer] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.com.thesamet.docs.json.MyContainer( + myAny = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .flatMap(_.as[_root_.scala.Option[_root_.com.google.protobuf.any.Any]]) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.com.thesamet.docs.json.JsonProto.javaDescriptor.getMessageTypes().get(1) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.com.thesamet.docs.json.JsonProto.scalaDescriptor.messages(1) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = { + var __out: _root_.scalapb.GeneratedMessageCompanion[?] = null + (__number: @ _root_.scala.unchecked) match { case 1 => __out = _root_.com.google.protobuf.any.Any } __out } - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = throw new MatchError(__fieldNumber) lazy val defaultInstance = _root_.com.thesamet.docs.json.MyContainer( myAny = _root_.scala.None ) - implicit class MyContainerLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.thesamet.docs.json.MyContainer]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.com.thesamet.docs.json.MyContainer](_l) { - def myAny: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.google.protobuf.any.Any] = field(_.getMyAny)((c_, f_) => c_.copy(myAny = _root_.scala.Option(f_))) - def optionalMyAny: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[_root_.com.google.protobuf.any.Any]] = field(_.myAny)((c_, f_) => c_.copy(myAny = f_)) + implicit class MyContainerLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.thesamet.docs.json.MyContainer] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.com.thesamet.docs.json.MyContainer]( + _l + ) { + def myAny: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.google.protobuf.any.Any] = + field(_.getMyAny)((c_, f_) => c_.copy(myAny = _root_.scala.Option(f_))) + def optionalMyAny: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[ + _root_.com.google.protobuf.any.Any + ]] = field(_.myAny)((c_, f_) => c_.copy(myAny = f_)) } final val MY_ANY_FIELD_NUMBER = 1 def of( - myAny: _root_.scala.Option[_root_.com.google.protobuf.any.Any] + myAny: _root_.scala.Option[_root_.com.google.protobuf.any.Any] ): _root_.com.thesamet.docs.json.MyContainer = _root_.com.thesamet.docs.json.MyContainer( myAny ) diff --git a/docs/src/main/scala/generated/com/thesamet/docs/json/MyMessage.scala b/docs/src/main/scala/generated/com/thesamet/docs/json/MyMessage.scala index fd26cec80..0351edd32 100644 --- a/docs/src/main/scala/generated/com/thesamet/docs/json/MyMessage.scala +++ b/docs/src/main/scala/generated/com/thesamet/docs/json/MyMessage.scala @@ -7,67 +7,76 @@ package com.thesamet.docs.json final case class MyMessage( x: _root_.scala.Int = 0, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[MyMessage] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - - { - val __value = x - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(1, __value) - } - }; - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[MyMessage] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + + { + val __value = x + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(1, __value) } - __size - 1 - - } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - { - val __v = x - if (__v != 0) { - _output__.writeInt32(1, __v) - } - }; - unknownFields.writeTo(_output__) + }; + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def withX(__v: _root_.scala.Int): MyMessage = copy(x = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => { - val __t = x - if (__t != 0) __t else null - } + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + { + val __v = x + if (__v != 0) { + _output__.writeInt32(1, __v) } - } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PInt(x) + }; + unknownFields.writeTo(_output__) + } + def withX(__v: _root_.scala.Int): MyMessage = copy(x = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => { + val __t = x + if (__t != 0) __t else null } } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.com.thesamet.docs.json.MyMessage.type = _root_.com.thesamet.docs.json.MyMessage - // @@protoc_insertion_point(GeneratedMessage[com.thesamet.docs.MyMessage]) + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => _root_.scalapb.descriptors.PInt(x) + } + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.com.thesamet.docs.json.MyMessage.type = + _root_.com.thesamet.docs.json.MyMessage + // @@protoc_insertion_point(GeneratedMessage[com.thesamet.docs.MyMessage]) } -object MyMessage extends scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyMessage] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyMessage] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.com.thesamet.docs.json.MyMessage = { - var __x: _root_.scala.Int = 0 +object MyMessage + extends scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyMessage] { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.com.thesamet.docs.json.MyMessage] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.com.thesamet.docs.json.MyMessage = { + var __x: _root_.scala.Int = 0 var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { @@ -82,32 +91,53 @@ object MyMessage extends scalapb.GeneratedMessageCompanion[_root_.com.thesamet.d } } _root_.com.thesamet.docs.json.MyMessage( - x = __x, - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + x = __x, + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.com.thesamet.docs.json.MyMessage] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.com.thesamet.docs.json.MyMessage( - x = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Int]).getOrElse(0) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.com.thesamet.docs.json.JsonProto.javaDescriptor.getMessageTypes().get(0) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.com.thesamet.docs.json.JsonProto.scalaDescriptor.messages(0) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber) + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.com.thesamet.docs.json.MyMessage] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.com.thesamet.docs.json.MyMessage( + x = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scala.Int]) + .getOrElse(0) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.com.thesamet.docs.json.JsonProto.javaDescriptor.getMessageTypes().get(0) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.com.thesamet.docs.json.JsonProto.scalaDescriptor.messages(0) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = throw new MatchError(__fieldNumber) lazy val defaultInstance = _root_.com.thesamet.docs.json.MyMessage( x = 0 ) - implicit class MyMessageLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.thesamet.docs.json.MyMessage]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.com.thesamet.docs.json.MyMessage](_l) { - def x: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = field(_.x)((c_, f_) => c_.copy(x = f_)) + implicit class MyMessageLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.thesamet.docs.json.MyMessage] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.com.thesamet.docs.json.MyMessage](_l) { + def x: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = + field(_.x)((c_, f_) => c_.copy(x = f_)) } final val X_FIELD_NUMBER = 1 def of( - x: _root_.scala.Int + x: _root_.scala.Int ): _root_.com.thesamet.docs.json.MyMessage = _root_.com.thesamet.docs.json.MyMessage( x ) diff --git a/docs/src/main/scala/generated/mytypes/duration/Duration.scala b/docs/src/main/scala/generated/mytypes/duration/Duration.scala index f5e72576e..4f7f6f60e 100644 --- a/docs/src/main/scala/generated/mytypes/duration/Duration.scala +++ b/docs/src/main/scala/generated/mytypes/duration/Duration.scala @@ -7,67 +7,74 @@ package mytypes.duration final case class Duration( seconds: _root_.scala.Int = 0, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[Duration] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - - { - val __value = seconds - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(1, __value) - } - }; - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[Duration] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + + { + val __value = seconds + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(1, __value) } - __size - 1 - - } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - { - val __v = seconds - if (__v != 0) { - _output__.writeInt32(1, __v) - } - }; - unknownFields.writeTo(_output__) + }; + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def withSeconds(__v: _root_.scala.Int): Duration = copy(seconds = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => { - val __t = seconds - if (__t != 0) __t else null - } + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + { + val __v = seconds + if (__v != 0) { + _output__.writeInt32(1, __v) } - } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PInt(seconds) + }; + unknownFields.writeTo(_output__) + } + def withSeconds(__v: _root_.scala.Int): Duration = copy(seconds = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => { + val __t = seconds + if (__t != 0) __t else null } } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.mytypes.duration.Duration.type = _root_.mytypes.duration.Duration - // @@protoc_insertion_point(GeneratedMessage[mytypes.Duration]) + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => _root_.scalapb.descriptors.PInt(seconds) + } + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.mytypes.duration.Duration.type = _root_.mytypes.duration.Duration + // @@protoc_insertion_point(GeneratedMessage[mytypes.Duration]) } object Duration extends scalapb.GeneratedMessageCompanion[_root_.mytypes.duration.Duration] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.mytypes.duration.Duration] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.mytypes.duration.Duration = { - var __seconds: _root_.scala.Int = 0 + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.mytypes.duration.Duration] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.mytypes.duration.Duration = { + var __seconds: _root_.scala.Int = 0 var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { @@ -82,32 +89,52 @@ object Duration extends scalapb.GeneratedMessageCompanion[_root_.mytypes.duratio } } _root_.mytypes.duration.Duration( - seconds = __seconds, - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + seconds = __seconds, + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.mytypes.duration.Duration] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.mytypes.duration.Duration( - seconds = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Int]).getOrElse(0) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.mytypes.duration.DurationProto.javaDescriptor.getMessageTypes().get(0) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.mytypes.duration.DurationProto.scalaDescriptor.messages(0) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber) + implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.mytypes.duration.Duration] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.mytypes.duration.Duration( + seconds = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scala.Int]) + .getOrElse(0) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.mytypes.duration.DurationProto.javaDescriptor.getMessageTypes().get(0) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.mytypes.duration.DurationProto.scalaDescriptor.messages(0) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = throw new MatchError(__fieldNumber) lazy val defaultInstance = _root_.mytypes.duration.Duration( seconds = 0 ) - implicit class DurationLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.mytypes.duration.Duration]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.mytypes.duration.Duration](_l) { - def seconds: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = field(_.seconds)((c_, f_) => c_.copy(seconds = f_)) + implicit class DurationLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.mytypes.duration.Duration] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.mytypes.duration.Duration](_l) { + def seconds: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = + field(_.seconds)((c_, f_) => c_.copy(seconds = f_)) } final val SECONDS_FIELD_NUMBER = 1 def of( - seconds: _root_.scala.Int + seconds: _root_.scala.Int ): _root_.mytypes.duration.Duration = _root_.mytypes.duration.Duration( seconds ) diff --git a/docs/src/main/scala/generated/mytypes/duration/DurationProto.scala b/docs/src/main/scala/generated/mytypes/duration/DurationProto.scala index 84dc6ef74..e03192a12 100644 --- a/docs/src/main/scala/generated/mytypes/duration/DurationProto.scala +++ b/docs/src/main/scala/generated/mytypes/duration/DurationProto.scala @@ -7,25 +7,37 @@ object DurationProto extends _root_.scalapb.GeneratedFileObject { lazy val dependencies: Seq[_root_.scalapb.GeneratedFileObject] = Seq( _root_.scalapb.options.ScalapbProto ) - lazy val messagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = - Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]]( + lazy val messagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]]( _root_.mytypes.duration.Duration ) private lazy val ProtoBytes: _root_.scala.Array[Byte] = - scalapb.Encoding.fromBase64(scala.collection.immutable.Seq( - """Cg5kdXJhdGlvbi5wcm90bxIHbXl0eXBlcxoVc2NhbGFwYi9zY2FsYXBiLnByb3RvIk8KCER1cmF0aW9uEiYKB3NlY29uZHMYA + scalapb.Encoding.fromBase64( + scala.collection.immutable + .Seq( + """Cg5kdXJhdGlvbi5wcm90bxIHbXl0eXBlcxoVc2NhbGFwYi9zY2FsYXBiLnByb3RvIk8KCER1cmF0aW9uEiYKB3NlY29uZHMYA SABKAVCDOI/CRIHc2Vjb25kc1IHc2Vjb25kczob4j8YIhZteXR5cGVzLk15RHVyYXRpb25UeXBlYgZwcm90bzM=""" - ).mkString) + ) + .mkString + ) lazy val scalaDescriptor: _root_.scalapb.descriptors.FileDescriptor = { val scalaProto = com.google.protobuf.descriptor.FileDescriptorProto.parseFrom(ProtoBytes) - _root_.scalapb.descriptors.FileDescriptor.buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) + _root_.scalapb.descriptors.FileDescriptor + .buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) } lazy val javaDescriptor: com.google.protobuf.Descriptors.FileDescriptor = { val javaProto = com.google.protobuf.DescriptorProtos.FileDescriptorProto.parseFrom(ProtoBytes) - com.google.protobuf.Descriptors.FileDescriptor.buildFrom(javaProto, _root_.scala.Array( - _root_.scalapb.options.ScalapbProto.javaDescriptor - )) + com.google.protobuf.Descriptors.FileDescriptor.buildFrom( + javaProto, + _root_.scala.Array( + _root_.scalapb.options.ScalapbProto.javaDescriptor + ) + ) } - @deprecated("Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", "ScalaPB 0.5.47") + @deprecated( + "Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", + "ScalaPB 0.5.47" + ) def descriptor: com.google.protobuf.Descriptors.FileDescriptor = javaDescriptor -} \ No newline at end of file +} diff --git a/docs/src/main/scala/generated/scalapb/docs/person/Person.scala b/docs/src/main/scala/generated/scalapb/docs/person/Person.scala index b599eb1f8..b8bee1ae3 100644 --- a/docs/src/main/scala/generated/scalapb/docs/person/Person.scala +++ b/docs/src/main/scala/generated/scalapb/docs/person/Person.scala @@ -7,116 +7,131 @@ package scalapb.docs.person final case class Person( name: _root_.scala.Predef.String = "", age: _root_.scala.Int = 0, - addresses: _root_.scala.Seq[_root_.scalapb.docs.person.Person.Address] = _root_.scala.Vector.empty, + addresses: _root_.scala.Seq[_root_.scalapb.docs.person.Person.Address] = + _root_.scala.Vector.empty, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[Person] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - - { - val __value = name - if (!__value.isEmpty) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, __value) - } - }; - - { - val __value = age - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(2, __value) - } - }; - addresses.foreach { __item => - val __value = __item - __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[Person] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + + { + val __value = name + if (!__value.isEmpty) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, __value) } - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size + }; + + { + val __value = age + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(2, __value) } - __size - 1 - + }; + addresses.foreach { __item => + val __value = __item + __size += 1 + _root_.com.google.protobuf.CodedOutputStream + .computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - { - val __v = name - if (!__v.isEmpty) { - _output__.writeString(1, __v) - } - }; - { - val __v = age - if (__v != 0) { - _output__.writeInt32(2, __v) - } - }; - addresses.foreach { __v => - val __m = __v - _output__.writeTag(3, 2) - _output__.writeUInt32NoTag(__m.serializedSize) - __m.writeTo(_output__) - }; - unknownFields.writeTo(_output__) + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def withName(__v: _root_.scala.Predef.String): Person = copy(name = __v) - def withAge(__v: _root_.scala.Int): Person = copy(age = __v) - def clearAddresses = copy(addresses = _root_.scala.Vector.empty) - def addAddresses(__vs: _root_.scalapb.docs.person.Person.Address *): Person = addAllAddresses(__vs) - def addAllAddresses(__vs: Iterable[_root_.scalapb.docs.person.Person.Address]): Person = copy(addresses = addresses ++ __vs) - def withAddresses(__v: _root_.scala.Seq[_root_.scalapb.docs.person.Person.Address]): Person = copy(addresses = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => { - val __t = name - if (__t != "") __t else null - } - case 2 => { - val __t = age - if (__t != 0) __t else null - } - case 3 => addresses + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + { + val __v = name + if (!__v.isEmpty) { + _output__.writeString(1, __v) } - } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PString(name) - case 2 => _root_.scalapb.descriptors.PInt(age) - case 3 => _root_.scalapb.descriptors.PRepeated(addresses.iterator.map(_.toPMessage).toVector) + }; + { + val __v = age + if (__v != 0) { + _output__.writeInt32(2, __v) + } + }; + addresses.foreach { __v => + val __m = __v + _output__.writeTag(3, 2) + _output__.writeUInt32NoTag(__m.serializedSize) + __m.writeTo(_output__) + }; + unknownFields.writeTo(_output__) + } + def withName(__v: _root_.scala.Predef.String): Person = copy(name = __v) + def withAge(__v: _root_.scala.Int): Person = copy(age = __v) + def clearAddresses = copy(addresses = _root_.scala.Vector.empty) + def addAddresses(__vs: _root_.scalapb.docs.person.Person.Address*): Person = addAllAddresses(__vs) + def addAllAddresses(__vs: Iterable[_root_.scalapb.docs.person.Person.Address]): Person = + copy(addresses = addresses ++ __vs) + def withAddresses(__v: _root_.scala.Seq[_root_.scalapb.docs.person.Person.Address]): Person = + copy(addresses = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => { + val __t = name + if (__t != "") __t else null + } + case 2 => { + val __t = age + if (__t != 0) __t else null } + case 3 => addresses } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.docs.person.Person.type = _root_.scalapb.docs.person.Person - // @@protoc_insertion_point(GeneratedMessage[scalapb.docs.Person]) + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => _root_.scalapb.descriptors.PString(name) + case 2 => _root_.scalapb.descriptors.PInt(age) + case 3 => _root_.scalapb.descriptors.PRepeated(addresses.iterator.map(_.toPMessage).toVector) + } + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.docs.person.Person.type = _root_.scalapb.docs.person.Person + // @@protoc_insertion_point(GeneratedMessage[scalapb.docs.Person]) } object Person extends scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.person.Person] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.person.Person] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.docs.person.Person = { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.person.Person] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.docs.person.Person = { var __name: _root_.scala.Predef.String = "" - var __age: _root_.scala.Int = 0 - val __addresses: _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.docs.person.Person.Address] = new _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.docs.person.Person.Address] + var __age: _root_.scala.Int = 0 + val __addresses: _root_.scala.collection.immutable.VectorBuilder[ + _root_.scalapb.docs.person.Person.Address + ] = + new _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.docs.person.Person.Address] var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { - case 0 => _done__ = true + case 0 => _done__ = true case 10 => __name = _input__.readStringRequireUtf8() case 16 => __age = _input__.readInt32() case 26 => - __addresses += _root_.scalapb.LiteParser.readMessage[_root_.scalapb.docs.person.Person.Address](_input__) + __addresses += _root_.scalapb.LiteParser + .readMessage[_root_.scalapb.docs.person.Person.Address](_input__) case tag => if (_unknownFields__ == null) { _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder() @@ -125,192 +140,239 @@ object Person extends scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.pers } } _root_.scalapb.docs.person.Person( - name = __name, - age = __age, - addresses = __addresses.result(), - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + name = __name, + age = __age, + addresses = __addresses.result(), + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.docs.person.Person] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.docs.person.Person( - name = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""), - age = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.Int]).getOrElse(0), - addresses = __fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).map(_.as[_root_.scala.Seq[_root_.scalapb.docs.person.Person.Address]]).getOrElse(_root_.scala.Seq.empty) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.docs.person.PersonProto.javaDescriptor.getMessageTypes().get(0) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.docs.person.PersonProto.scalaDescriptor.messages(0) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = { - var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null - (__number: @_root_.scala.unchecked) match { + implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.docs.person.Person] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.docs.person.Person( + name = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scala.Predef.String]) + .getOrElse(""), + age = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(2).get) + .map(_.as[_root_.scala.Int]) + .getOrElse(0), + addresses = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(3).get) + .map(_.as[_root_.scala.Seq[_root_.scalapb.docs.person.Person.Address]]) + .getOrElse(_root_.scala.Seq.empty) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.docs.person.PersonProto.javaDescriptor.getMessageTypes().get(0) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.docs.person.PersonProto.scalaDescriptor.messages(0) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = { + var __out: _root_.scalapb.GeneratedMessageCompanion[?] = null + (__number: @ _root_.scala.unchecked) match { case 3 => __out = _root_.scalapb.docs.person.Person.Address } __out } - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = - Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]]( + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]]( _root_.scalapb.docs.person.Person.Address ) - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber) + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = throw new MatchError(__fieldNumber) lazy val defaultInstance = _root_.scalapb.docs.person.Person( name = "", age = 0, addresses = _root_.scala.Vector.empty ) - sealed abstract class AddressType(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { - type EnumType = _root_.scalapb.docs.person.Person.AddressType + sealed abstract class AddressType(val value: _root_.scala.Int) + extends _root_.scalapb.GeneratedEnum { + type EnumType = _root_.scalapb.docs.person.Person.AddressType type RecognizedType = _root_.scalapb.docs.person.Person.AddressType.Recognized - def isHome: _root_.scala.Boolean = false - def isWork: _root_.scala.Boolean = false - def companion: _root_.scalapb.GeneratedEnumCompanion[AddressType] = _root_.scalapb.docs.person.Person.AddressType - final def asRecognized: _root_.scala.Option[_root_.scalapb.docs.person.Person.AddressType.Recognized] = if (isUnrecognized) _root_.scala.None else _root_.scala.Some(this.asInstanceOf[_root_.scalapb.docs.person.Person.AddressType.Recognized]) + def isHome: _root_.scala.Boolean = false + def isWork: _root_.scala.Boolean = false + def companion: _root_.scalapb.GeneratedEnumCompanion[AddressType] = + _root_.scalapb.docs.person.Person.AddressType + final def asRecognized + : _root_.scala.Option[_root_.scalapb.docs.person.Person.AddressType.Recognized] = if ( + isUnrecognized + ) _root_.scala.None + else + _root_.scala.Some(this.asInstanceOf[_root_.scalapb.docs.person.Person.AddressType.Recognized]) } - + object AddressType extends _root_.scalapb.GeneratedEnumCompanion[AddressType] { sealed trait Recognized extends AddressType implicit def enumCompanion: _root_.scalapb.GeneratedEnumCompanion[AddressType] = this - + @SerialVersionUID(0L) case object HOME extends AddressType(0) with AddressType.Recognized { - val index = 0 - val name = "HOME" + val index = 0 + val name = "HOME" override def isHome: _root_.scala.Boolean = true } - + @SerialVersionUID(0L) case object WORK extends AddressType(1) with AddressType.Recognized { - val index = 1 - val name = "WORK" + val index = 1 + val name = "WORK" override def isWork: _root_.scala.Boolean = true } - + @SerialVersionUID(0L) - final case class Unrecognized(unrecognizedValue: _root_.scala.Int) extends AddressType(unrecognizedValue) with _root_.scalapb.UnrecognizedEnum - lazy val values: scala.collection.immutable.Seq[ValueType] = scala.collection.immutable.Seq(HOME, WORK) + final case class Unrecognized(unrecognizedValue: _root_.scala.Int) + extends AddressType(unrecognizedValue) + with _root_.scalapb.UnrecognizedEnum + lazy val values: scala.collection.immutable.Seq[ValueType] = + scala.collection.immutable.Seq(HOME, WORK) def fromValue(__value: _root_.scala.Int): AddressType = __value match { - case 0 => HOME - case 1 => WORK + case 0 => HOME + case 1 => WORK case __other => Unrecognized(__other) } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.EnumDescriptor = _root_.scalapb.docs.person.Person.javaDescriptor.getEnumTypes().get(0) - def scalaDescriptor: _root_.scalapb.descriptors.EnumDescriptor = _root_.scalapb.docs.person.Person.scalaDescriptor.enums(0) + def javaDescriptor: _root_.com.google.protobuf.Descriptors.EnumDescriptor = + _root_.scalapb.docs.person.Person.javaDescriptor.getEnumTypes().get(0) + def scalaDescriptor: _root_.scalapb.descriptors.EnumDescriptor = + _root_.scalapb.docs.person.Person.scalaDescriptor.enums(0) } @SerialVersionUID(0L) final case class Address( - addressType: _root_.scalapb.docs.person.Person.AddressType = _root_.scalapb.docs.person.Person.AddressType.HOME, + addressType: _root_.scalapb.docs.person.Person.AddressType = + _root_.scalapb.docs.person.Person.AddressType.HOME, street: _root_.scala.Predef.String = "", city: _root_.scala.Predef.String = "", unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[Address] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - - { - val __value = addressType.value - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(1, __value) - } - }; - - { - val __value = street - if (!__value.isEmpty) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(2, __value) - } - }; - - { - val __value = city - if (!__value.isEmpty) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(3, __value) - } - }; - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size + ) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[Address] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + + { + val __value = addressType.value + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(1, __value) } - __size - 1 - - } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - { - val __v = addressType.value - if (__v != 0) { - _output__.writeEnum(1, __v) - } - }; - { - val __v = street - if (!__v.isEmpty) { - _output__.writeString(2, __v) - } - }; - { - val __v = city - if (!__v.isEmpty) { - _output__.writeString(3, __v) - } - }; - unknownFields.writeTo(_output__) - } - def withAddressType(__v: _root_.scalapb.docs.person.Person.AddressType): Address = copy(addressType = __v) - def withStreet(__v: _root_.scala.Predef.String): Address = copy(street = __v) - def withCity(__v: _root_.scala.Predef.String): Address = copy(city = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => { - val __t = addressType.javaValueDescriptor - if (__t.getNumber() != 0) __t else null - } - case 2 => { - val __t = street - if (__t != "") __t else null - } - case 3 => { - val __t = city - if (__t != "") __t else null - } + }; + + { + val __value = street + if (!__value.isEmpty) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(2, __value) } + }; + + { + val __value = city + if (!__value.isEmpty) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(3, __value) + } + }; + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PEnum(addressType.scalaValueDescriptor) - case 2 => _root_.scalapb.descriptors.PString(street) - case 3 => _root_.scalapb.descriptors.PString(city) + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + { + val __v = addressType.value + if (__v != 0) { + _output__.writeEnum(1, __v) + } + }; + { + val __v = street + if (!__v.isEmpty) { + _output__.writeString(2, __v) + } + }; + { + val __v = city + if (!__v.isEmpty) { + _output__.writeString(3, __v) + } + }; + unknownFields.writeTo(_output__) + } + def withAddressType(__v: _root_.scalapb.docs.person.Person.AddressType): Address = + copy(addressType = __v) + def withStreet(__v: _root_.scala.Predef.String): Address = copy(street = __v) + def withCity(__v: _root_.scala.Predef.String): Address = copy(city = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => { + val __t = addressType.javaValueDescriptor + if (__t.getNumber() != 0) __t else null + } + case 2 => { + val __t = street + if (__t != "") __t else null + } + case 3 => { + val __t = city + if (__t != "") __t else null } } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.docs.person.Person.Address.type = _root_.scalapb.docs.person.Person.Address - // @@protoc_insertion_point(GeneratedMessage[scalapb.docs.Person.Address]) + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => _root_.scalapb.descriptors.PEnum(addressType.scalaValueDescriptor) + case 2 => _root_.scalapb.descriptors.PString(street) + case 3 => _root_.scalapb.descriptors.PString(city) + } + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.docs.person.Person.Address.type = + _root_.scalapb.docs.person.Person.Address + // @@protoc_insertion_point(GeneratedMessage[scalapb.docs.Person.Address]) } - - object Address extends scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.person.Person.Address] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.person.Person.Address] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.docs.person.Person.Address = { - var __addressType: _root_.scalapb.docs.person.Person.AddressType = _root_.scalapb.docs.person.Person.AddressType.HOME - var __street: _root_.scala.Predef.String = "" - var __city: _root_.scala.Predef.String = "" + + object Address + extends scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.person.Person.Address] { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.person.Person.Address] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.docs.person.Person.Address = { + var __addressType: _root_.scalapb.docs.person.Person.AddressType = + _root_.scalapb.docs.person.Person.AddressType.HOME + var __street: _root_.scala.Predef.String = "" + var __city: _root_.scala.Predef.String = "" var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { case 0 => _done__ = true case 8 => - __addressType = _root_.scalapb.docs.person.Person.AddressType.fromValue(_input__.readEnum()) + __addressType = + _root_.scalapb.docs.person.Person.AddressType.fromValue(_input__.readEnum()) case 18 => __street = _input__.readStringRequireUtf8() case 26 => @@ -323,28 +385,55 @@ object Person extends scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.pers } } _root_.scalapb.docs.person.Person.Address( - addressType = __addressType, - street = __street, - city = __city, - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + addressType = __addressType, + street = __street, + city = __city, + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.docs.person.Person.Address] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.docs.person.Person.Address( - addressType = _root_.scalapb.docs.person.Person.AddressType.fromValue(__fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]).getOrElse(_root_.scalapb.docs.person.Person.AddressType.HOME.scalaValueDescriptor).number), - street = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""), - city = __fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).map(_.as[_root_.scala.Predef.String]).getOrElse("") - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.docs.person.Person.javaDescriptor.getNestedTypes().get(0) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.docs.person.Person.scalaDescriptor.nestedMessages(0) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = { - (__fieldNumber: @_root_.scala.unchecked) match { + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.scalapb.docs.person.Person.Address] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.docs.person.Person.Address( + addressType = _root_.scalapb.docs.person.Person.AddressType.fromValue( + __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]) + .getOrElse(_root_.scalapb.docs.person.Person.AddressType.HOME.scalaValueDescriptor) + .number + ), + street = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(2).get) + .map(_.as[_root_.scala.Predef.String]) + .getOrElse(""), + city = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(3).get) + .map(_.as[_root_.scala.Predef.String]) + .getOrElse("") + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.docs.person.Person.javaDescriptor.getNestedTypes().get(0) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.docs.person.Person.scalaDescriptor.nestedMessages(0) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = { + (__fieldNumber: @ _root_.scala.unchecked) match { case 1 => _root_.scalapb.docs.person.Person.AddressType } } @@ -353,18 +442,26 @@ object Person extends scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.pers street = "", city = "" ) - implicit class AddressLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.docs.person.Person.Address]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.docs.person.Person.Address](_l) { - def addressType: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.docs.person.Person.AddressType] = field(_.addressType)((c_, f_) => c_.copy(addressType = f_)) - def street: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.street)((c_, f_) => c_.copy(street = f_)) - def city: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.city)((c_, f_) => c_.copy(city = f_)) + implicit class AddressLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.docs.person.Person.Address] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.docs.person.Person.Address]( + _l + ) { + def addressType + : _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.docs.person.Person.AddressType] = + field(_.addressType)((c_, f_) => c_.copy(addressType = f_)) + def street: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = + field(_.street)((c_, f_) => c_.copy(street = f_)) + def city: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = + field(_.city)((c_, f_) => c_.copy(city = f_)) } final val ADDRESS_TYPE_FIELD_NUMBER = 1 - final val STREET_FIELD_NUMBER = 2 - final val CITY_FIELD_NUMBER = 3 + final val STREET_FIELD_NUMBER = 2 + final val CITY_FIELD_NUMBER = 3 def of( - addressType: _root_.scalapb.docs.person.Person.AddressType, - street: _root_.scala.Predef.String, - city: _root_.scala.Predef.String + addressType: _root_.scalapb.docs.person.Person.AddressType, + street: _root_.scala.Predef.String, + city: _root_.scala.Predef.String ): _root_.scalapb.docs.person.Person.Address = _root_.scalapb.docs.person.Person.Address( addressType, street, @@ -372,19 +469,25 @@ object Person extends scalapb.GeneratedMessageCompanion[_root_.scalapb.docs.pers ) // @@protoc_insertion_point(GeneratedMessageCompanion[scalapb.docs.Person.Address]) } - - implicit class PersonLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.docs.person.Person]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.docs.person.Person](_l) { - def name: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.name)((c_, f_) => c_.copy(name = f_)) - def age: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = field(_.age)((c_, f_) => c_.copy(age = f_)) - def addresses: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[_root_.scalapb.docs.person.Person.Address]] = field(_.addresses)((c_, f_) => c_.copy(addresses = f_)) + + implicit class PersonLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.docs.person.Person] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.docs.person.Person](_l) { + def name: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = + field(_.name)((c_, f_) => c_.copy(name = f_)) + def age: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = + field(_.age)((c_, f_) => c_.copy(age = f_)) + def addresses: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[ + _root_.scalapb.docs.person.Person.Address + ]] = field(_.addresses)((c_, f_) => c_.copy(addresses = f_)) } - final val NAME_FIELD_NUMBER = 1 - final val AGE_FIELD_NUMBER = 2 + final val NAME_FIELD_NUMBER = 1 + final val AGE_FIELD_NUMBER = 2 final val ADDRESSES_FIELD_NUMBER = 3 def of( - name: _root_.scala.Predef.String, - age: _root_.scala.Int, - addresses: _root_.scala.Seq[_root_.scalapb.docs.person.Person.Address] + name: _root_.scala.Predef.String, + age: _root_.scala.Int, + addresses: _root_.scala.Seq[_root_.scalapb.docs.person.Person.Address] ): _root_.scalapb.docs.person.Person = _root_.scalapb.docs.person.Person( name, age, diff --git a/docs/src/main/scala/generated/scalapb/docs/person/PersonProto.scala b/docs/src/main/scala/generated/scalapb/docs/person/PersonProto.scala index 304bb9d60..75d877cbe 100644 --- a/docs/src/main/scala/generated/scalapb/docs/person/PersonProto.scala +++ b/docs/src/main/scala/generated/scalapb/docs/person/PersonProto.scala @@ -5,28 +5,40 @@ package scalapb.docs.person object PersonProto extends _root_.scalapb.GeneratedFileObject { lazy val dependencies: Seq[_root_.scalapb.GeneratedFileObject] = Seq.empty - lazy val messagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = - Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]]( + lazy val messagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]]( _root_.scalapb.docs.person.Person ) private lazy val ProtoBytes: _root_.scala.Array[Byte] = - scalapb.Encoding.fromBase64(scala.collection.immutable.Seq( - """CgxwZXJzb24ucHJvdG8SDHNjYWxhcGIuZG9jcyLvAgoGUGVyc29uEh0KBG5hbWUYASABKAlCCeI/BhIEbmFtZVIEbmFtZRIaC + scalapb.Encoding.fromBase64( + scala.collection.immutable + .Seq( + """CgxwZXJzb24ucHJvdG8SDHNjYWxhcGIuZG9jcyLvAgoGUGVyc29uEh0KBG5hbWUYASABKAlCCeI/BhIEbmFtZVIEbmFtZRIaC gNhZ2UYAiABKAVCCOI/BRIDYWdlUgNhZ2USSgoJYWRkcmVzc2VzGAMgAygLMhwuc2NhbGFwYi5kb2NzLlBlcnNvbi5BZGRyZXNzQ g7iPwsSCWFkZHJlc3Nlc1IJYWRkcmVzc2VzGqQBCgdBZGRyZXNzElUKDGFkZHJlc3NfdHlwZRgBIAEoDjIgLnNjYWxhcGIuZG9jc y5QZXJzb24uQWRkcmVzc1R5cGVCEOI/DRILYWRkcmVzc1R5cGVSC2FkZHJlc3NUeXBlEiMKBnN0cmVldBgCIAEoCUIL4j8IEgZzd HJlZXRSBnN0cmVldBIdCgRjaXR5GAMgASgJQgniPwYSBGNpdHlSBGNpdHkiNwoLQWRkcmVzc1R5cGUSEwoESE9NRRAAGgniPwYSB EhPTUUSEwoEV09SSxABGgniPwYSBFdPUktiBnByb3RvMw==""" - ).mkString) + ) + .mkString + ) lazy val scalaDescriptor: _root_.scalapb.descriptors.FileDescriptor = { val scalaProto = com.google.protobuf.descriptor.FileDescriptorProto.parseFrom(ProtoBytes) - _root_.scalapb.descriptors.FileDescriptor.buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) + _root_.scalapb.descriptors.FileDescriptor + .buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) } lazy val javaDescriptor: com.google.protobuf.Descriptors.FileDescriptor = { val javaProto = com.google.protobuf.DescriptorProtos.FileDescriptorProto.parseFrom(ProtoBytes) - com.google.protobuf.Descriptors.FileDescriptor.buildFrom(javaProto, _root_.scala.Array( - )) + com.google.protobuf.Descriptors.FileDescriptor.buildFrom( + javaProto, + _root_.scala.Array( + ) + ) } - @deprecated("Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", "ScalaPB 0.5.47") + @deprecated( + "Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", + "ScalaPB 0.5.47" + ) def descriptor: com.google.protobuf.Descriptors.FileDescriptor = javaDescriptor -} \ No newline at end of file +} diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala b/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala index 09d98860b..9487afa04 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala @@ -4,58 +4,66 @@ package scalapb.perf.protos sealed abstract class Color(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { - type EnumType = _root_.scalapb.perf.protos.Color + type EnumType = _root_.scalapb.perf.protos.Color type RecognizedType = _root_.scalapb.perf.protos.Color.Recognized - def isUnknown: _root_.scala.Boolean = false - def isRed: _root_.scala.Boolean = false - def isGreen: _root_.scala.Boolean = false - def isBlue: _root_.scala.Boolean = false + def isUnknown: _root_.scala.Boolean = false + def isRed: _root_.scala.Boolean = false + def isGreen: _root_.scala.Boolean = false + def isBlue: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[Color] = _root_.scalapb.perf.protos.Color - final def asRecognized: _root_.scala.Option[_root_.scalapb.perf.protos.Color.Recognized] = if (isUnrecognized) _root_.scala.None else _root_.scala.Some(this.asInstanceOf[_root_.scalapb.perf.protos.Color.Recognized]) + final def asRecognized: _root_.scala.Option[_root_.scalapb.perf.protos.Color.Recognized] = if ( + isUnrecognized + ) _root_.scala.None + else _root_.scala.Some(this.asInstanceOf[_root_.scalapb.perf.protos.Color.Recognized]) } object Color extends _root_.scalapb.GeneratedEnumCompanion[Color] { sealed trait Recognized extends Color implicit def enumCompanion: _root_.scalapb.GeneratedEnumCompanion[Color] = this - + @SerialVersionUID(0L) case object UNKNOWN extends Color(0) with Color.Recognized { - val index = 0 - val name = "UNKNOWN" + val index = 0 + val name = "UNKNOWN" override def isUnknown: _root_.scala.Boolean = true } - + @SerialVersionUID(0L) case object RED extends Color(1) with Color.Recognized { - val index = 1 - val name = "RED" + val index = 1 + val name = "RED" override def isRed: _root_.scala.Boolean = true } - + @SerialVersionUID(0L) case object GREEN extends Color(2) with Color.Recognized { - val index = 2 - val name = "GREEN" + val index = 2 + val name = "GREEN" override def isGreen: _root_.scala.Boolean = true } - + @SerialVersionUID(0L) case object BLUE extends Color(3) with Color.Recognized { - val index = 3 - val name = "BLUE" + val index = 3 + val name = "BLUE" override def isBlue: _root_.scala.Boolean = true } - + @SerialVersionUID(0L) - final case class Unrecognized(unrecognizedValue: _root_.scala.Int) extends Color(unrecognizedValue) with _root_.scalapb.UnrecognizedEnum - lazy val values: scala.collection.immutable.Seq[ValueType] = scala.collection.immutable.Seq(UNKNOWN, RED, GREEN, BLUE) + final case class Unrecognized(unrecognizedValue: _root_.scala.Int) + extends Color(unrecognizedValue) + with _root_.scalapb.UnrecognizedEnum + lazy val values: scala.collection.immutable.Seq[ValueType] = + scala.collection.immutable.Seq(UNKNOWN, RED, GREEN, BLUE) def fromValue(__value: _root_.scala.Int): Color = __value match { - case 0 => UNKNOWN - case 1 => RED - case 2 => GREEN - case 3 => BLUE + case 0 => UNKNOWN + case 1 => RED + case 2 => GREEN + case 3 => BLUE case __other => Unrecognized(__other) } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.EnumDescriptor = _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getEnumTypes().get(0) - def scalaDescriptor: _root_.scalapb.descriptors.EnumDescriptor = _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.enums(0) -} \ No newline at end of file + def javaDescriptor: _root_.com.google.protobuf.Descriptors.EnumDescriptor = + _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getEnumTypes().get(0) + def scalaDescriptor: _root_.scalapb.descriptors.EnumDescriptor = + _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.enums(0) +} diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/Enum.scala b/docs/src/main/scala/generated/scalapb/perf/protos/Enum.scala index 986b21f91..626bb1385 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/Enum.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/Enum.scala @@ -7,67 +7,74 @@ package scalapb.perf.protos final case class Enum( color: _root_.scalapb.perf.protos.Color = _root_.scalapb.perf.protos.Color.UNKNOWN, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[Enum] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - - { - val __value = color.value - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(1, __value) - } - }; - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[Enum] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + + { + val __value = color.value + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(1, __value) } - __size - 1 - - } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - { - val __v = color.value - if (__v != 0) { - _output__.writeEnum(1, __v) - } - }; - unknownFields.writeTo(_output__) + }; + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def withColor(__v: _root_.scalapb.perf.protos.Color): Enum = copy(color = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => { - val __t = color.javaValueDescriptor - if (__t.getNumber() != 0) __t else null - } + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + { + val __v = color.value + if (__v != 0) { + _output__.writeEnum(1, __v) } - } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PEnum(color.scalaValueDescriptor) + }; + unknownFields.writeTo(_output__) + } + def withColor(__v: _root_.scalapb.perf.protos.Color): Enum = copy(color = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => { + val __t = color.javaValueDescriptor + if (__t.getNumber() != 0) __t else null } } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.perf.protos.Enum.type = _root_.scalapb.perf.protos.Enum - // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.Enum]) + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => _root_.scalapb.descriptors.PEnum(color.scalaValueDescriptor) + } + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.perf.protos.Enum.type = _root_.scalapb.perf.protos.Enum + // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.Enum]) } object Enum extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.Enum] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.Enum] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.perf.protos.Enum = { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.Enum] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.perf.protos.Enum = { var __color: _root_.scalapb.perf.protos.Color = _root_.scalapb.perf.protos.Color.UNKNOWN var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { @@ -82,36 +89,59 @@ object Enum extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos } } _root_.scalapb.perf.protos.Enum( - color = __color, - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + color = __color, + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.Enum] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.perf.protos.Enum( - color = _root_.scalapb.perf.protos.Color.fromValue(__fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]).getOrElse(_root_.scalapb.perf.protos.Color.UNKNOWN.scalaValueDescriptor).number) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(2) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(2) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = { - (__fieldNumber: @_root_.scala.unchecked) match { + implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.Enum] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.perf.protos.Enum( + color = _root_.scalapb.perf.protos.Color.fromValue( + __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]) + .getOrElse(_root_.scalapb.perf.protos.Color.UNKNOWN.scalaValueDescriptor) + .number + ) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(2) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(2) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = { + (__fieldNumber: @ _root_.scala.unchecked) match { case 1 => _root_.scalapb.perf.protos.Color } } lazy val defaultInstance = _root_.scalapb.perf.protos.Enum( color = _root_.scalapb.perf.protos.Color.UNKNOWN ) - implicit class EnumLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.Enum]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.Enum](_l) { - def color: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.Color] = field(_.color)((c_, f_) => c_.copy(color = f_)) + implicit class EnumLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.Enum] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.Enum](_l) { + def color: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.Color] = + field(_.color)((c_, f_) => c_.copy(color = f_)) } final val COLOR_FIELD_NUMBER = 1 def of( - color: _root_.scalapb.perf.protos.Color + color: _root_.scalapb.perf.protos.Color ): _root_.scalapb.perf.protos.Enum = _root_.scalapb.perf.protos.Enum( color ) diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/EnumVector.scala b/docs/src/main/scala/generated/scalapb/perf/protos/EnumVector.scala index e773004b6..c591cd928 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/EnumVector.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/EnumVector.scala @@ -7,72 +7,93 @@ package scalapb.perf.protos final case class EnumVector( colors: _root_.scala.Seq[_root_.scalapb.perf.protos.Color] = _root_.scala.Vector.empty, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[EnumVector] { - private[this] def colorsSerializedSize = { - if (__colorsSerializedSizeField == 0) __colorsSerializedSizeField = { - var __s: _root_.scala.Int = 0 - colors.foreach(__i => __s += _root_.com.google.protobuf.CodedOutputStream.computeEnumSizeNoTag(__i.value)) - __s - } - __colorsSerializedSizeField - } - @transient private[this] var __colorsSerializedSizeField: _root_.scala.Int = 0 - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - if (colors.nonEmpty) { - val __localsize = colorsSerializedSize - __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__localsize) + __localsize - } - __size += unknownFields.serializedSize - __size +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[EnumVector] { + private[this] def colorsSerializedSize = { + if (__colorsSerializedSizeField == 0) __colorsSerializedSizeField = { + var __s: _root_.scala.Int = 0 + colors.foreach(__i => + __s += _root_.com.google.protobuf.CodedOutputStream.computeEnumSizeNoTag(__i.value) + ) + __s } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size - } - __size - 1 - + __colorsSerializedSizeField + } + @transient private[this] var __colorsSerializedSizeField: _root_.scala.Int = 0 + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + if (colors.nonEmpty) { + val __localsize = colorsSerializedSize + __size += 1 + _root_.com.google.protobuf.CodedOutputStream + .computeUInt32SizeNoTag(__localsize) + __localsize } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - if (colors.nonEmpty) { - _output__.writeTag(1, 2) - _output__.writeUInt32NoTag(colorsSerializedSize) - colors.foreach((_output__.writeEnumNoTag _).compose((_: _root_.scalapb.perf.protos.Color).value)) - }; - unknownFields.writeTo(_output__) + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def clearColors = copy(colors = _root_.scala.Vector.empty) - def addColors(__vs: _root_.scalapb.perf.protos.Color *): EnumVector = addAllColors(__vs) - def addAllColors(__vs: Iterable[_root_.scalapb.perf.protos.Color]): EnumVector = copy(colors = colors ++ __vs) - def withColors(__v: _root_.scala.Seq[_root_.scalapb.perf.protos.Color]): EnumVector = copy(colors = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => colors.iterator.map(_.javaValueDescriptor).toSeq - } + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + if (colors.nonEmpty) { + _output__.writeTag(1, 2) + _output__.writeUInt32NoTag(colorsSerializedSize) + colors.foreach( + (_output__.writeEnumNoTag _).compose((_: _root_.scalapb.perf.protos.Color).value) + ) + }; + unknownFields.writeTo(_output__) + } + def clearColors = copy(colors = _root_.scala.Vector.empty) + def addColors(__vs: _root_.scalapb.perf.protos.Color*): EnumVector = addAllColors(__vs) + def addAllColors(__vs: Iterable[_root_.scalapb.perf.protos.Color]): EnumVector = + copy(colors = colors ++ __vs) + def withColors(__v: _root_.scala.Seq[_root_.scalapb.perf.protos.Color]): EnumVector = + copy(colors = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => colors.iterator.map(_.javaValueDescriptor).toSeq } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PRepeated(colors.iterator.map(__e => _root_.scalapb.descriptors.PEnum(__e.scalaValueDescriptor)).toVector) - } + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => + _root_.scalapb.descriptors.PRepeated( + colors.iterator + .map(__e => _root_.scalapb.descriptors.PEnum(__e.scalaValueDescriptor)) + .toVector + ) } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.perf.protos.EnumVector.type = _root_.scalapb.perf.protos.EnumVector - // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.EnumVector]) + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.perf.protos.EnumVector.type = _root_.scalapb.perf.protos.EnumVector + // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.EnumVector]) } object EnumVector extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.EnumVector] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.EnumVector] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.perf.protos.EnumVector = { - val __colors: _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.perf.protos.Color] = new _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.perf.protos.Color] + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.EnumVector] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.perf.protos.EnumVector = { + val __colors + : _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.perf.protos.Color] = + new _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.perf.protos.Color] var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { @@ -80,7 +101,7 @@ object EnumVector extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf. case 8 => __colors += _root_.scalapb.perf.protos.Color.fromValue(_input__.readEnum()) case 10 => { - val length = _input__.readRawVarint32() + val length = _input__.readRawVarint32() val oldLimit = _input__.pushLimit(length) while (_input__.getBytesUntilLimit > 0) { __colors += _root_.scalapb.perf.protos.Color.fromValue(_input__.readEnum()) @@ -95,36 +116,61 @@ object EnumVector extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf. } } _root_.scalapb.perf.protos.EnumVector( - colors = __colors.result(), - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + colors = __colors.result(), + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.EnumVector] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.perf.protos.EnumVector( - colors = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Seq[_root_.scalapb.descriptors.EnumValueDescriptor]]).getOrElse(_root_.scala.Seq.empty).iterator.map(__e => _root_.scalapb.perf.protos.Color.fromValue(__e.number)).toSeq - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(3) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(3) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = { - (__fieldNumber: @_root_.scala.unchecked) match { + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.EnumVector] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.perf.protos.EnumVector( + colors = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scala.Seq[_root_.scalapb.descriptors.EnumValueDescriptor]]) + .getOrElse(_root_.scala.Seq.empty) + .iterator + .map(__e => _root_.scalapb.perf.protos.Color.fromValue(__e.number)) + .toSeq + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(3) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(3) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = { + (__fieldNumber: @ _root_.scala.unchecked) match { case 1 => _root_.scalapb.perf.protos.Color } } lazy val defaultInstance = _root_.scalapb.perf.protos.EnumVector( colors = _root_.scala.Vector.empty ) - implicit class EnumVectorLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.EnumVector]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.EnumVector](_l) { - def colors: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[_root_.scalapb.perf.protos.Color]] = field(_.colors)((c_, f_) => c_.copy(colors = f_)) + implicit class EnumVectorLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.EnumVector] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.EnumVector](_l) { + def colors + : _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[_root_.scalapb.perf.protos.Color]] = + field(_.colors)((c_, f_) => c_.copy(colors = f_)) } final val COLORS_FIELD_NUMBER = 1 def of( - colors: _root_.scala.Seq[_root_.scalapb.perf.protos.Color] + colors: _root_.scala.Seq[_root_.scalapb.perf.protos.Color] ): _root_.scalapb.perf.protos.EnumVector = _root_.scalapb.perf.protos.EnumVector( colors ) diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/IntVector.scala b/docs/src/main/scala/generated/scalapb/perf/protos/IntVector.scala index baeee7cf8..e6d4d2e83 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/IntVector.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/IntVector.scala @@ -7,72 +7,86 @@ package scalapb.perf.protos final case class IntVector( ints: _root_.scala.Seq[_root_.scala.Int] = _root_.scala.Vector.empty, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[IntVector] { - private[this] def intsSerializedSize = { - if (__intsSerializedSizeField == 0) __intsSerializedSizeField = { - var __s: _root_.scala.Int = 0 - ints.foreach(__i => __s += _root_.com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(__i)) - __s - } - __intsSerializedSizeField - } - @transient private[this] var __intsSerializedSizeField: _root_.scala.Int = 0 - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - if (ints.nonEmpty) { - val __localsize = intsSerializedSize - __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__localsize) + __localsize - } - __size += unknownFields.serializedSize - __size +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[IntVector] { + private[this] def intsSerializedSize = { + if (__intsSerializedSizeField == 0) __intsSerializedSizeField = { + var __s: _root_.scala.Int = 0 + ints.foreach(__i => + __s += _root_.com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(__i) + ) + __s } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size - } - __size - 1 - + __intsSerializedSizeField + } + @transient private[this] var __intsSerializedSizeField: _root_.scala.Int = 0 + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + if (ints.nonEmpty) { + val __localsize = intsSerializedSize + __size += 1 + _root_.com.google.protobuf.CodedOutputStream + .computeUInt32SizeNoTag(__localsize) + __localsize } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - if (ints.nonEmpty) { - _output__.writeTag(1, 2) - _output__.writeUInt32NoTag(intsSerializedSize) - ints.foreach(_output__.writeInt32NoTag) - }; - unknownFields.writeTo(_output__) + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def clearInts = copy(ints = _root_.scala.Vector.empty) - def addInts(__vs: _root_.scala.Int *): IntVector = addAllInts(__vs) - def addAllInts(__vs: Iterable[_root_.scala.Int]): IntVector = copy(ints = ints ++ __vs) - def withInts(__v: _root_.scala.Seq[_root_.scala.Int]): IntVector = copy(ints = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => ints - } + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + if (ints.nonEmpty) { + _output__.writeTag(1, 2) + _output__.writeUInt32NoTag(intsSerializedSize) + ints.foreach(_output__.writeInt32NoTag) + }; + unknownFields.writeTo(_output__) + } + def clearInts = copy(ints = _root_.scala.Vector.empty) + def addInts(__vs: _root_.scala.Int*): IntVector = addAllInts(__vs) + def addAllInts(__vs: Iterable[_root_.scala.Int]): IntVector = copy(ints = ints ++ __vs) + def withInts(__v: _root_.scala.Seq[_root_.scala.Int]): IntVector = copy(ints = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => ints } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PRepeated(ints.iterator.map(_root_.scalapb.descriptors.PInt(_)).toVector) - } + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => + _root_.scalapb.descriptors.PRepeated( + ints.iterator.map(_root_.scalapb.descriptors.PInt(_)).toVector + ) } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.perf.protos.IntVector.type = _root_.scalapb.perf.protos.IntVector - // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.IntVector]) + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.perf.protos.IntVector.type = _root_.scalapb.perf.protos.IntVector + // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.IntVector]) } object IntVector extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.IntVector] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.IntVector] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.perf.protos.IntVector = { - val __ints: _root_.scala.collection.immutable.VectorBuilder[_root_.scala.Int] = new _root_.scala.collection.immutable.VectorBuilder[_root_.scala.Int] + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.IntVector] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.perf.protos.IntVector = { + val __ints: _root_.scala.collection.immutable.VectorBuilder[_root_.scala.Int] = + new _root_.scala.collection.immutable.VectorBuilder[_root_.scala.Int] var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { @@ -80,7 +94,7 @@ object IntVector extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.p case 8 => __ints += _input__.readInt32() case 10 => { - val length = _input__.readRawVarint32() + val length = _input__.readRawVarint32() val oldLimit = _input__.pushLimit(length) while (_input__.getBytesUntilLimit > 0) { __ints += _input__.readInt32() @@ -95,32 +109,53 @@ object IntVector extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.p } } _root_.scalapb.perf.protos.IntVector( - ints = __ints.result(), - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + ints = __ints.result(), + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.IntVector] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.perf.protos.IntVector( - ints = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Seq[_root_.scala.Int]]).getOrElse(_root_.scala.Seq.empty) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(4) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(4) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber) + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.IntVector] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.perf.protos.IntVector( + ints = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scala.Seq[_root_.scala.Int]]) + .getOrElse(_root_.scala.Seq.empty) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(4) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(4) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = throw new MatchError(__fieldNumber) lazy val defaultInstance = _root_.scalapb.perf.protos.IntVector( ints = _root_.scala.Vector.empty ) - implicit class IntVectorLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.IntVector]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.IntVector](_l) { - def ints: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[_root_.scala.Int]] = field(_.ints)((c_, f_) => c_.copy(ints = f_)) + implicit class IntVectorLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.IntVector] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.IntVector](_l) { + def ints: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[_root_.scala.Int]] = + field(_.ints)((c_, f_) => c_.copy(ints = f_)) } final val INTS_FIELD_NUMBER = 1 def of( - ints: _root_.scala.Seq[_root_.scala.Int] + ints: _root_.scala.Seq[_root_.scala.Int] ): _root_.scalapb.perf.protos.IntVector = _root_.scalapb.perf.protos.IntVector( ints ) diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/MessageContainer.scala b/docs/src/main/scala/generated/scalapb/perf/protos/MessageContainer.scala index 11497d68b..e31162d62 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/MessageContainer.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/MessageContainer.scala @@ -4,95 +4,119 @@ package scalapb.perf.protos /** @param rep - * [(scalapb.field).collection_type="List"]; + * [(scalapb.field).collection_type="List"]; */ @SerialVersionUID(0L) final case class MessageContainer( opt: _root_.scala.Option[_root_.scalapb.perf.protos.SimpleMessage] = _root_.scala.None, rep: _root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage] = _root_.scala.Vector.empty, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[MessageContainer] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - if (opt.isDefined) { - val __value = opt.get - __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize - }; - rep.foreach { __item => - val __value = __item - __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize - } - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size - } - __size - 1 - +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[MessageContainer] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + if (opt.isDefined) { + val __value = opt.get + __size += 1 + _root_.com.google.protobuf.CodedOutputStream + .computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize + }; + rep.foreach { __item => + val __value = __item + __size += 1 + _root_.com.google.protobuf.CodedOutputStream + .computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - opt.foreach { __v => - val __m = __v - _output__.writeTag(1, 2) - _output__.writeUInt32NoTag(__m.serializedSize) - __m.writeTo(_output__) - }; - rep.foreach { __v => - val __m = __v - _output__.writeTag(2, 2) - _output__.writeUInt32NoTag(__m.serializedSize) - __m.writeTo(_output__) - }; - unknownFields.writeTo(_output__) + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def getOpt: _root_.scalapb.perf.protos.SimpleMessage = opt.getOrElse(_root_.scalapb.perf.protos.SimpleMessage.defaultInstance) - def clearOpt: MessageContainer = copy(opt = _root_.scala.None) - def withOpt(__v: _root_.scalapb.perf.protos.SimpleMessage): MessageContainer = copy(opt = _root_.scala.Option(__v)) - def clearRep = copy(rep = _root_.scala.Vector.empty) - def addRep(__vs: _root_.scalapb.perf.protos.SimpleMessage *): MessageContainer = addAllRep(__vs) - def addAllRep(__vs: Iterable[_root_.scalapb.perf.protos.SimpleMessage]): MessageContainer = copy(rep = rep ++ __vs) - def withRep(__v: _root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage]): MessageContainer = copy(rep = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => opt.orNull - case 2 => rep - } + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + opt.foreach { __v => + val __m = __v + _output__.writeTag(1, 2) + _output__.writeUInt32NoTag(__m.serializedSize) + __m.writeTo(_output__) + }; + rep.foreach { __v => + val __m = __v + _output__.writeTag(2, 2) + _output__.writeUInt32NoTag(__m.serializedSize) + __m.writeTo(_output__) + }; + unknownFields.writeTo(_output__) + } + def getOpt: _root_.scalapb.perf.protos.SimpleMessage = + opt.getOrElse(_root_.scalapb.perf.protos.SimpleMessage.defaultInstance) + def clearOpt: MessageContainer = copy(opt = _root_.scala.None) + def withOpt(__v: _root_.scalapb.perf.protos.SimpleMessage): MessageContainer = + copy(opt = _root_.scala.Option(__v)) + def clearRep = copy(rep = _root_.scala.Vector.empty) + def addRep(__vs: _root_.scalapb.perf.protos.SimpleMessage*): MessageContainer = addAllRep(__vs) + def addAllRep(__vs: Iterable[_root_.scalapb.perf.protos.SimpleMessage]): MessageContainer = + copy(rep = rep ++ __vs) + def withRep(__v: _root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage]): MessageContainer = + copy(rep = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => opt.orNull + case 2 => rep } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => opt.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty) - case 2 => _root_.scalapb.descriptors.PRepeated(rep.iterator.map(_.toPMessage).toVector) - } + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => opt.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty) + case 2 => _root_.scalapb.descriptors.PRepeated(rep.iterator.map(_.toPMessage).toVector) } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.perf.protos.MessageContainer.type = _root_.scalapb.perf.protos.MessageContainer - // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.MessageContainer]) + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.perf.protos.MessageContainer.type = + _root_.scalapb.perf.protos.MessageContainer + // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.MessageContainer]) } -object MessageContainer extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.MessageContainer] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.MessageContainer] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.perf.protos.MessageContainer = { +object MessageContainer + extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.MessageContainer] { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.MessageContainer] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.perf.protos.MessageContainer = { var __opt: _root_.scala.Option[_root_.scalapb.perf.protos.SimpleMessage] = _root_.scala.None - val __rep: _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.perf.protos.SimpleMessage] = new _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.perf.protos.SimpleMessage] + val __rep: _root_.scala.collection.immutable.VectorBuilder[ + _root_.scalapb.perf.protos.SimpleMessage + ] = + new _root_.scala.collection.immutable.VectorBuilder[_root_.scalapb.perf.protos.SimpleMessage] var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { - case 0 => _done__ = true + case 0 => _done__ = true case 10 => - __opt = _root_.scala.Option(__opt.fold(_root_.scalapb.LiteParser.readMessage[_root_.scalapb.perf.protos.SimpleMessage](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _))) + __opt = _root_.scala.Option( + __opt.fold( + _root_.scalapb.LiteParser + .readMessage[_root_.scalapb.perf.protos.SimpleMessage](_input__) + )(_root_.scalapb.LiteParser.readMessage(_input__, _)) + ) case 18 => - __rep += _root_.scalapb.LiteParser.readMessage[_root_.scalapb.perf.protos.SimpleMessage](_input__) + __rep += _root_.scalapb.LiteParser + .readMessage[_root_.scalapb.perf.protos.SimpleMessage](_input__) case tag => if (_unknownFields__ == null) { _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder() @@ -101,46 +125,75 @@ object MessageContainer extends scalapb.GeneratedMessageCompanion[_root_.scalapb } } _root_.scalapb.perf.protos.MessageContainer( - opt = __opt, - rep = __rep.result(), - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + opt = __opt, + rep = __rep.result(), + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.MessageContainer] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.perf.protos.MessageContainer( - opt = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).flatMap(_.as[_root_.scala.Option[_root_.scalapb.perf.protos.SimpleMessage]]), - rep = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage]]).getOrElse(_root_.scala.Seq.empty) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(1) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(1) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = { - var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null - (__number: @_root_.scala.unchecked) match { + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.MessageContainer] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.perf.protos.MessageContainer( + opt = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .flatMap(_.as[_root_.scala.Option[_root_.scalapb.perf.protos.SimpleMessage]]), + rep = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(2).get) + .map(_.as[_root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage]]) + .getOrElse(_root_.scala.Seq.empty) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(1) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(1) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = { + var __out: _root_.scalapb.GeneratedMessageCompanion[?] = null + (__number: @ _root_.scala.unchecked) match { case 1 => __out = _root_.scalapb.perf.protos.SimpleMessage case 2 => __out = _root_.scalapb.perf.protos.SimpleMessage } __out } - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = throw new MatchError(__fieldNumber) lazy val defaultInstance = _root_.scalapb.perf.protos.MessageContainer( opt = _root_.scala.None, rep = _root_.scala.Vector.empty ) - implicit class MessageContainerLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.MessageContainer]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.MessageContainer](_l) { - def opt: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.SimpleMessage] = field(_.getOpt)((c_, f_) => c_.copy(opt = _root_.scala.Option(f_))) - def optionalOpt: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[_root_.scalapb.perf.protos.SimpleMessage]] = field(_.opt)((c_, f_) => c_.copy(opt = f_)) - def rep: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage]] = field(_.rep)((c_, f_) => c_.copy(rep = f_)) + implicit class MessageContainerLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.MessageContainer] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.MessageContainer]( + _l + ) { + def opt: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.SimpleMessage] = + field(_.getOpt)((c_, f_) => c_.copy(opt = _root_.scala.Option(f_))) + def optionalOpt: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[ + _root_.scalapb.perf.protos.SimpleMessage + ]] = field(_.opt)((c_, f_) => c_.copy(opt = f_)) + def rep: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Seq[ + _root_.scalapb.perf.protos.SimpleMessage + ]] = field(_.rep)((c_, f_) => c_.copy(rep = f_)) } final val OPT_FIELD_NUMBER = 1 final val REP_FIELD_NUMBER = 2 def of( - opt: _root_.scala.Option[_root_.scalapb.perf.protos.SimpleMessage], - rep: _root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage] + opt: _root_.scala.Option[_root_.scalapb.perf.protos.SimpleMessage], + rep: _root_.scala.Seq[_root_.scalapb.perf.protos.SimpleMessage] ): _root_.scalapb.perf.protos.MessageContainer = _root_.scalapb.perf.protos.MessageContainer( opt, rep diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/ProtosProto.scala b/docs/src/main/scala/generated/scalapb/perf/protos/ProtosProto.scala index 5812ad8bf..fe439e4f0 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/ProtosProto.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/ProtosProto.scala @@ -7,8 +7,9 @@ object ProtosProto extends _root_.scalapb.GeneratedFileObject { lazy val dependencies: Seq[_root_.scalapb.GeneratedFileObject] = Seq( _root_.scalapb.options.ScalapbProto ) - lazy val messagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = - Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]]( + lazy val messagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]]( _root_.scalapb.perf.protos.SimpleMessage, _root_.scalapb.perf.protos.MessageContainer, _root_.scalapb.perf.protos.Enum, @@ -17,8 +18,10 @@ object ProtosProto extends _root_.scalapb.GeneratedFileObject { _root_.scalapb.perf.protos.StringMessage ) private lazy val ProtoBytes: _root_.scala.Array[Byte] = - scalapb.Encoding.fromBase64(scala.collection.immutable.Seq( - """Cgxwcm90b3MucHJvdG8SDHNjYWxhcGIucGVyZhoVc2NhbGFwYi9zY2FsYXBiLnByb3RvIogBCg1TaW1wbGVNZXNzYWdlEhQKA + scalapb.Encoding.fromBase64( + scala.collection.immutable + .Seq( + """Cgxwcm90b3MucHJvdG8SDHNjYWxhcGIucGVyZhoVc2NhbGFwYi9zY2FsYXBiLnByb3RvIogBCg1TaW1wbGVNZXNzYWdlEhQKA WkYASABKAVCBuI/AxIBaVIBaRIUCgFqGAIgASgFQgbiPwMSAWpSAWoSFAoBaxgDIAEoDEIG4j8DEgFrUgFrEjUKBWNvbG9yGAQgA SgOMhMuc2NhbGFwYi5wZXJmLkNvbG9yQgriPwcSBWNvbG9yUgVjb2xvciKEAQoQTWVzc2FnZUNvbnRhaW5lchI3CgNvcHQYASABK AsyGy5zY2FsYXBiLnBlcmYuU2ltcGxlTWVzc2FnZUII4j8FEgNvcHRSA29wdBI3CgNyZXAYAiADKAsyGy5zY2FsYXBiLnBlcmYuU @@ -42,17 +45,26 @@ object ProtosProto extends _root_.scalapb.GeneratedFileObject { AESAyYIEQoLCgQEBAIAEgMnAhoKDAoFBAQCAAQSAycCCgoMCgUEBAIABRIDJwsQCgwKBQQEAgABEgMnERUKDAoFBAQCAAMSAycYG QoKCgIEBRIEKgAtAQoKCgMEBQESAyoIFQoLCgQEBQIAEgMrAhIKDAoFBAUCAAUSAysCCAoMCgUEBQIAARIDKwkNCgwKBQQFAgADE gMrEBEKCwoEBAUCARIDLAISCgwKBQQFAgEFEgMsAggKDAoFBAUCAQESAywJDQoMCgUEBQIBAxIDLBARYgZwcm90bzM=""" - ).mkString) + ) + .mkString + ) lazy val scalaDescriptor: _root_.scalapb.descriptors.FileDescriptor = { val scalaProto = com.google.protobuf.descriptor.FileDescriptorProto.parseFrom(ProtoBytes) - _root_.scalapb.descriptors.FileDescriptor.buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) + _root_.scalapb.descriptors.FileDescriptor + .buildFrom(scalaProto, dependencies.map(_.scalaDescriptor)) } lazy val javaDescriptor: com.google.protobuf.Descriptors.FileDescriptor = { val javaProto = com.google.protobuf.DescriptorProtos.FileDescriptorProto.parseFrom(ProtoBytes) - com.google.protobuf.Descriptors.FileDescriptor.buildFrom(javaProto, _root_.scala.Array( - _root_.scalapb.options.ScalapbProto.javaDescriptor - )) + com.google.protobuf.Descriptors.FileDescriptor.buildFrom( + javaProto, + _root_.scala.Array( + _root_.scalapb.options.ScalapbProto.javaDescriptor + ) + ) } - @deprecated("Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", "ScalaPB 0.5.47") + @deprecated( + "Use javaDescriptor instead. In a future version this will refer to scalaDescriptor.", + "ScalaPB 0.5.47" + ) def descriptor: com.google.protobuf.Descriptors.FileDescriptor = javaDescriptor -} \ No newline at end of file +} diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/SimpleMessage.scala b/docs/src/main/scala/generated/scalapb/perf/protos/SimpleMessage.scala index 0985e6526..ccc990e18 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/SimpleMessage.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/SimpleMessage.scala @@ -10,127 +10,136 @@ final case class SimpleMessage( k: _root_.com.google.protobuf.ByteString = _root_.com.google.protobuf.ByteString.EMPTY, color: _root_.scalapb.perf.protos.Color = _root_.scalapb.perf.protos.Color.UNKNOWN, unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[SimpleMessage] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - - { - val __value = i - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(1, __value) - } - }; - - { - val __value = j - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(2, __value) - } - }; - - { - val __value = k - if (!__value.isEmpty) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeBytesSize(3, __value) - } - }; - - { - val __value = color.value - if (__value != 0) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(4, __value) - } - }; - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[SimpleMessage] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + + { + val __value = i + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(1, __value) } - __size - 1 - - } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - { - val __v = i - if (__v != 0) { - _output__.writeInt32(1, __v) - } - }; - { - val __v = j - if (__v != 0) { - _output__.writeInt32(2, __v) - } - }; - { - val __v = k - if (!__v.isEmpty) { - _output__.writeBytes(3, __v) - } - }; - { - val __v = color.value - if (__v != 0) { - _output__.writeEnum(4, __v) - } - }; - unknownFields.writeTo(_output__) - } - def withI(__v: _root_.scala.Int): SimpleMessage = copy(i = __v) - def withJ(__v: _root_.scala.Int): SimpleMessage = copy(j = __v) - def withK(__v: _root_.com.google.protobuf.ByteString): SimpleMessage = copy(k = __v) - def withColor(__v: _root_.scalapb.perf.protos.Color): SimpleMessage = copy(color = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => { - val __t = i - if (__t != 0) __t else null - } - case 2 => { - val __t = j - if (__t != 0) __t else null - } - case 3 => { - val __t = k - if (__t != _root_.com.google.protobuf.ByteString.EMPTY) __t else null - } - case 4 => { - val __t = color.javaValueDescriptor - if (__t.getNumber() != 0) __t else null - } + }; + + { + val __value = j + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(2, __value) + } + }; + + { + val __value = k + if (!__value.isEmpty) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeBytesSize(3, __value) } + }; + + { + val __value = color.value + if (__value != 0) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(4, __value) + } + }; + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PInt(i) - case 2 => _root_.scalapb.descriptors.PInt(j) - case 3 => _root_.scalapb.descriptors.PByteString(k) - case 4 => _root_.scalapb.descriptors.PEnum(color.scalaValueDescriptor) + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + { + val __v = i + if (__v != 0) { + _output__.writeInt32(1, __v) + } + }; + { + val __v = j + if (__v != 0) { + _output__.writeInt32(2, __v) } + }; + { + val __v = k + if (!__v.isEmpty) { + _output__.writeBytes(3, __v) + } + }; + { + val __v = color.value + if (__v != 0) { + _output__.writeEnum(4, __v) + } + }; + unknownFields.writeTo(_output__) + } + def withI(__v: _root_.scala.Int): SimpleMessage = copy(i = __v) + def withJ(__v: _root_.scala.Int): SimpleMessage = copy(j = __v) + def withK(__v: _root_.com.google.protobuf.ByteString): SimpleMessage = copy(k = __v) + def withColor(__v: _root_.scalapb.perf.protos.Color): SimpleMessage = copy(color = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => { + val __t = i + if (__t != 0) __t else null + } + case 2 => { + val __t = j + if (__t != 0) __t else null + } + case 3 => { + val __t = k + if (__t != _root_.com.google.protobuf.ByteString.EMPTY) __t else null + } + case 4 => { + val __t = color.javaValueDescriptor + if (__t.getNumber() != 0) __t else null + } + } + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => _root_.scalapb.descriptors.PInt(i) + case 2 => _root_.scalapb.descriptors.PInt(j) + case 3 => _root_.scalapb.descriptors.PByteString(k) + case 4 => _root_.scalapb.descriptors.PEnum(color.scalaValueDescriptor) } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.perf.protos.SimpleMessage.type = _root_.scalapb.perf.protos.SimpleMessage - // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.SimpleMessage]) + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.perf.protos.SimpleMessage.type = + _root_.scalapb.perf.protos.SimpleMessage + // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.SimpleMessage]) } -object SimpleMessage extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.SimpleMessage] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.SimpleMessage] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.perf.protos.SimpleMessage = { - var __i: _root_.scala.Int = 0 - var __j: _root_.scala.Int = 0 +object SimpleMessage + extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.SimpleMessage] { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.SimpleMessage] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.perf.protos.SimpleMessage = { + var __i: _root_.scala.Int = 0 + var __j: _root_.scala.Int = 0 var __k: _root_.com.google.protobuf.ByteString = _root_.com.google.protobuf.ByteString.EMPTY - var __color: _root_.scalapb.perf.protos.Color = _root_.scalapb.perf.protos.Color.UNKNOWN + var __color: _root_.scalapb.perf.protos.Color = _root_.scalapb.perf.protos.Color.UNKNOWN var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { @@ -151,30 +160,60 @@ object SimpleMessage extends scalapb.GeneratedMessageCompanion[_root_.scalapb.pe } } _root_.scalapb.perf.protos.SimpleMessage( - i = __i, - j = __j, - k = __k, - color = __color, - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + i = __i, + j = __j, + k = __k, + color = __color, + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.SimpleMessage] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.perf.protos.SimpleMessage( - i = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Int]).getOrElse(0), - j = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.Int]).getOrElse(0), - k = __fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).map(_.as[_root_.com.google.protobuf.ByteString]).getOrElse(_root_.com.google.protobuf.ByteString.EMPTY), - color = _root_.scalapb.perf.protos.Color.fromValue(__fieldsMap.get(scalaDescriptor.findFieldByNumber(4).get).map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]).getOrElse(_root_.scalapb.perf.protos.Color.UNKNOWN.scalaValueDescriptor).number) - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(0) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(0) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = { - (__fieldNumber: @_root_.scala.unchecked) match { + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.SimpleMessage] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.perf.protos.SimpleMessage( + i = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scala.Int]) + .getOrElse(0), + j = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(2).get) + .map(_.as[_root_.scala.Int]) + .getOrElse(0), + k = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(3).get) + .map(_.as[_root_.com.google.protobuf.ByteString]) + .getOrElse(_root_.com.google.protobuf.ByteString.EMPTY), + color = _root_.scalapb.perf.protos.Color.fromValue( + __fieldsMap + .get(scalaDescriptor.findFieldByNumber(4).get) + .map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]) + .getOrElse(_root_.scalapb.perf.protos.Color.UNKNOWN.scalaValueDescriptor) + .number + ) + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(0) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(0) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = { + (__fieldNumber: @ _root_.scala.unchecked) match { case 4 => _root_.scalapb.perf.protos.Color } } @@ -184,21 +223,29 @@ object SimpleMessage extends scalapb.GeneratedMessageCompanion[_root_.scalapb.pe k = _root_.com.google.protobuf.ByteString.EMPTY, color = _root_.scalapb.perf.protos.Color.UNKNOWN ) - implicit class SimpleMessageLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.SimpleMessage]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.SimpleMessage](_l) { - def i: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = field(_.i)((c_, f_) => c_.copy(i = f_)) - def j: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = field(_.j)((c_, f_) => c_.copy(j = f_)) - def k: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.google.protobuf.ByteString] = field(_.k)((c_, f_) => c_.copy(k = f_)) - def color: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.Color] = field(_.color)((c_, f_) => c_.copy(color = f_)) + implicit class SimpleMessageLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.SimpleMessage] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.SimpleMessage]( + _l + ) { + def i: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = + field(_.i)((c_, f_) => c_.copy(i = f_)) + def j: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = + field(_.j)((c_, f_) => c_.copy(j = f_)) + def k: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.google.protobuf.ByteString] = + field(_.k)((c_, f_) => c_.copy(k = f_)) + def color: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.Color] = + field(_.color)((c_, f_) => c_.copy(color = f_)) } - final val I_FIELD_NUMBER = 1 - final val J_FIELD_NUMBER = 2 - final val K_FIELD_NUMBER = 3 + final val I_FIELD_NUMBER = 1 + final val J_FIELD_NUMBER = 2 + final val K_FIELD_NUMBER = 3 final val COLOR_FIELD_NUMBER = 4 def of( - i: _root_.scala.Int, - j: _root_.scala.Int, - k: _root_.com.google.protobuf.ByteString, - color: _root_.scalapb.perf.protos.Color + i: _root_.scala.Int, + j: _root_.scala.Int, + k: _root_.com.google.protobuf.ByteString, + color: _root_.scalapb.perf.protos.Color ): _root_.scalapb.perf.protos.SimpleMessage = _root_.scalapb.perf.protos.SimpleMessage( i, j, diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/StringMessage.scala b/docs/src/main/scala/generated/scalapb/perf/protos/StringMessage.scala index 04ec6ff5e..8a4d23ddc 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/StringMessage.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/StringMessage.scala @@ -8,91 +8,100 @@ final case class StringMessage( str1: _root_.scala.Predef.String = "", str2: _root_.scala.Predef.String = "", unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty - ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[StringMessage] { - @transient - private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 - private[this] def __computeSerializedSize(): _root_.scala.Int = { - var __size = 0 - - { - val __value = str1 - if (!__value.isEmpty) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, __value) - } - }; - - { - val __value = str2 - if (!__value.isEmpty) { - __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(2, __value) - } - }; - __size += unknownFields.serializedSize - __size - } - override def serializedSize: _root_.scala.Int = { - var __size = __serializedSizeMemoized - if (__size == 0) { - __size = __computeSerializedSize() + 1 - __serializedSizeMemoized = __size +) extends scalapb.GeneratedMessage + with scalapb.lenses.Updatable[StringMessage] { + @transient + private[this] var __serializedSizeMemoized: _root_.scala.Int = 0 + private[this] def __computeSerializedSize(): _root_.scala.Int = { + var __size = 0 + + { + val __value = str1 + if (!__value.isEmpty) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, __value) } - __size - 1 - - } - def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { - { - val __v = str1 - if (!__v.isEmpty) { - _output__.writeString(1, __v) - } - }; - { - val __v = str2 - if (!__v.isEmpty) { - _output__.writeString(2, __v) - } - }; - unknownFields.writeTo(_output__) - } - def withStr1(__v: _root_.scala.Predef.String): StringMessage = copy(str1 = __v) - def withStr2(__v: _root_.scala.Predef.String): StringMessage = copy(str2 = __v) - def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) - def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) - def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { - (__fieldNumber: @_root_.scala.unchecked) match { - case 1 => { - val __t = str1 - if (__t != "") __t else null - } - case 2 => { - val __t = str2 - if (__t != "") __t else null - } + }; + + { + val __value = str2 + if (!__value.isEmpty) { + __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(2, __value) } + }; + __size += unknownFields.serializedSize + __size + } + override def serializedSize: _root_.scala.Int = { + var __size = __serializedSizeMemoized + if (__size == 0) { + __size = __computeSerializedSize() + 1 + __serializedSizeMemoized = __size } - def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = { - _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) - (__field.number: @_root_.scala.unchecked) match { - case 1 => _root_.scalapb.descriptors.PString(str1) - case 2 => _root_.scalapb.descriptors.PString(str2) + __size - 1 + + } + def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = { + { + val __v = str1 + if (!__v.isEmpty) { + _output__.writeString(1, __v) + } + }; + { + val __v = str2 + if (!__v.isEmpty) { + _output__.writeString(2, __v) } + }; + unknownFields.writeTo(_output__) + } + def withStr1(__v: _root_.scala.Predef.String): StringMessage = copy(str1 = __v) + def withStr2(__v: _root_.scala.Predef.String): StringMessage = copy(str2 = __v) + def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v) + def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty) + def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = { + (__fieldNumber: @ _root_.scala.unchecked) match { + case 1 => { + val __t = str1 + if (__t != "") __t else null + } + case 2 => { + val __t = str2 + if (__t != "") __t else null + } + } + } + def getField( + __field: _root_.scalapb.descriptors.FieldDescriptor + ): _root_.scalapb.descriptors.PValue = { + _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor) + (__field.number: @ _root_.scala.unchecked) match { + case 1 => _root_.scalapb.descriptors.PString(str1) + case 2 => _root_.scalapb.descriptors.PString(str2) } - def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this) - def companion: _root_.scalapb.perf.protos.StringMessage.type = _root_.scalapb.perf.protos.StringMessage - // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.StringMessage]) + } + def toProtoString: _root_.scala.Predef.String = + _root_.scalapb.TextFormat.printToUnicodeString(this) + def companion: _root_.scalapb.perf.protos.StringMessage.type = + _root_.scalapb.perf.protos.StringMessage + // @@protoc_insertion_point(GeneratedMessage[scalapb.perf.StringMessage]) } -object StringMessage extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.StringMessage] { - implicit def messageCompanion: scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.StringMessage] = this - def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): _root_.scalapb.perf.protos.StringMessage = { - var __str1: _root_.scala.Predef.String = "" - var __str2: _root_.scala.Predef.String = "" +object StringMessage + extends scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.StringMessage] { + implicit def messageCompanion + : scalapb.GeneratedMessageCompanion[_root_.scalapb.perf.protos.StringMessage] = this + def parseFrom( + `_input__`: _root_.com.google.protobuf.CodedInputStream + ): _root_.scalapb.perf.protos.StringMessage = { + var __str1: _root_.scala.Predef.String = "" + var __str2: _root_.scala.Predef.String = "" var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null - var _done__ = false + var _done__ = false while (!_done__) { val _tag__ = _input__.readTag() _tag__ match { - case 0 => _done__ = true + case 0 => _done__ = true case 10 => __str1 = _input__.readStringRequireUtf8() case 18 => @@ -105,38 +114,65 @@ object StringMessage extends scalapb.GeneratedMessageCompanion[_root_.scalapb.pe } } _root_.scalapb.perf.protos.StringMessage( - str1 = __str1, - str2 = __str2, - unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result() + str1 = __str1, + str2 = __str2, + unknownFields = + if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty + else _unknownFields__.result() ) } - implicit def messageReads: _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.StringMessage] = _root_.scalapb.descriptors.Reads{ - case _root_.scalapb.descriptors.PMessage(__fieldsMap) => - _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.") - _root_.scalapb.perf.protos.StringMessage( - str1 = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""), - str2 = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.Predef.String]).getOrElse("") - ) - case _ => throw new RuntimeException("Expected PMessage") - } - def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(5) - def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(5) - def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number) - lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty - def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber) + implicit def messageReads + : _root_.scalapb.descriptors.Reads[_root_.scalapb.perf.protos.StringMessage] = + _root_.scalapb.descriptors.Reads { + case _root_.scalapb.descriptors.PMessage(__fieldsMap) => + _root_.scala.Predef.require( + __fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), + "FieldDescriptor does not match message type." + ) + _root_.scalapb.perf.protos.StringMessage( + str1 = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(1).get) + .map(_.as[_root_.scala.Predef.String]) + .getOrElse(""), + str2 = __fieldsMap + .get(scalaDescriptor.findFieldByNumber(2).get) + .map(_.as[_root_.scala.Predef.String]) + .getOrElse("") + ) + case _ => throw new RuntimeException("Expected PMessage") + } + def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.javaDescriptor.getMessageTypes().get(5) + def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = + _root_.scalapb.perf.protos.ProtosProto.scalaDescriptor.messages(5) + def messageCompanionForFieldNumber( + __number: _root_.scala.Int + ): _root_.scalapb.GeneratedMessageCompanion[?] = throw new MatchError(__number) + lazy val nestedMessagesCompanions + : Seq[_root_.scalapb.GeneratedMessageCompanion[? <: _root_.scalapb.GeneratedMessage]] = + Seq.empty + def enumCompanionForFieldNumber( + __fieldNumber: _root_.scala.Int + ): _root_.scalapb.GeneratedEnumCompanion[?] = throw new MatchError(__fieldNumber) lazy val defaultInstance = _root_.scalapb.perf.protos.StringMessage( str1 = "", str2 = "" ) - implicit class StringMessageLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.StringMessage]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.StringMessage](_l) { - def str1: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.str1)((c_, f_) => c_.copy(str1 = f_)) - def str2: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.str2)((c_, f_) => c_.copy(str2 = f_)) + implicit class StringMessageLens[UpperPB]( + _l: _root_.scalapb.lenses.Lens[UpperPB, _root_.scalapb.perf.protos.StringMessage] + ) extends _root_.scalapb.lenses.ObjectLens[UpperPB, _root_.scalapb.perf.protos.StringMessage]( + _l + ) { + def str1: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = + field(_.str1)((c_, f_) => c_.copy(str1 = f_)) + def str2: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = + field(_.str2)((c_, f_) => c_.copy(str2 = f_)) } final val STR1_FIELD_NUMBER = 1 final val STR2_FIELD_NUMBER = 2 def of( - str1: _root_.scala.Predef.String, - str2: _root_.scala.Predef.String + str1: _root_.scala.Predef.String, + str2: _root_.scala.Predef.String ): _root_.scalapb.perf.protos.StringMessage = _root_.scalapb.perf.protos.StringMessage( str1, str2 diff --git a/docs/src/main/scala/scalapb/docs/benchmarks/Charts.scala b/docs/src/main/scala/scalapb/docs/benchmarks/Charts.scala index 7a8d83bf4..c7f438625 100644 --- a/docs/src/main/scala/scalapb/docs/benchmarks/Charts.scala +++ b/docs/src/main/scala/scalapb/docs/benchmarks/Charts.scala @@ -45,9 +45,9 @@ object Charts { def traceForKey(key: LineKey, showLegend: Boolean) = { val (x, y) = ts(key).toVector.sortBy(v => versionKey(v._1)).unzip Obj( - "x" -> x, - "y" -> y.map(_._1), - "name" -> ("Scala " + key.scalaVersion.split('.').dropRight(1).mkString(".")), + "x" -> x, + "y" -> y.map(_._1), + "name" -> ("Scala " + key.scalaVersion.split('.').dropRight(1).mkString(".")), "error_y" -> Obj( "array" -> y.map(t => t._3 - t._1), "arrayminus" -> y.map(t => t._1 - t._2), @@ -77,7 +77,7 @@ object Charts { val java = LineKey(baseName + "Java", "java") val allVersions = (ts(key1).keySet ++ ts(key2).keySet).toVector - val data = Arr( + val data = Arr( traceForKey(key1, showLegend), traceForKey(key2, showLegend), javaTraceForKey(java, allVersions, showLegend) diff --git a/e2e-grpc/src/test/scala/GrpcServiceScalaServerSpec.scala b/e2e-grpc/src/test/scala/GrpcServiceScalaServerSpec.scala index 4ad4002d8..80d2214b1 100644 --- a/e2e-grpc/src/test/scala/GrpcServiceScalaServerSpec.scala +++ b/e2e-grpc/src/test/scala/GrpcServiceScalaServerSpec.scala @@ -31,7 +31,7 @@ class GrpcServiceScalaServerSpec extends GrpcServiceSpecBase { val stub = ServerReflectionGrpc.stub(channel) val (responseObserver, future) = getObserverAndFutureVector[ServerReflectionResponse] val requestObserver = stub.serverReflectionInfo(responseObserver) - val request = ServerReflectionRequest( + val request = ServerReflectionRequest( host = "localhost", messageRequest = MessageRequest.ListServices("services") ) @@ -214,11 +214,11 @@ class GrpcServiceScalaServerSpec extends GrpcServiceSpecBase { it("InProcessTransport skips serialization") { withInMemoryTransportScalaServer { channel => val client = Service1GrpcScala.stub(channel) - val req = service.Req1(request = "AmIsraelChai") + val req = service.Req1(request = "AmIsraelChai") val res = Await.result(client.echoRequest(req), 10.seconds) - res.req.get must be theSameInstanceAs(req) + res.req.get must be theSameInstanceAs (req) } } diff --git a/e2e-grpc/src/test/scala/GrpcServiceSpecBase.scala b/e2e-grpc/src/test/scala/GrpcServiceSpecBase.scala index 0167fbb27..6684784f6 100644 --- a/e2e-grpc/src/test/scala/GrpcServiceSpecBase.scala +++ b/e2e-grpc/src/test/scala/GrpcServiceSpecBase.scala @@ -35,7 +35,9 @@ abstract class GrpcServiceSpecBase extends AnyFunSpec with Matchers { withManagedServer( InProcessServerBuilder .forName(channelName) - .addService(Service1GrpcScala.bindService(new Service1ScalaImpl, singleThreadExecutionContext)) + .addService( + Service1GrpcScala.bindService(new Service1ScalaImpl, singleThreadExecutionContext) + ) .build() ) { val channel = InProcessChannelBuilder @@ -75,7 +77,7 @@ abstract class GrpcServiceSpecBase extends AnyFunSpec with Matchers { } protected[this] final def getObserverAndFuture[T]: (StreamObserver[T], Future[T]) = { - val promise = Promise[T]() + val promise = Promise[T]() val observer = new StreamObserver[T] { override def onError(t: Throwable): Unit = {} @@ -88,8 +90,8 @@ abstract class GrpcServiceSpecBase extends AnyFunSpec with Matchers { protected[this] final def getObserverAndFutureVector[T] : (StreamObserver[T], Future[Vector[T]]) = { - val promise = Promise[Vector[T]]() - val values = Vector.newBuilder[T] + val promise = Promise[Vector[T]]() + val values = Vector.newBuilder[T] val observer = new StreamObserver[T] { override def onError(t: Throwable): Unit = {} diff --git a/e2e-grpc/src/test/scala/ProtoInputStreamSpec.scala b/e2e-grpc/src/test/scala/ProtoInputStreamSpec.scala index 460373fb1..567835f8f 100644 --- a/e2e-grpc/src/test/scala/ProtoInputStreamSpec.scala +++ b/e2e-grpc/src/test/scala/ProtoInputStreamSpec.scala @@ -70,10 +70,10 @@ class ProtoInputStreamSpec extends AnyFunSpec with Matchers { it("fully readable in chunks") { new Setup { var offset = 0 - var count = 0 - var buf = newBuffer + var count = 0 + var buf = newBuffer val res = Array.newBuilder[Byte] - while({ + while ({ res ++= buf.slice(offset, offset + count) buf = newBuffer offset += count diff --git a/e2e-grpc/src/test/scala/UniquePortGenerator.scala b/e2e-grpc/src/test/scala/UniquePortGenerator.scala index 8ca9ff80c..36c43ea93 100644 --- a/e2e-grpc/src/test/scala/UniquePortGenerator.scala +++ b/e2e-grpc/src/test/scala/UniquePortGenerator.scala @@ -9,7 +9,7 @@ object UniquePortGenerator { @annotation.tailrec def loop(loopCount: Int): Option[Int] = { val socket = new ServerSocket(0) - val port = + val port = try { socket.getLocalPort } finally { diff --git a/e2e/src/main/scala-3/scalapb/derives/typeclasses.scala b/e2e/src/main/scala-3/scalapb/derives/typeclasses.scala index e8d148959..4041d8d28 100644 --- a/e2e/src/main/scala-3/scalapb/derives/typeclasses.scala +++ b/e2e/src/main/scala-3/scalapb/derives/typeclasses.scala @@ -5,17 +5,17 @@ import scala.compiletime.erasedValue import scala.annotation.targetName trait Show[T]: - def show(t: T): String + def show(t: T): String object Show: - @targetName("derivedMessage") def derived[T <: GeneratedMessage]: Show[T] = new Show[T]: - def show(t: T): String = t.toProtoString + @targetName("derivedMessage") def derived[T <: GeneratedMessage]: Show[T] = new Show[T]: + def show(t: T): String = t.toProtoString - @targetName("derivedSealedOneof") def derived[T <: GeneratedSealedOneof]: Show[T] = new Show[T]: - def show(t: T): String = "Sealed!" + @targetName("derivedSealedOneof") def derived[T <: GeneratedSealedOneof]: Show[T] = new Show[T]: + def show(t: T): String = "Sealed!" trait TC[T]: - def tc(t: T): Unit + def tc(t: T): Unit object TC: - def derived[T <: GeneratedMessage]: TC[T] = null \ No newline at end of file + def derived[T <: GeneratedMessage]: TC[T] = null diff --git a/e2e/src/main/scala/com/thesamet/proto/e2e/TypeMappers.scala b/e2e/src/main/scala/com/thesamet/proto/e2e/TypeMappers.scala index ba53c1b31..50f3566df 100644 --- a/e2e/src/main/scala/com/thesamet/proto/e2e/TypeMappers.scala +++ b/e2e/src/main/scala/com/thesamet/proto/e2e/TypeMappers.scala @@ -3,5 +3,7 @@ package com.thesamet.proto.e2e import scalapb.{GeneratedEnumCompanion, TypeMapper} object TypeMappers { - implicit def enumMapper[A <: scalapb.GeneratedEnum](implicit ec: GeneratedEnumCompanion[A]): TypeMapper[A, String] = TypeMapper[A, String](_.name)(ec.fromName(_).get) -} \ No newline at end of file + implicit def enumMapper[A <: scalapb.GeneratedEnum](implicit + ec: GeneratedEnumCompanion[A] + ): TypeMapper[A, String] = TypeMapper[A, String](_.name)(ec.fromName(_).get) +} diff --git a/e2e/src/test/scala/CollectionTypesSpec.scala b/e2e/src/test/scala/CollectionTypesSpec.scala index b428f3dd8..e4bf82ccb 100644 --- a/e2e/src/test/scala/CollectionTypesSpec.scala +++ b/e2e/src/test/scala/CollectionTypesSpec.scala @@ -11,10 +11,10 @@ class CollectionTypesSpec extends AnyFlatSpec with Matchers { val cv = CollectionTypesVector().update(_.repeatedInt32 :++= Seq(11, 9)) val cl = CollectionTypesList().update(_.repeatedInt32 :++= Seq(11, 9)) val cs = CollectionTypesSet().update(_.repeatedInt32 :++= Seq(11, 9)) - cis.repeatedInt32 must be(a[collection.immutable.Seq[_]]) - cv.repeatedInt32 must be(a[Vector[_]]) - cl.repeatedInt32 must be(a[List[_]]) - cs.repeatedInt32 must be(a[Set[_]]) + cis.repeatedInt32 must be(a[collection.immutable.Seq[?]]) + cv.repeatedInt32 must be(a[Vector[?]]) + cl.repeatedInt32 must be(a[List[?]]) + cs.repeatedInt32 must be(a[Set[?]]) } "custom collection" should "work" in { @@ -31,9 +31,9 @@ class CollectionTypesSpec extends AnyFlatSpec with Matchers { "custom maps" should "have expected types" in { val m = CollectionTypesMap() - m.mapInt32Bool must be(a[mutable.Map[_, _]]) - m.mapInt32Enum must be(a[mutable.Map[_, _]]) - m.mymapInt32Bool must be(a[MyMap[_, _]]) + m.mapInt32Bool must be(a[mutable.Map[?, ?]]) + m.mapInt32Enum must be(a[mutable.Map[?, ?]]) + m.mymapInt32Bool must be(a[MyMap[?, ?]]) } "custom maps" should "serialize and deserialize" in { diff --git a/e2e/src/test/scala/CustomOptionsSpec.scala b/e2e/src/test/scala/CustomOptionsSpec.scala index 50bb16bc4..9d3d54ee4 100644 --- a/e2e/src/test/scala/CustomOptionsSpec.scala +++ b/e2e/src/test/scala/CustomOptionsSpec.scala @@ -149,7 +149,9 @@ class CustomOptionsSpec extends AnyFlatSpec with Matchers with OptionValues { barP3Options.extension(CustomOptionsP3Proto.p3OptEnum).value must be(GOOD_P3) barP3Options.extension(CustomOptionsP3Proto.p3OptBool).value must be(true) barP3Options.extension(CustomOptionsP3Proto.p3OptString).value must be("foo") - barP3Options.extension(CustomOptionsP3Proto.p3OptBytes).value must be(ByteString.copyFromUtf8("foo")) + barP3Options.extension(CustomOptionsP3Proto.p3OptBytes).value must be( + ByteString.copyFromUtf8("foo") + ) } "setting proto3 primitives" should "work" in { diff --git a/e2e/src/test/scala/EnumAliasSpec.scala b/e2e/src/test/scala/EnumAliasSpec.scala index 66b20ff16..6449dd962 100644 --- a/e2e/src/test/scala/EnumAliasSpec.scala +++ b/e2e/src/test/scala/EnumAliasSpec.scala @@ -14,4 +14,4 @@ class EnumAliasSpec extends AnyFlatSpec with Matchers with OptionValues { EnumAllowingAlias.EAA_FINISHED.isEaaStarted must be(false) EnumAllowingAlias.EAA_FINISHED.isEaaRunning must be(false) } -} \ No newline at end of file +} diff --git a/e2e/src/test/scala/OneofSpec.scala b/e2e/src/test/scala/OneofSpec.scala index ec894a1f5..3084dc4ce 100644 --- a/e2e/src/test/scala/OneofSpec.scala +++ b/e2e/src/test/scala/OneofSpec.scala @@ -133,8 +133,8 @@ class OneofSpec "oneof parser" should "pick last oneof value" in { forAll(Gen.listOf(Gen.oneOf(unspecified, tempField, otherField))) { l => - val concat = l.map(_.toByteArray.toSeq).foldLeft(Seq[Byte]())(_ ++ _).toArray - val parsed = OneofTest.parseFrom(concat) + val concat = l.map(_.toByteArray.toSeq).foldLeft(Seq[Byte]())(_ ++ _).toArray + val parsed = OneofTest.parseFrom(concat) val expectedOneOf = l.reverse.collectFirst { case e if e != unspecified => e.myOneOf } getOrElse (unspecified.myOneOf) diff --git a/e2e/src/test/scala/RepeatablesSpec.scala b/e2e/src/test/scala/RepeatablesSpec.scala index c34be6ca8..986d18013 100644 --- a/e2e/src/test/scala/RepeatablesSpec.scala +++ b/e2e/src/test/scala/RepeatablesSpec.scala @@ -119,7 +119,7 @@ class RepeatablesSpec extends AnyFlatSpec with ScalaCheckDrivenPropertyChecks wi forAll(Gen.listOf(repGen)) { list => val os = new ByteArrayOutputStream() list.foreach(_.writeDelimitedTo(os)) - val bytes = os.toByteArray + val bytes = os.toByteArray val parsedStream = RepeatablesTest.streamFromDelimitedInput(new ByteArrayInputStream(bytes)).toList val parsedInputStream = { diff --git a/e2e/src/test/scala/UnknownFieldSetSpec.scala b/e2e/src/test/scala/UnknownFieldSetSpec.scala index a440ac2e4..1dfb8424c 100644 --- a/e2e/src/test/scala/UnknownFieldSetSpec.scala +++ b/e2e/src/test/scala/UnknownFieldSetSpec.scala @@ -9,7 +9,7 @@ class UnknownFieldSetSpec extends AnyFlatSpec with Matchers { val baseX = BaseCase(x = "x", y = 12) val baseY = BaseCase(x = "y", y = 31) val baseZ = BaseCase(x = "z", y = 47) - val ext = Extended( + val ext = Extended( extInt = 4, extRepStr = Seq("foo", "bar"), extMsg = Some(baseX), @@ -29,7 +29,7 @@ class UnknownFieldSetSpec extends AnyFlatSpec with Matchers { } "Unknown fields" should "be combined" in { - val mergedBase = BaseCase.parseFrom(baseX.toByteArray ++ ext.toByteArray) + val mergedBase = BaseCase.parseFrom(baseX.toByteArray ++ ext.toByteArray) val mergedOnceMore = BaseCase.merge(mergedBase, CodedInputStream.newInstance(Extended(extInt = 35).toByteArray)) diff --git a/e2e/src/test/scala/scalapb/StructUtilsSpec.scala b/e2e/src/test/scala/scalapb/StructUtilsSpec.scala index 6d68d6559..8123f3110 100644 --- a/e2e/src/test/scala/scalapb/StructUtilsSpec.scala +++ b/e2e/src/test/scala/scalapb/StructUtilsSpec.scala @@ -78,7 +78,9 @@ class StructUtilsSpec extends AnyFlatSpec with Matchers with EitherValues { Struct( Map( "optional_bytes" -> Value( - Value.Kind.StringValue(new String(Base64.getEncoder.encode(someBytesValue.toByteArray()))) + Value.Kind.StringValue( + new String(Base64.getEncoder.encode(someBytesValue.toByteArray())) + ) ) ) ) @@ -388,7 +390,7 @@ class StructUtilsSpec extends AnyFlatSpec with Matchers with EitherValues { "fromStruct with repeated field of messages" should "pass" in { val someIntValueA = Random.nextInt() val someIntValueB = Random.nextInt() - val types = TestAllTypes().withRepeatedForeignMessage( + val types = TestAllTypes().withRepeatedForeignMessage( Seq(ForeignMessage().withC(someIntValueA), ForeignMessage().withC(someIntValueB)) ) StructUtils.fromStruct(StructUtils.toStruct(types)).right.value must be(types) @@ -403,7 +405,7 @@ class StructUtilsSpec extends AnyFlatSpec with Matchers with EitherValues { // Tests added for precaution to verify recursion and companions is correct "fromStruct with two level deep message" should "pass" in { implicit val containerMessageCompanion = ContainerMessage.messageCompanion - val types = ContainerMessage().withImportMessage( + val types = ContainerMessage().withImportMessage( ContainerMessageImportMessage().withB(DeepMessage().withA(Random.nextInt())) ) StructUtils.fromStruct[ContainerMessage](StructUtils.toStruct(types)).right.value must be(types) @@ -411,7 +413,7 @@ class StructUtilsSpec extends AnyFlatSpec with Matchers with EitherValues { "fromStruct with two level deep enum" should "pass" in { implicit val containerMessageCompanion = ContainerMessage.messageCompanion - val types = + val types = ContainerMessage().withImportMessage(ContainerMessageImportMessage().withC(DeepEnum.DEEP_BAZ)) StructUtils.fromStruct[ContainerMessage](StructUtils.toStruct(types)).right.value must be(types) } diff --git a/e2e/src/test/scala/scoped/WildcardSpec.scala b/e2e/src/test/scala/scoped/WildcardSpec.scala index 5ae150bd3..a0419151b 100644 --- a/e2e/src/test/scala/scoped/WildcardSpec.scala +++ b/e2e/src/test/scala/scoped/WildcardSpec.scala @@ -5,7 +5,7 @@ import org.scalatest.matchers.must.Matchers import scalapb.changed.scoped._ class WildcardSpec extends AnyFlatSpec with Matchers { - assert(Wild1().isInstanceOf[WildcardTrait]) - assert(Wild2().isInstanceOf[WildcardTrait]) - assert(Wild2().isInstanceOf[SomeTrait]) + assert(Wild1().isInstanceOf[WildcardTrait]) + assert(Wild2().isInstanceOf[WildcardTrait]) + assert(Wild2().isInstanceOf[SomeTrait]) } diff --git a/e2e/src/test/scalajvm-3-source/Scala3CompatSpec.scala b/e2e/src/test/scalajvm-3-source/Scala3CompatSpec.scala index 102985287..5372c6585 100644 --- a/e2e/src/test/scalajvm-3-source/Scala3CompatSpec.scala +++ b/e2e/src/test/scalajvm-3-source/Scala3CompatSpec.scala @@ -6,7 +6,7 @@ import scalapb.lenses.{MessageLens, ObjectLens} class Scala3CompatSpec extends AnyFlatSpec with Matchers with OptionValues { "message lens" should "extend MessageLens and ObjectLens" in { - classOf[MessageLens[_, _]].isAssignableFrom(classOf[Foo.FooLens[_]]) must be(true) - classOf[ObjectLens[_, _]].isAssignableFrom(classOf[Foo.FooLens[_]]) must be(true) + classOf[MessageLens[?, ?]].isAssignableFrom(classOf[Foo.FooLens[?]]) must be(true) + classOf[ObjectLens[?, ?]].isAssignableFrom(classOf[Foo.FooLens[?]]) must be(true) } } diff --git a/examples/basic/src/main/scala/AddressBookMain.scala b/examples/basic/src/main/scala/AddressBookMain.scala index e4705f623..facb499b6 100644 --- a/examples/basic/src/main/scala/AddressBookMain.scala +++ b/examples/basic/src/main/scala/AddressBookMain.scala @@ -36,7 +36,7 @@ object AddressBookMain extends App { case "mobile" => Some(Person.PhoneType.MOBILE) case "home" => Some(Person.PhoneType.HOME) case "work" => Some(Person.PhoneType.WORK) - case _ => + case _ => println("Unknown phone type. Leaving as None.") None } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 22ca1c2c8..48e6a4327 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -29,7 +29,7 @@ object Dependencies { val Scala3 = "3.3.6" - val protobufJava = "com.google.protobuf" % "protobuf-java" % versions.protobuf + val protobufJava = "com.google.protobuf" % "protobuf-java" % versions.protobuf val scalaCollectionCompat = Def.setting { "org.scala-lang.modules" %%% "scala-collection-compat" % versions.collectionCompat } @@ -55,7 +55,7 @@ object Dependencies { val grpcInprocess = "io.grpc" % "grpc-inprocess" % versions.grpc // testing - val scalaTest = Def.setting { "org.scalatest" %%% "scalatest" % versions.scalaTest } + val scalaTest = Def.setting { "org.scalatest" %%% "scalatest" % versions.scalaTest } val scalaTestPlusScalaCheck = Def.setting { "org.scalatestplus" %%% "scalacheck-1-17" % versions.scalaTestPlusScalaCheck } diff --git a/proptest/src/test/scala/GenData.scala b/proptest/src/test/scala/GenData.scala index c42633c7b..4ce21c599 100644 --- a/proptest/src/test/scala/GenData.scala +++ b/proptest/src/test/scala/GenData.scala @@ -7,8 +7,8 @@ object GenData { import org.scalacheck.Gen.{sized, oneOf} sealed trait ProtoValue - case class PrimitiveValue(value: String) extends ProtoValue - case class EnumValue(value: String) extends ProtoValue + case class PrimitiveValue(value: String) extends ProtoValue + case class EnumValue(value: String) extends ProtoValue case class MessageValue(values: Seq[(String, ProtoValue)]) extends ProtoValue { def toAscii: String = printAscii(new FunctionalPrinter()).result() @@ -17,7 +17,7 @@ object GenData { values.foldLeft(printer) { case (printer, (name, PrimitiveValue(value))) => printer.add(s"$name: $value") case (printer, (name, EnumValue(value))) => printer.add(s"$name: $value") - case (printer, (name, mv: MessageValue)) => + case (printer, (name, mv: MessageValue)) => printer .add(s"$name: <") .indent diff --git a/proptest/src/test/scala/GenTypes.scala b/proptest/src/test/scala/GenTypes.scala index a6a6c9fa3..5016e7261 100644 --- a/proptest/src/test/scala/GenTypes.scala +++ b/proptest/src/test/scala/GenTypes.scala @@ -33,7 +33,7 @@ object GenTypes { case b if b == '\''.toByte => builder.append("\\\'") case b if b == '\\'.toByte => builder.append("\\\\") case b if b >= 0x20 => builder.append(b.toChar) - case b => + case b => builder.append('\\') builder.append((48 + ((b >>> 6) & 3)).toChar) builder.append((48 + ((b >>> 3) & 7)).toChar) @@ -56,7 +56,7 @@ object GenTypes { val ProtoDouble = Primitive("double", Arbitrary.arbitrary[Double].map(_.toString)) val ProtoFloat = Primitive("float", Arbitrary.arbitrary[Float].map(_.toString)) val ProtoBool = Primitive("bool", Arbitrary.arbitrary[Boolean].map(_.toString)) - val ProtoString = Primitive( + val ProtoString = Primitive( "string", Arbitrary.arbitrary[String].map(_.getBytes("UTF-8").toSeq).map(escapeBytes), packable = false @@ -138,7 +138,7 @@ object GenTypes { allowMaps: Boolean = true, enumMustHaveZeroDefined: Boolean = false ): Gen[ProtoType] = { - val baseFreq = List((5, generatePrimitive)) + val baseFreq = List((5, generatePrimitive)) val withMessages = if (state._nextMessageId > 0) (1, Gen.chooseNum(0, state._nextMessageId - 1).map(MessageReference(_))) :: baseFreq @@ -165,7 +165,7 @@ object GenTypes { def genMapType(state: State, syntax: ProtoSyntax): Gen[MapType] = for { - keyType <- generateMapKey + keyType <- generateMapKey valueType <- genFieldType( state, syntax, @@ -198,7 +198,7 @@ object GenTypes { Gen.const(FieldOptions(FieldModifier.REPEATED, isPacked = false, proto3Presence = false)) case _ => for { - mod <- genFieldModifier(allowRequired = protoSyntax.isProto2) + mod <- genFieldModifier(allowRequired = protoSyntax.isProto2) packed <- if (fieldType.packable && mod == FieldModifier.REPEATED) Gen.oneOf(true, false) diff --git a/proptest/src/test/scala/GraphGen.scala b/proptest/src/test/scala/GraphGen.scala index 3f92872e9..855ccf423 100644 --- a/proptest/src/test/scala/GraphGen.scala +++ b/proptest/src/test/scala/GraphGen.scala @@ -101,7 +101,7 @@ object GraphGen { zeroDefined <- if (syntax.isProto3) Gen.const(true) else Gen.oneOf(false, true) (enumName, state) <- state.generateName (myId, state) <- Gen.const(state.nextEnumId(syntax, zeroDefined)) - (names, state) <- GenUtils + (names, state) <- GenUtils .listWithStatefulGen(state, minSize = 1, maxSize = 5)(_.generateName) .retryUntil { case (names, _) => // In protoc there is a check that says: @@ -180,8 +180,8 @@ object GraphGen { ): Gen[(MessageNode, State)] = sized { s => for { - (myId, state) <- Gen.const(state.nextMessageId) - (name, state) <- state.generateSubspace + (myId, state) <- Gen.const(state.nextMessageId) + (name, state) <- state.generateSubspace (messages, state) <- listWithStatefulGen(state, maxSize = (3 - depth) max 0)( genMessageNode(depth + 1, Some(myId), protoSyntax) ) diff --git a/proptest/src/test/scala/Nodes.scala b/proptest/src/test/scala/Nodes.scala index 5a212caa2..e2d305900 100644 --- a/proptest/src/test/scala/Nodes.scala +++ b/proptest/src/test/scala/Nodes.scala @@ -60,9 +60,9 @@ object Nodes { def maxEnumId = Try(files.flatMap(_.maxEnumId).max).toOption def resolveProtoTypeName(t: GenTypes.ProtoType): String = t match { - case Primitive(name, _, _, _) => name - case MessageReference(id) => fullMessageNameParts(id).mkString(".") - case EnumReference(id) => fullEnumNameParts(id).mkString(".") + case Primitive(name, _, _, _) => name + case MessageReference(id) => fullMessageNameParts(id).mkString(".") + case EnumReference(id) => fullEnumNameParts(id).mkString(".") case MapType(keyType, valueType) => s"map<${resolveProtoTypeName(keyType)}, ${resolveProtoTypeName(valueType)}>" } @@ -324,7 +324,7 @@ object Nodes { printer: compiler.FunctionalPrinter ): compiler.FunctionalPrinter = if (!oneOfGroup.isOneof) { - val packed = if (fieldOptions.isPacked) " [packed = true]" else "" + val packed = if (fieldOptions.isPacked) " [packed = true]" else "" val modifier = if (fileNode.protoSyntax.isProto2) { if (fieldType.isMap) "" else fieldOptions.modifier.toString + " " } else { diff --git a/proptest/src/test/scala/SchemaGenerators.scala b/proptest/src/test/scala/SchemaGenerators.scala index 33a67945a..cbd223653 100644 --- a/proptest/src/test/scala/SchemaGenerators.scala +++ b/proptest/src/test/scala/SchemaGenerators.scala @@ -170,7 +170,7 @@ object SchemaGenerators { file.getAbsolutePath } val scala3SourcesParam = if (isScala3Sources) ",scala3_sources" else "" - val args = Seq( + val args = Seq( "--experimental_allow_proto3_optional", "--proto_path", (tmpDir.toString + ":protobuf:third_party"), diff --git a/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/ProtoInputStream.scala b/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/ProtoInputStream.scala index 50363642d..16ff938a1 100644 --- a/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/ProtoInputStream.scala +++ b/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/ProtoInputStream.scala @@ -27,12 +27,12 @@ class ProtoInputStream[T <: GeneratedMessage](msg: T) extends InputStream { } private case class Message(value: T) extends State { - override def available: Int = value.serializedSize - override def message: T = value - override def read(): Int = toStream.read() + override def available: Int = value.serializedSize + override def message: T = value + override def read(): Int = toStream.read() override def read(b: Array[Byte], off: Int, len: Int): Int = { value.serializedSize match { - case 0 => toDrained.read(b, off, len) + case 0 => toDrained.read(b, off, len) case size if size <= len => val stream = CodedOutputStream.newInstance(b, off, size) message.writeTo(stream) diff --git a/scalapb-runtime/src/main/scala/scalapb/Encoding.scala b/scalapb-runtime/src/main/scala/scalapb/Encoding.scala index 960e8ecc7..4da772b4a 100644 --- a/scalapb-runtime/src/main/scala/scalapb/Encoding.scala +++ b/scalapb-runtime/src/main/scala/scalapb/Encoding.scala @@ -31,7 +31,7 @@ object Encoding { private def fromBase64Inner(input: String): Array[Byte] = { require(input.length % 4 == 0) val lastEqualsIndex = input.indexOf('=') - val outputLength = (input.length * 3) / 4 - (if (lastEqualsIndex > 0) + val outputLength = (input.length * 3) / 4 - (if (lastEqualsIndex > 0) (input.length() - lastEqualsIndex) else 0) val builder = mutable.ArrayBuilder.make[Byte] diff --git a/scalapb-runtime/src/main/scala/scalapb/FieldMaskTree.scala b/scalapb-runtime/src/main/scala/scalapb/FieldMaskTree.scala index f2894896e..b68c422da 100644 --- a/scalapb-runtime/src/main/scala/scalapb/FieldMaskTree.scala +++ b/scalapb-runtime/src/main/scala/scalapb/FieldMaskTree.scala @@ -44,7 +44,7 @@ private[scalapb] case class FieldMaskTree(nodes: SortedMap[String, FieldMaskTree private def isValidFor(descriptor: Descriptor): Boolean = { nodes.forall { case (field, tree) => descriptor.findFieldByName(field) match { - case None => false + case None => false case Some(field) => if (tree == FieldMaskTree.Empty) { true @@ -61,7 +61,7 @@ private[scalapb] case class FieldMaskTree(nodes: SortedMap[String, FieldMaskTree private def paths: Vector[String] = { nodes.toVector.flatMap { case (field, FieldMaskTree.Empty) => Vector(field) - case (field, subTree) => + case (field, subTree) => subTree.paths.map(path => s"$field${FieldMaskTree.FieldSeparator}$path") } } @@ -82,11 +82,11 @@ private[scalapb] object FieldMaskTree { } def union(tree1: FieldMaskTree, tree2: FieldMaskTree): FieldMaskTree = (tree1, tree2) match { - case (Empty, tree) => tree - case (tree, Empty) => tree + case (Empty, tree) => tree + case (tree, Empty) => tree case (FieldMaskTree(nodes1), FieldMaskTree(nodes2)) => val fields: Seq[String] = (nodes1.keySet ++ nodes2.keySet).toSeq - val tree = SortedMap(fields.map { field => + val tree = SortedMap(fields.map { field => val subTree = (nodes1.get(field), nodes2.get(field)) match { case (Some(Empty), _) => Empty case (_, Some(Empty)) => Empty diff --git a/scalapb-runtime/src/main/scala/scalapb/FieldMaskUtil.scala b/scalapb-runtime/src/main/scala/scalapb/FieldMaskUtil.scala index b51b4c709..0257131a7 100644 --- a/scalapb-runtime/src/main/scala/scalapb/FieldMaskUtil.scala +++ b/scalapb-runtime/src/main/scala/scalapb/FieldMaskUtil.scala @@ -154,7 +154,7 @@ object FieldMaskUtil { fieldNumbers: Int* ): Option[FieldMask] = { val companion = implicitly[GeneratedMessageCompanion[M]] - val fields = fieldNumbers.map { fieldNumber => + val fields = fieldNumbers.map { fieldNumber => companion.scalaDescriptor.findFieldByNumber(fieldNumber) } val fieldNames = fields.foldLeft[Option[Vector[String]]](Some(Vector.empty)) { diff --git a/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala b/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala index 97f33fa97..665974025 100644 --- a/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala +++ b/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala @@ -44,15 +44,15 @@ object StructUtils { PLong(v.toLong) } match { case Success(pLong) => Right(pLong) - case Failure(_) => + case Failure(_) => Left( StructParsingError( s"""Field "${fd.fullName}" is of type long but received invalid long value "$v"""" ) ) } - case (Kind.NumberValue(v), ScalaType.Double) => Right(PDouble(v)) - case (Kind.NumberValue(v), ScalaType.Float) => Right(PFloat(v.toFloat)) + case (Kind.NumberValue(v), ScalaType.Double) => Right(PDouble(v)) + case (Kind.NumberValue(v), ScalaType.Float) => Right(PFloat(v.toFloat)) case (Kind.StringValue(v), ScalaType.ByteString) => Right(PByteString(ByteString.copyFrom(Base64.getDecoder.decode(v.getBytes)))) case (Kind.StringValue(v), en @ ScalaType.Enum(_)) => @@ -64,13 +64,13 @@ object StructUtils { s"""Field "${fd.fullName}" is of type enum "${en.descriptor.fullName}" but received invalid enum value "$v"""" ) ) - case (Kind.StringValue(v), ScalaType.String) => Right(PString(v)) - case (Kind.BoolValue(v), ScalaType.Boolean) => Right(PBoolean(v)) + case (Kind.StringValue(v), ScalaType.String) => Right(PString(v)) + case (Kind.BoolValue(v), ScalaType.Boolean) => Right(PBoolean(v)) case (Kind.ListValue(v), _) if (fd.isRepeated) => flatten(v.values.map(fromValue(fd))).map(PRepeated(_)) case (Kind.StructValue(v), _: ScalaType.Message) => structMapToFDMap(v.fields)(companion.messageCompanionForFieldNumber(fd.number)) - case (Kind.Empty, _) => Right(PEmpty) + case (Kind.Empty, _) => Right(PEmpty) case (kind: Kind, scalaType: ScalaType) => Left( StructParsingError( @@ -94,11 +94,11 @@ object StructUtils { private def toValue(pValue: PValue): Value = Value(pValue match { - case PInt(value) => Value.Kind.NumberValue(value.toDouble) - case PLong(value) => Value.Kind.StringValue(value.toString) - case PDouble(value) => Value.Kind.NumberValue(value) - case PFloat(value) => Value.Kind.NumberValue(value.toDouble) - case PString(value) => Value.Kind.StringValue(value) + case PInt(value) => Value.Kind.NumberValue(value.toDouble) + case PLong(value) => Value.Kind.StringValue(value.toString) + case PDouble(value) => Value.Kind.NumberValue(value) + case PFloat(value) => Value.Kind.NumberValue(value.toDouble) + case PString(value) => Value.Kind.StringValue(value) case PByteString(value) => Value.Kind.StringValue( new String(Base64.getEncoder.encode(value.toByteArray())) diff --git a/scalapb-runtime/src/main/scala/scalapb/UnknownFieldSet.scala b/scalapb-runtime/src/main/scala/scalapb/UnknownFieldSet.scala index 128cd2a95..91aaa1fac 100644 --- a/scalapb-runtime/src/main/scala/scalapb/UnknownFieldSet.scala +++ b/scalapb-runtime/src/main/scala/scalapb/UnknownFieldSet.scala @@ -69,9 +69,9 @@ object UnknownFieldSet { } object Field { - val varintLens = Lens[Field, Seq[Long]](_.varint)((c, v) => c.copy(varint = v)) - val fixed64Lens = Lens[Field, Seq[Long]](_.fixed64)((c, v) => c.copy(fixed64 = v)) - val fixed32Lens = Lens[Field, Seq[Int]](_.fixed32)((c, v) => c.copy(fixed32 = v)) + val varintLens = Lens[Field, Seq[Long]](_.varint)((c, v) => c.copy(varint = v)) + val fixed64Lens = Lens[Field, Seq[Long]](_.fixed64)((c, v) => c.copy(fixed64 = v)) + val fixed32Lens = Lens[Field, Seq[Int]](_.fixed32)((c, v) => c.copy(fixed32 = v)) val lengthDelimitedLens = Lens[Field, Seq[ByteString]](_.lengthDelimited)((c, v) => c.copy(lengthDelimited = v)) diff --git a/scalapb-runtime/src/main/scala/scalapb/descriptors/Descriptor.scala b/scalapb-runtime/src/main/scala/scalapb/descriptors/Descriptor.scala index b1e9e119f..e96e2670f 100644 --- a/scalapb-runtime/src/main/scala/scalapb/descriptors/Descriptor.scala +++ b/scalapb-runtime/src/main/scala/scalapb/descriptors/Descriptor.scala @@ -159,7 +159,7 @@ class MethodDescriptor private[descriptors] ( FileDescriptor.find(containingService.file, this, inputType) match { case Some(descriptor: Descriptor) => descriptor - case Some(otherDescriptor) => + case Some(otherDescriptor) => throw new DescriptorValidationException( this, s"Unexpected descriptor type ${otherDescriptor.getClass.getName} for input type $inputType" @@ -182,7 +182,7 @@ class MethodDescriptor private[descriptors] ( FileDescriptor.find(containingService.file, this, outputType) match { case Some(descriptor: Descriptor) => descriptor - case Some(otherDescriptor) => + case Some(otherDescriptor) => throw new DescriptorValidationException( this, s"Unexpected descriptor type ${otherDescriptor.getClass.getName} for output type $outputType" @@ -339,7 +339,7 @@ object FieldDescriptor { case FieldDescriptorProto.Type.TYPE_FIXED32 => ScalaType.Int case FieldDescriptorProto.Type.TYPE_FIXED64 => ScalaType.Long case FieldDescriptorProto.Type.TYPE_FLOAT => ScalaType.Float - case FieldDescriptorProto.Type.TYPE_GROUP => + case FieldDescriptorProto.Type.TYPE_GROUP => throw new DescriptorValidationException(m, s"Groups are not supported.") case FieldDescriptorProto.Type.TYPE_INT32 => ScalaType.Int case FieldDescriptorProto.Type.TYPE_INT64 => ScalaType.Long @@ -505,7 +505,7 @@ object FileDescriptor { if (name.startsWith(".")) { file.findSymbol(name.substring(1)) } else { - val dotIndex = name.indexOf('.') + val dotIndex = name.indexOf('.') val (baseName, suffix) = if (dotIndex == -1) (name, "") else (name.substring(0, dotIndex), name.substring(dotIndex)) findFirstParent(context.fullName, baseName).flatMap { gd => diff --git a/scalapb-runtime/src/main/scala/scalapb/descriptors/SourceCodePath.scala b/scalapb-runtime/src/main/scala/scalapb/descriptors/SourceCodePath.scala index 972adf03e..01d1b04c1 100644 --- a/scalapb-runtime/src/main/scala/scalapb/descriptors/SourceCodePath.scala +++ b/scalapb-runtime/src/main/scala/scalapb/descriptors/SourceCodePath.scala @@ -4,7 +4,7 @@ import com.google.protobuf.descriptor._ object SourceCodePath { def get(fd: Descriptor): Seq[Int] = fd.containingMessage match { - case None => Seq(FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER, fd.index) + case None => Seq(FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER, fd.index) case Some(container) => get(container) ++ Seq(DescriptorProto.NESTED_TYPE_FIELD_NUMBER, fd.index) } diff --git a/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala b/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala index 64eefd395..0bd12793d 100644 --- a/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala +++ b/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala @@ -33,7 +33,7 @@ private[scalapb] object AstUtils { ): Either[AstError, BigInt] = p match { case TIntLiteral(index, v) => val negative = v.signum == -1 - val maxBits = if (isLong) { + val maxBits = if (isLong) { if (isSigned) 63 else 64 } else { if (isSigned) 31 else 32 @@ -75,7 +75,7 @@ private[scalapb] object AstUtils { case "inf" | "infinity" => Right(PDouble(Double.PositiveInfinity)) case "-inf" | "-infinity" => Right(PDouble(Double.NegativeInfinity)) case "nan" => Right(PDouble(Double.NaN)) - case _ => + case _ => Try(PDouble(value.toDouble)).toOption .toRight(AstError(p.position, s"Invalid value for double: '$value'")) } @@ -91,7 +91,7 @@ private[scalapb] object AstUtils { case "-inf" | "-inff" | "-infinity" | "-infinityf" => Right(PFloat(Float.NegativeInfinity)) case "nan" | "nanf" => Right(PFloat(Float.NaN)) - case _ => + case _ => Try(PFloat(value.toFloat)).toOption .toRight(AstError(p.position, s"Invalid value for float: '$value'")) } @@ -150,7 +150,7 @@ private[scalapb] object AstUtils { case FieldDescriptorProto.Type.TYPE_SFIXED64 => parseInt64(p) case FieldDescriptorProto.Type.TYPE_SINT32 => parseInt32(p) case FieldDescriptorProto.Type.TYPE_SINT64 => parseInt64(p) - case FieldDescriptorProto.Type.TYPE_GROUP => + case FieldDescriptorProto.Type.TYPE_GROUP => Left(AstError(p.position, "groups are not supported")) case FieldDescriptorProto.Type.TYPE_ENUM => { val enumDesc = v.enumCompanionForFieldNumber(field.number).scalaDescriptor diff --git a/scalapb-runtime/src/main/scala/scalapb/textformat/Parser.scala b/scalapb-runtime/src/main/scala/scalapb/textformat/Parser.scala index 34417ff6d..473e83fe0 100644 --- a/scalapb-runtime/src/main/scala/scalapb/textformat/Parser.scala +++ b/scalapb-runtime/src/main/scala/scalapb/textformat/Parser.scala @@ -17,7 +17,7 @@ class Parser(text: String) { val pos = it.lastPosition closer match { case Some(cl) if token == cl => acc - case _ => + case _ => if (!Tokenizer.isIdentifier(token)) throw { throw parseException(s"Expected identifier, got $token") } diff --git a/scalapb-runtime/src/main/scala/scalapb/textformat/Printer.scala b/scalapb-runtime/src/main/scala/scalapb/textformat/Printer.scala index 01e374c23..2e9e29bcc 100644 --- a/scalapb-runtime/src/main/scala/scalapb/textformat/Printer.scala +++ b/scalapb-runtime/src/main/scala/scalapb/textformat/Printer.scala @@ -25,7 +25,7 @@ object Printer { case PRepeated(values) => values.foreach(v => printSingleField(fd, v, out)) case PEmpty => - case _ => + case _ => printSingleField(fd, value, out); () } diff --git a/scalapb-runtime/src/main/scala/scalapb/textformat/TextFormatUtils.scala b/scalapb-runtime/src/main/scala/scalapb/textformat/TextFormatUtils.scala index 4a8be9928..034256faa 100644 --- a/scalapb-runtime/src/main/scala/scalapb/textformat/TextFormatUtils.scala +++ b/scalapb-runtime/src/main/scala/scalapb/textformat/TextFormatUtils.scala @@ -42,16 +42,16 @@ private[scalapb] object TextFormatUtils { def escapeBytes(bytes: ByteString): String = { val sb = new mutable.StringBuilder() bytes.foreach { - case CH_SLASH_A => sb.append("\\a") - case CH_SLASH_B => sb.append("\\b") - case CH_SLASH_F => sb.append("\\f") - case CH_SLASH_N => sb.append("\\n") - case CH_SLASH_R => sb.append("\\r") - case CH_SLASH_T => sb.append("\\t") - case CH_SLASH_V => sb.append("\\v") - case CH_SLASH => sb.append("\\\\") - case CH_SQ => sb.append("\\\'") - case CH_DQ => sb.append("\\\"") + case CH_SLASH_A => sb.append("\\a") + case CH_SLASH_B => sb.append("\\b") + case CH_SLASH_F => sb.append("\\f") + case CH_SLASH_N => sb.append("\\n") + case CH_SLASH_R => sb.append("\\r") + case CH_SLASH_T => sb.append("\\t") + case CH_SLASH_V => sb.append("\\v") + case CH_SLASH => sb.append("\\\\") + case CH_SQ => sb.append("\\\'") + case CH_DQ => sb.append("\\\"") case b if b >= 0x20 => sb.append(b.toChar) case b => @@ -104,7 +104,7 @@ private[scalapb] object TextFormatUtils { case (EscapeMode, CH_DQ) => result += '\"'; Default case (EscapeMode, CH_QM) => result += '?'; Default case (EscapeMode, CH_X) => Hex0 - case (EscapeMode, _) => Error("Invalid escape sequence: " + b.toChar) + case (EscapeMode, _) => Error("Invalid escape sequence: " + b.toChar) case (Octal1(i), b) if b >= '0' && b <= '7' => Octal2(i * 8 + digitValue(b)) case (Octal1(i), b) => @@ -116,8 +116,8 @@ private[scalapb] object TextFormatUtils { case (Octal2(i), b) => result += i.toByte defaultHandle(b) - case (Hex0, b) if (isHexDigit(b.toChar)) => Hex1(digitValue(b)) - case (Hex0, _) => Error("'\\x' with no digits") + case (Hex0, b) if (isHexDigit(b.toChar)) => Hex1(digitValue(b)) + case (Hex0, _) => Error("'\\x' with no digits") case (Hex1(i), b) if (isHexDigit(b.toChar)) => result += (16 * i + digitValue(b)).toByte Default @@ -131,7 +131,7 @@ private[scalapb] object TextFormatUtils { case Error(e) => Left(TextFormatError(e)) case Hex0 => Left(TextFormatError("'\\x' with no digits")) case EscapeMode => Left(TextFormatError("Invalid escape sequence '\\' at end of string.")) - case Hex1(i) => + case Hex1(i) => result += i.toByte Right(ByteString.copyFrom(result.result())) case Octal1(i) => diff --git a/scalapbc/src/main/scala/scalapb/ScalaPBC.scala b/scalapbc/src/main/scala/scalapb/ScalaPBC.scala index 258255ec3..92edc492a 100644 --- a/scalapbc/src/main/scala/scalapb/ScalaPBC.scala +++ b/scalapbc/src/main/scala/scalapb/ScalaPBC.scala @@ -92,7 +92,7 @@ object ScalaPBC { artifacts: Seq[(String, String)] ): Either[String, Seq[(String, (Dependency, Seq[File]))]] = artifacts.foldLeft[Either[String, Seq[(String, (Dependency, Seq[File]))]]](Right(Seq())) { - case (Left(error), _) => Left(error) + case (Left(error), _) => Left(error) case (Right(result), (name, artifact)) => fetchArtifact(artifact) match { case Right((dep, files)) => Right(result :+ ((name, (dep, files)))) @@ -147,8 +147,8 @@ object ScalaPBC { case Left(error) => fatalError(error) case Right(arts) => arts.map { case (name, (_, files)) => - val urls = files.map(_.toURI().toURL()).toArray - val loader = new URLClassLoader(urls, null) + val urls = files.map(_.toURI().toURL()).toArray + val loader = new URLClassLoader(urls, null) val mainClass = findMainClass(files.head) match { case Right(v) => v case Left(err) => fatalError(err) diff --git a/sonatype.sbt b/sonatype.sbt index 12749d949..892fabbca 100644 --- a/sonatype.sbt +++ b/sonatype.sbt @@ -3,7 +3,7 @@ inThisBuild( organization := "com.thesamet.scalapb", homepage := Some(url("https://github.com/scalapb/ScalaPB")), licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), - developers := List( + developers := List( Developer( "thesamet", "Nadav Samet", From 54ab475ccf9ed69de7c74d1093f04d38ad284fe4 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 13 Oct 2025 18:53:08 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.10.0' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index ad44d6416..10e5fc515 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -6,3 +6,6 @@ f84d366235b9104d60a589cff5d3aed7291c5312 # Scala Steward: Reformat with scalafmt 3.7.0 fc3306ef4aea224b3be56707f096884f43f0340a + +# Scala Steward: Reformat with scalafmt 3.10.0 +6d0416fc660bcb8aa7d630a99eac7ca1d855bc32