diff --git a/compiler-plugin/src/main/java/com/trueaccord/scalapb/Scalapb.java b/compiler-plugin/src/main/java/com/trueaccord/scalapb/Scalapb.java index ef8f6daf6..b6222aed5 100644 --- a/compiler-plugin/src/main/java/com/trueaccord/scalapb/Scalapb.java +++ b/compiler-plugin/src/main/java/com/trueaccord/scalapb/Scalapb.java @@ -1327,7 +1327,7 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ com.google.protobuf.ProtocolStringList @@ -1336,7 +1336,7 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ int getExtendsCount(); @@ -1344,7 +1344,7 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ java.lang.String getExtends(int index); @@ -1352,11 +1352,46 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ com.google.protobuf.ByteString getExtendsBytes(int index); + + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + com.google.protobuf.ProtocolStringList + getCompanionExtendsList(); + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + int getCompanionExtendsCount(); + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + java.lang.String getCompanionExtends(int index); + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + com.google.protobuf.ByteString + getCompanionExtendsBytes(int index); } /** * Protobuf type {@code scalapb.MessageOptions} @@ -1371,6 +1406,7 @@ private MessageOptions(com.google.protobuf.GeneratedMessage.Builder builder) } private MessageOptions() { extends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; } @java.lang.Override @@ -1409,6 +1445,15 @@ private MessageOptions( extends_.add(bs); break; } + case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + companionExtends_.add(bs); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -1421,6 +1466,9 @@ private MessageOptions( if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { extends_ = extends_.getUnmodifiableView(); } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = companionExtends_.getUnmodifiableView(); + } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -1443,7 +1491,7 @@ private MessageOptions( * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public com.google.protobuf.ProtocolStringList @@ -1454,7 +1502,7 @@ private MessageOptions( * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public int getExtendsCount() { @@ -1464,7 +1512,7 @@ public int getExtendsCount() { * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public java.lang.String getExtends(int index) { @@ -1474,7 +1522,7 @@ public java.lang.String getExtends(int index) { * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public com.google.protobuf.ByteString @@ -1482,6 +1530,51 @@ public java.lang.String getExtends(int index) { return extends_.getByteString(index); } + public static final int COMPANION_EXTENDS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList companionExtends_; + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public com.google.protobuf.ProtocolStringList + getCompanionExtendsList() { + return companionExtends_; + } + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public int getCompanionExtendsCount() { + return companionExtends_.size(); + } + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public java.lang.String getCompanionExtends(int index) { + return companionExtends_.get(index); + } + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public com.google.protobuf.ByteString + getCompanionExtendsBytes(int index) { + return companionExtends_.getByteString(index); + } + private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; @@ -1497,6 +1590,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < extends_.size(); i++) { com.google.protobuf.GeneratedMessage.writeString(output, 1, extends_.getRaw(i)); } + for (int i = 0; i < companionExtends_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, companionExtends_.getRaw(i)); + } unknownFields.writeTo(output); } @@ -1513,6 +1609,14 @@ public int getSerializedSize() { size += dataSize; size += 1 * getExtendsList().size(); } + { + int dataSize = 0; + for (int i = 0; i < companionExtends_.size(); i++) { + dataSize += computeStringSizeNoTag(companionExtends_.getRaw(i)); + } + size += dataSize; + size += 1 * getCompanionExtendsList().size(); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1627,6 +1731,8 @@ public Builder clear() { super.clear(); extends_ = com.google.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000001); + companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); return this; } @@ -1655,6 +1761,11 @@ public com.trueaccord.scalapb.Scalapb.MessageOptions buildPartial() { bitField0_ = (bitField0_ & ~0x00000001); } result.extends_ = extends_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = companionExtends_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.companionExtends_ = companionExtends_; onBuilt(); return result; } @@ -1680,6 +1791,16 @@ public Builder mergeFrom(com.trueaccord.scalapb.Scalapb.MessageOptions other) { } onChanged(); } + if (!other.companionExtends_.isEmpty()) { + if (companionExtends_.isEmpty()) { + companionExtends_ = other.companionExtends_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureCompanionExtendsIsMutable(); + companionExtends_.addAll(other.companionExtends_); + } + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1719,7 +1840,7 @@ private void ensureExtendsIsMutable() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public com.google.protobuf.ProtocolStringList @@ -1730,7 +1851,7 @@ private void ensureExtendsIsMutable() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public int getExtendsCount() { @@ -1740,7 +1861,7 @@ public int getExtendsCount() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public java.lang.String getExtends(int index) { @@ -1750,7 +1871,7 @@ public java.lang.String getExtends(int index) { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public com.google.protobuf.ByteString @@ -1761,7 +1882,7 @@ public java.lang.String getExtends(int index) { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder setExtends( @@ -1778,7 +1899,7 @@ public Builder setExtends( * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder addExtends( @@ -1795,7 +1916,7 @@ public Builder addExtends( * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder addAllExtends( @@ -1810,7 +1931,7 @@ public Builder addAllExtends( * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder clearExtends() { @@ -1823,7 +1944,7 @@ public Builder clearExtends() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder addExtendsBytes( @@ -1837,6 +1958,135 @@ public Builder addExtendsBytes( return this; } + private com.google.protobuf.LazyStringList companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureCompanionExtendsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = new com.google.protobuf.LazyStringArrayList(companionExtends_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public com.google.protobuf.ProtocolStringList + getCompanionExtendsList() { + return companionExtends_.getUnmodifiableView(); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public int getCompanionExtendsCount() { + return companionExtends_.size(); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public java.lang.String getCompanionExtends(int index) { + return companionExtends_.get(index); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public com.google.protobuf.ByteString + getCompanionExtendsBytes(int index) { + return companionExtends_.getByteString(index); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder setCompanionExtends( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompanionExtendsIsMutable(); + companionExtends_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder addCompanionExtends( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompanionExtendsIsMutable(); + companionExtends_.add(value); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder addAllCompanionExtends( + java.lang.Iterable values) { + ensureCompanionExtendsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, companionExtends_); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder clearCompanionExtends() { + companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder addCompanionExtendsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompanionExtendsIsMutable(); + companionExtends_.add(value); + onChanged(); + return this; + } + // @@protoc_insertion_point(builder_scope:scalapb.MessageOptions) } @@ -2434,15 +2684,15 @@ public com.trueaccord.scalapb.Scalapb.FieldOptions getDefaultInstanceForType() { "/protobuf/descriptor.proto\"s\n\016ScalaPbOpt" + "ions\022\024\n\014package_name\030\001 \001(\t\022\024\n\014flat_packa" + "ge\030\002 \001(\010\022\016\n\006import\030\003 \003(\t\022\023\n\013single_file\030" + - "\005 \001(\010\022\020\n\010preamble\030\004 \003(\t\"!\n\016MessageOption" + - "s\022\017\n\007extends\030\001 \003(\t\"\034\n\014FieldOptions\022\014\n\004ty" + - "pe\030\001 \001(\t:G\n\007options\022\034.google.protobuf.Fi" + - "leOptions\030\374\007 \001(\0132\027.scalapb.ScalaPbOption" + - "s:J\n\007message\022\037.google.protobuf.MessageOp" + - "tions\030\374\007 \001(\0132\027.scalapb.MessageOptions:D\n", - "\005field\022\035.google.protobuf.FieldOptions\030\374\007" + - " \001(\0132\025.scalapb.FieldOptionsB\030\n\026com.truea" + - "ccord.scalapb" + "\005 \001(\010\022\020\n\010preamble\030\004 \003(\t\"<\n\016MessageOption" + + "s\022\017\n\007extends\030\001 \003(\t\022\031\n\021companion_extends\030" + + "\002 \003(\t\"\034\n\014FieldOptions\022\014\n\004type\030\001 \001(\t:G\n\007o" + + "ptions\022\034.google.protobuf.FileOptions\030\374\007 " + + "\001(\0132\027.scalapb.ScalaPbOptions:J\n\007message\022" + + "\037.google.protobuf.MessageOptions\030\374\007 \001(\0132", + "\027.scalapb.MessageOptions:D\n\005field\022\035.goog" + + "le.protobuf.FieldOptions\030\374\007 \001(\0132\025.scalap" + + "b.FieldOptionsB\030\n\026com.trueaccord.scalapb" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -2468,7 +2718,7 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_scalapb_MessageOptions_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_scalapb_MessageOptions_descriptor, - new java.lang.String[] { "Extends", }); + new java.lang.String[] { "Extends", "CompanionExtends", }); internal_static_scalapb_FieldOptions_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_scalapb_FieldOptions_fieldAccessorTable = new diff --git a/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/DescriptorPimps.scala b/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/DescriptorPimps.scala index 4c0e03f16..1222cd8f6 100644 --- a/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/DescriptorPimps.scala +++ b/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/DescriptorPimps.scala @@ -226,6 +226,8 @@ trait DescriptorPimps { def extendsOption = messageOptions.getExtendsList.toSeq + def companionExtendsOption = messageOptions.getCompanionExtendsList.toSeq + def nameSymbol = scalaName.asSymbol def baseClasses: Seq[String] = @@ -233,6 +235,14 @@ trait DescriptorPimps { s"com.trueaccord.scalapb.Message[$nameSymbol]", s"com.trueaccord.lenses.Updatable[$nameSymbol]") ++ extendsOption + def companionBaseClasses: Seq[String] = { + val mixins = if (javaConversions) + Seq(s"com.trueaccord.scalapb.JavaProtoSupport[$nameSymbol, $javaTypeName]") else Nil + Seq(s"com.trueaccord.scalapb.GeneratedMessageCompanion[$nameSymbol]") ++ + mixins ++ + companionExtendsOption + } + def nestedTypes: Seq[Descriptor] = message.getNestedTypes.toSeq def isMapEntry: Boolean = message.getOptions.getMapEntry diff --git a/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/ProtobufGenerator.scala b/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/ProtobufGenerator.scala index dbafc5050..657810071 100644 --- a/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/ProtobufGenerator.scala +++ b/compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/ProtobufGenerator.scala @@ -809,9 +809,7 @@ class ProtobufGenerator(val params: GeneratorParams) extends DescriptorPimps { def generateMessageCompanion(message: Descriptor)(printer: FunctionalPrinter): FunctionalPrinter = { val className = message.nameSymbol - val mixins = if (message.javaConversions) - s"with com.trueaccord.scalapb.JavaProtoSupport[$className, ${message.javaTypeName}] " else "" - val companionType = s"com.trueaccord.scalapb.GeneratedMessageCompanion[$className] $mixins" + val companionType = message.companionBaseClasses.mkString(" with ") printer.addM( s"""object $className extends $companionType { | implicit def messageCompanion: $companionType = this""") @@ -975,7 +973,7 @@ class ProtobufGenerator(val params: GeneratorParams) extends DescriptorPimps { } def generateSingleScalaFileForFileDescriptor(file: FileDescriptor): Seq[CodeGeneratorResponse.File] = { - val code = + val code = scalaFileHeader(file) .print(file.getEnumTypes)(printEnum) .print(file.getMessageTypes)(printMessage) @@ -1073,8 +1071,8 @@ object ProtobufGenerator { request.getFileToGenerateList.foreach { name => val file = filesByName(name) - val responseFiles = - if (file.scalaOptions.getSingleFile) + val responseFiles = + if (file.scalaOptions.getSingleFile) generator.generateSingleScalaFileForFileDescriptor(file) else generator.generateMultipleScalaFilesForFileDescriptor(file) b.addAllFile(responseFiles) diff --git a/e2e/src/main/protobuf/custom_types.proto b/e2e/src/main/protobuf/custom_types.proto index 382c7e10e..29d5ba966 100644 --- a/e2e/src/main/protobuf/custom_types.proto +++ b/e2e/src/main/protobuf/custom_types.proto @@ -47,6 +47,7 @@ message OneofMessage { message CustomerEvent { option (scalapb.message).extends = "com.trueaccord.pb.DomainEvent"; + option (scalapb.message).companion_extends = "com.trueaccord.pb.DomainEventCompanion"; optional string person_id = 1 [(scalapb.field).type = "com.trueaccord.pb.PersonId"]; optional int32 optional_number = 2; diff --git a/e2e/src/main/scala/com/trueaccord/pb/PersonId.scala b/e2e/src/main/scala/com/trueaccord/pb/PersonId.scala index 0cc8b1ee2..a3f98af96 100644 --- a/e2e/src/main/scala/com/trueaccord/pb/PersonId.scala +++ b/e2e/src/main/scala/com/trueaccord/pb/PersonId.scala @@ -36,3 +36,7 @@ trait DomainEvent { def repeatedNumber: Seq[Int] def requiredNumber: Int } + +trait DomainEventCompanion { + val thisIs = "The companion object" +} diff --git a/e2e/src/test/scala/CustomTypesSpec.scala b/e2e/src/test/scala/CustomTypesSpec.scala index d609ce7bf..7662ada75 100644 --- a/e2e/src/test/scala/CustomTypesSpec.scala +++ b/e2e/src/test/scala/CustomTypesSpec.scala @@ -98,4 +98,9 @@ class CustomTypesSpec extends FlatSpec with MustMatchers { t.repeatedNumber must be(Seq(2,3,4)) t.requiredNumber must be(5) } + + "Extended companion objects" should "inherit from marker type" in { + CustomerEvent mustBe a [DomainEventCompanion] + CustomerEvent.thisIs must be("The companion object") + } } diff --git a/protobuf/scalapb/scalapb.proto b/protobuf/scalapb/scalapb.proto index e49da7ea5..da43d82d8 100644 --- a/protobuf/scalapb/scalapb.proto +++ b/protobuf/scalapb/scalapb.proto @@ -36,8 +36,11 @@ extend google.protobuf.FileOptions { } message MessageOptions { - // additional classes and traits to mix in to the case class. + // Additional classes and traits to mix in to the case class. repeated string extends = 1; + + // Additional classes and traits to mix in to the companion object. + repeated string companion_extends = 2; } extend google.protobuf.MessageOptions { diff --git a/scalapb-runtime/jvm/src/main/java/com/trueaccord/scalapb/Scalapb.java b/scalapb-runtime/jvm/src/main/java/com/trueaccord/scalapb/Scalapb.java index ef8f6daf6..b6222aed5 100644 --- a/scalapb-runtime/jvm/src/main/java/com/trueaccord/scalapb/Scalapb.java +++ b/scalapb-runtime/jvm/src/main/java/com/trueaccord/scalapb/Scalapb.java @@ -1327,7 +1327,7 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ com.google.protobuf.ProtocolStringList @@ -1336,7 +1336,7 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ int getExtendsCount(); @@ -1344,7 +1344,7 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ java.lang.String getExtends(int index); @@ -1352,11 +1352,46 @@ public interface MessageOptionsOrBuilder extends * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ com.google.protobuf.ByteString getExtendsBytes(int index); + + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + com.google.protobuf.ProtocolStringList + getCompanionExtendsList(); + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + int getCompanionExtendsCount(); + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + java.lang.String getCompanionExtends(int index); + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + com.google.protobuf.ByteString + getCompanionExtendsBytes(int index); } /** * Protobuf type {@code scalapb.MessageOptions} @@ -1371,6 +1406,7 @@ private MessageOptions(com.google.protobuf.GeneratedMessage.Builder builder) } private MessageOptions() { extends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; } @java.lang.Override @@ -1409,6 +1445,15 @@ private MessageOptions( extends_.add(bs); break; } + case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + companionExtends_.add(bs); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -1421,6 +1466,9 @@ private MessageOptions( if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { extends_ = extends_.getUnmodifiableView(); } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = companionExtends_.getUnmodifiableView(); + } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -1443,7 +1491,7 @@ private MessageOptions( * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public com.google.protobuf.ProtocolStringList @@ -1454,7 +1502,7 @@ private MessageOptions( * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public int getExtendsCount() { @@ -1464,7 +1512,7 @@ public int getExtendsCount() { * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public java.lang.String getExtends(int index) { @@ -1474,7 +1522,7 @@ public java.lang.String getExtends(int index) { * repeated string extends = 1; * *
-     * additional classes and traits to mix in to the case class.
+     * Additional classes and traits to mix in to the case class.
      * 
*/ public com.google.protobuf.ByteString @@ -1482,6 +1530,51 @@ public java.lang.String getExtends(int index) { return extends_.getByteString(index); } + public static final int COMPANION_EXTENDS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList companionExtends_; + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public com.google.protobuf.ProtocolStringList + getCompanionExtendsList() { + return companionExtends_; + } + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public int getCompanionExtendsCount() { + return companionExtends_.size(); + } + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public java.lang.String getCompanionExtends(int index) { + return companionExtends_.get(index); + } + /** + * repeated string companion_extends = 2; + * + *
+     * Additional classes and traits to mix in to the companion object.
+     * 
+ */ + public com.google.protobuf.ByteString + getCompanionExtendsBytes(int index) { + return companionExtends_.getByteString(index); + } + private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; @@ -1497,6 +1590,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < extends_.size(); i++) { com.google.protobuf.GeneratedMessage.writeString(output, 1, extends_.getRaw(i)); } + for (int i = 0; i < companionExtends_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, companionExtends_.getRaw(i)); + } unknownFields.writeTo(output); } @@ -1513,6 +1609,14 @@ public int getSerializedSize() { size += dataSize; size += 1 * getExtendsList().size(); } + { + int dataSize = 0; + for (int i = 0; i < companionExtends_.size(); i++) { + dataSize += computeStringSizeNoTag(companionExtends_.getRaw(i)); + } + size += dataSize; + size += 1 * getCompanionExtendsList().size(); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1627,6 +1731,8 @@ public Builder clear() { super.clear(); extends_ = com.google.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000001); + companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); return this; } @@ -1655,6 +1761,11 @@ public com.trueaccord.scalapb.Scalapb.MessageOptions buildPartial() { bitField0_ = (bitField0_ & ~0x00000001); } result.extends_ = extends_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = companionExtends_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.companionExtends_ = companionExtends_; onBuilt(); return result; } @@ -1680,6 +1791,16 @@ public Builder mergeFrom(com.trueaccord.scalapb.Scalapb.MessageOptions other) { } onChanged(); } + if (!other.companionExtends_.isEmpty()) { + if (companionExtends_.isEmpty()) { + companionExtends_ = other.companionExtends_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureCompanionExtendsIsMutable(); + companionExtends_.addAll(other.companionExtends_); + } + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1719,7 +1840,7 @@ private void ensureExtendsIsMutable() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public com.google.protobuf.ProtocolStringList @@ -1730,7 +1851,7 @@ private void ensureExtendsIsMutable() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public int getExtendsCount() { @@ -1740,7 +1861,7 @@ public int getExtendsCount() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public java.lang.String getExtends(int index) { @@ -1750,7 +1871,7 @@ public java.lang.String getExtends(int index) { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public com.google.protobuf.ByteString @@ -1761,7 +1882,7 @@ public java.lang.String getExtends(int index) { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder setExtends( @@ -1778,7 +1899,7 @@ public Builder setExtends( * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder addExtends( @@ -1795,7 +1916,7 @@ public Builder addExtends( * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder addAllExtends( @@ -1810,7 +1931,7 @@ public Builder addAllExtends( * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder clearExtends() { @@ -1823,7 +1944,7 @@ public Builder clearExtends() { * repeated string extends = 1; * *
-       * additional classes and traits to mix in to the case class.
+       * Additional classes and traits to mix in to the case class.
        * 
*/ public Builder addExtendsBytes( @@ -1837,6 +1958,135 @@ public Builder addExtendsBytes( return this; } + private com.google.protobuf.LazyStringList companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureCompanionExtendsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + companionExtends_ = new com.google.protobuf.LazyStringArrayList(companionExtends_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public com.google.protobuf.ProtocolStringList + getCompanionExtendsList() { + return companionExtends_.getUnmodifiableView(); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public int getCompanionExtendsCount() { + return companionExtends_.size(); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public java.lang.String getCompanionExtends(int index) { + return companionExtends_.get(index); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public com.google.protobuf.ByteString + getCompanionExtendsBytes(int index) { + return companionExtends_.getByteString(index); + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder setCompanionExtends( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompanionExtendsIsMutable(); + companionExtends_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder addCompanionExtends( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompanionExtendsIsMutable(); + companionExtends_.add(value); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder addAllCompanionExtends( + java.lang.Iterable values) { + ensureCompanionExtendsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, companionExtends_); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder clearCompanionExtends() { + companionExtends_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string companion_extends = 2; + * + *
+       * Additional classes and traits to mix in to the companion object.
+       * 
+ */ + public Builder addCompanionExtendsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompanionExtendsIsMutable(); + companionExtends_.add(value); + onChanged(); + return this; + } + // @@protoc_insertion_point(builder_scope:scalapb.MessageOptions) } @@ -2434,15 +2684,15 @@ public com.trueaccord.scalapb.Scalapb.FieldOptions getDefaultInstanceForType() { "/protobuf/descriptor.proto\"s\n\016ScalaPbOpt" + "ions\022\024\n\014package_name\030\001 \001(\t\022\024\n\014flat_packa" + "ge\030\002 \001(\010\022\016\n\006import\030\003 \003(\t\022\023\n\013single_file\030" + - "\005 \001(\010\022\020\n\010preamble\030\004 \003(\t\"!\n\016MessageOption" + - "s\022\017\n\007extends\030\001 \003(\t\"\034\n\014FieldOptions\022\014\n\004ty" + - "pe\030\001 \001(\t:G\n\007options\022\034.google.protobuf.Fi" + - "leOptions\030\374\007 \001(\0132\027.scalapb.ScalaPbOption" + - "s:J\n\007message\022\037.google.protobuf.MessageOp" + - "tions\030\374\007 \001(\0132\027.scalapb.MessageOptions:D\n", - "\005field\022\035.google.protobuf.FieldOptions\030\374\007" + - " \001(\0132\025.scalapb.FieldOptionsB\030\n\026com.truea" + - "ccord.scalapb" + "\005 \001(\010\022\020\n\010preamble\030\004 \003(\t\"<\n\016MessageOption" + + "s\022\017\n\007extends\030\001 \003(\t\022\031\n\021companion_extends\030" + + "\002 \003(\t\"\034\n\014FieldOptions\022\014\n\004type\030\001 \001(\t:G\n\007o" + + "ptions\022\034.google.protobuf.FileOptions\030\374\007 " + + "\001(\0132\027.scalapb.ScalaPbOptions:J\n\007message\022" + + "\037.google.protobuf.MessageOptions\030\374\007 \001(\0132", + "\027.scalapb.MessageOptions:D\n\005field\022\035.goog" + + "le.protobuf.FieldOptions\030\374\007 \001(\0132\025.scalap" + + "b.FieldOptionsB\030\n\026com.trueaccord.scalapb" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -2468,7 +2718,7 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_scalapb_MessageOptions_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_scalapb_MessageOptions_descriptor, - new java.lang.String[] { "Extends", }); + new java.lang.String[] { "Extends", "CompanionExtends", }); internal_static_scalapb_FieldOptions_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_scalapb_FieldOptions_fieldAccessorTable = new