Пример #1
0
 def VisitMessage(self, msg_proto, type_context, nested_msgs, nested_enums):
     upgraded_proto = copy.deepcopy(msg_proto)
     if upgraded_proto.options.deprecated and not self._envoy_internal_shadow:
         options.AddHideOption(upgraded_proto.options)
     options.SetVersioningAnnotation(upgraded_proto.options,
                                     type_context.name)
     # Mark deprecated fields as ready for deletion by protoxform.
     for f in upgraded_proto.field:
         if f.options.deprecated:
             self._Deprecate(upgraded_proto, f)
             if self._envoy_internal_shadow:
                 # When shadowing, we use the upgraded version of types (which should
                 # themselves also be shadowed), to allow us to avoid unnecessary
                 # references to the previous version (and complexities around
                 # upgrading during API boosting).
                 f.type_name = self._UpgradedType(f.type_name)
             else:
                 # Make sure the type name is erased so it isn't picked up by protoxform
                 # when computing deps.
                 f.type_name = ""
         else:
             f.type_name = self._UpgradedType(f.type_name)
         if f.options.HasExtension(migrate_pb2.field_migrate):
             field_migrate = f.options.Extensions[migrate_pb2.field_migrate]
             self._Rename(f, field_migrate)
             self._OneofPromotion(upgraded_proto, f, field_migrate)
     # Upgrade nested messages.
     del upgraded_proto.nested_type[:]
     upgraded_proto.nested_type.extend(nested_msgs)
     # Upgrade enums.
     del upgraded_proto.enum_type[:]
     upgraded_proto.enum_type.extend(nested_enums)
     return upgraded_proto
Пример #2
0
 def VisitMessage(self, msg_proto, type_context, nested_msgs, nested_enums):
     upgraded_proto = copy.deepcopy(msg_proto)
     if upgraded_proto.options.deprecated:
         options.AddHideOption(upgraded_proto.options)
     options.SetVersioningAnnotation(upgraded_proto.options,
                                     type_context.name)
     # Mark deprecated fields as ready for deletion by protoxform.
     for f in upgraded_proto.field:
         if f.options.deprecated:
             self._Deprecate(upgraded_proto, f)
             # Make sure the type name is erased so it isn't picked up by protoxform
             # when computing deps.
             f.type_name = ""
         else:
             f.type_name = self._UpgradedType(f.type_name)
         if f.options.HasExtension(migrate_pb2.field_migrate):
             self._Rename(f,
                          f.options.Extensions[migrate_pb2.field_migrate])
     # Upgrade nested messages.
     del upgraded_proto.nested_type[:]
     upgraded_proto.nested_type.extend(nested_msgs)
     # Upgrade enums.
     del upgraded_proto.enum_type[:]
     upgraded_proto.enum_type.extend(nested_enums)
     return upgraded_proto