Skip to content

Instantly share code, notes, and snippets.

@chanced
Last active January 10, 2021 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanced/ba81cfd1e462133ca8c29ab6de6efd5d to your computer and use it in GitHub Desktop.
Save chanced/ba81cfd1e462133ca8c29ab6de6efd5d to your computer and use it in GitHub Desktop.
boilerplate for extending protoc-gen-star after making methods public
package genproto
import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
pgs "github.com/lyft/protoc-gen-star"
)
// Enum describes an enumeration type. Its parent can be either a Message or a
// File.
type Enum struct {
enum pgs.Enum
}
var _ pgs.Enum = (*Enum)(nil)
// Name of the entity
func (e *Enum) Name() pgs.Name {
return e.enum.Name()
}
// FullyQualifiedName is the fully qualified name of the entity.
// For example, a message 'HelloRequest' in a 'helloworld' package takes the form of '.helloworld.HelloRequest'.
func (e *Enum) FullyQualifiedName() string {
return e.enum.FullyQualifiedName()
}
// Syntax identifies whether this entity is encoded with proto2 or proto3 syntax.
func (e *Enum) Syntax() pgs.Syntax {
return e.enum.Syntax()
}
// Package returns the container package for this entity.
func (e *Enum) Package() pgs.Package {
return e.enum.Package()
}
// File returns the File containing this entity.
func (e *Enum) File() pgs.File {
return e.enum.File()
}
// BuildTarget identifies whether or not generation should be performed on this entity.
// Use this flag to determine if the file was targeted in the protoc run or if it was
// loaded as an external dependency.
func (e *Enum) BuildTarget() bool {
return e.enum.BuildTarget()
}
// SourceCodeInfo returns the SourceCodeInfo associated with the entity.
// Primarily, this struct contains the comments associated with the Entity.
func (e *Enum) SourceCodeInfo() pgs.SourceCodeInfo {
return e.enum.SourceCodeInfo()
}
// Descriptor returns the proto descriptor for this Enum
func (e *Enum) Descriptor() *descriptor.EnumDescriptorProto {
return e.enum.Descriptor()
}
// Parent resolves to either a Message or File that directly contains this
// Enum.
func (e *Enum) Parent() pgs.ParentEntity {
return e.enum.Parent()
}
// Imports includes external files directly required by this entity.
// Call TransitiveImports on File to get all transitive dependencies.
func (e *Enum) Imports() []pgs.File {
return e.enum.Imports()
}
// Values returns each defined enumeration value.
func (e *Enum) Values() []pgs.EnumValue {
return e.enum.Values()
}
// Accept processes a Visitor
func (e *Enum) Accept(v pgs.Visitor) error {
return e.enum.Accept(v)
}
// AddDependent ...
func (e *Enum) AddDependent(m pgs.Message) {
e.enum.AddDependent(m)
}
// AddValue ...
func (e *Enum) AddValue(v pgs.EnumValue) {
e.enum.AddValue(v)
}
// SetParent ...
func (e *Enum) SetParent(p pgs.ParentEntity) {
e.enum.SetParent(p)
}
// ChildAtPath ...
func (e *Enum) ChildAtPath(path []int32) pgs.Entity {
return e.enum.ChildAtPath(path)
}
// AddSourceCodeInfo ...
func (e *Enum) AddSourceCodeInfo(info pgs.SourceCodeInfo) {
e.enum.AddSourceCodeInfo(info)
}
// Dependents returns all of the messages where Enum is directly or
// transitively used.
func (e *Enum) Dependents() []pgs.Message {
return e.enum.Dependents()
}
// Extension extracts an extension from the entity's options,
// described by desc and populates the value ext. Ext must be a
// pointer type. An error will only be returned if there is a type
// mismatch between desc and ext. The ok value will be true if the
// extension was found. If the extension is NOT found, ok will be
// false and err will be nil.
func (e *Enum) Extension(desc *proto.ExtensionDesc, ext interface{}) (bool, error) {
return e.enum.Extension(desc, ext)
}
package genproto
import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
pgs "github.com/lyft/protoc-gen-star"
)
// An Extension is a custom option annotation that can be applied to an Entity to provide additional
// semantic details and metadata about the Entity.
type Extension struct {
ext pgs.Extension
}
var _ pgs.Extension = (*Extension)(nil)
// DefinedIn returns the ParentEntity where the Extension is defined
func (e *Extension) DefinedIn() pgs.ParentEntity {
return e.ext.DefinedIn()
}
// Extendee returns the Message that the Extension is extending
func (e *Extension) Extendee() pgs.Message {
return e.ext.Extendee()
}
// SetExtendee ...
func (e *Extension) SetExtendee(m pgs.Message) {
e.ext.SetExtendee(m)
}
// Name of the entity
func (e *Extension) Name() pgs.Name {
return e.ext.Name()
}
// FullyQualifiedName returns the fully qualified name of the entity.
// For example, a message 'HelloRequest' in a 'helloworld'
// package takes the form of '.helloworld.HelloRequest'.
func (e *Extension) FullyQualifiedName() string {
return e.ext.FullyQualifiedName()
}
// Syntax identifies whether this entity is encoded with proto2 or proto3
// syntax.
func (e *Extension) Syntax() pgs.Syntax {
return e.ext.Syntax()
}
// Package returns the container package for this entity.
func (e *Extension) Package() pgs.Package {
return e.ext.Package()
}
// Imports includes external files directly required by this entity. Call
// TransitiveImports on File to get all transitive dependencies.
func (e *Extension) Imports() []pgs.File {
return e.ext.Imports()
}
// File returns the File containing this entity.
func (e *Extension) File() pgs.File {
return e.ext.File()
}
// Extension extracts an extension from the entity's options, described by
// desc and populates the value ext. Ext must be a pointer type. An error
// will only be returned if there is a type mismatch between desc and ext.
// The ok value will be true if the extension was found. If the extension
// is NOT found, ok will be false and err will be nil.
func (e *Extension) Extension(desc *proto.ExtensionDesc, ext interface{}) (ok bool, err error) {
return e.ext.Extension(desc, ext)
}
// BuildTarget identifies whether or not generation should be performed on
// this entity. Use this flag to determine if the file was targeted in the
// protoc run or if it was loaded as an external dependency.
func (e *Extension) BuildTarget() bool {
return e.ext.BuildTarget()
}
// SourceCodeInfo returns the SourceCodeInfo associated with the entity.
// Primarily, this struct contains the comments associated with the Entity.
func (e *Extension) SourceCodeInfo() pgs.SourceCodeInfo {
return e.ext.SourceCodeInfo()
}
// ChildAtPath ...
func (e *Extension) ChildAtPath(path []int32) pgs.Entity {
return e.ext.ChildAtPath(path)
}
// AddSourceCodeInfo ...
func (e *Extension) AddSourceCodeInfo(info pgs.SourceCodeInfo) {
e.ext.AddSourceCodeInfo(info)
}
// Descriptor returns the proto descriptor for this field
func (e *Extension) Descriptor() *descriptor.FieldDescriptorProto
// Message returns the Message containing this Field.
func (e *Extension) Message() pgs.Message
// InOneOf returns true if the field is in a OneOf of the parent Message.
func (e *Extension) InOneOf() bool
// OneOf returns the OneOf that this field is apart of. Nil is returned if
// the field is not within a OneOf.
func (e *Extension) OneOf() pgs.OneOf
// Type returns the FieldType of this Field.
func (e *Extension) Type() pgs.FieldType {
return e.ext.Type()
}
// Required returns whether or not the field is labeled as required. This
// will only be true if the syntax is proto2.
func (e *Extension) Required() bool {
return e.ext.Required()
}
// SetMessage ...
func (e *Extension) SetMessage(m pgs.Message) {
e.ext.SetMessage(m)
}
// SetOneOf ...
func (e *Extension) SetOneOf(o pgs.OneOf) {
e.ext.SetOneOf(o)
}
// AddType ...
func (e *Extension) AddType(t pgs.FieldType) {
e.ext.AddType(t)
}
// Accept ...
func (e *Extension) Accept(v pgs.Visitor) error {
return e.ext.Accept(v)
}
package genproto
import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
pgs "github.com/lyft/protoc-gen-star"
)
// A Field describes a member of a Message. A field may also be a member of a
// OneOf on the Message.
type Field struct {
field pgs.Field
}
var _ pgs.Field = (*Field)(nil)
// Name of the entity
func (f *Field) Name() pgs.Name {
return f.field.Name()
}
// FullyQualifiedName is the fully qualified name of the entity.
// For example, a message 'HelloRequest' in a 'helloworld'
// package takes the form of '.helloworld.HelloRequest'.
func (f *Field) FullyQualifiedName() string {
return f.field.FullyQualifiedName()
}
// Syntax identifies whether this entity is encoded with proto2 or proto3
// syntax.
func (f *Field) Syntax() pgs.Syntax {
return f.field.Syntax()
}
// Package returns the container package for this entity.
func (f *Field) Package() pgs.Package {
return f.field.Package()
}
// Imports includes external files directly required by this entity. Call
// TransitiveImports on File to get all transitive dependencies.
func (f *Field) Imports() []pgs.File {
return f.field.Imports()
}
// File returns the File containing this entity.
func (f *Field) File() pgs.File {
return f.field.File()
}
// Extension extracts an extension from the entity's options, described by
// desc and populates the value ext. Ext must be a pointer type. An error
// will only be returned if there is a type mismatch between desc and ext.
// The ok value will be true if the extension was found. If the extension
// is NOT found, ok will be false and err will be nil.
func (f *Field) Extension(desc *proto.ExtensionDesc, ext interface{}) (ok bool, err error) {
return f.field.Extension(desc, ext)
}
// BuildTarget identifies whether or not generation should be performed on
// this entity. Use this flag to determine if the file was targeted in the
// protoc run or if it was loaded as an external dependency.
func (f *Field) BuildTarget() bool {
return f.field.BuildTarget()
}
// SourceCodeInfo returns the SourceCodeInfo associated with the entity.
// Primarily, this struct contains the comments associated with the Entity.
func (f *Field) SourceCodeInfo() pgs.SourceCodeInfo {
return f.field.SourceCodeInfo()
}
// ChildAtPath ...
func (f *Field) ChildAtPath(path []int32) pgs.Entity {
return f.field.ChildAtPath(path)
}
// AddSourceCodeInfo ...
func (f *Field) AddSourceCodeInfo(info pgs.SourceCodeInfo) {
f.field.AddSourceCodeInfo(info)
}
// Descriptor returns the proto descriptor for this field
func (f *Field) Descriptor() *descriptor.FieldDescriptorProto
// Message returns the Message containing this Field.
func (f *Field) Message() pgs.Message
// InOneOf returns true if the field is in a OneOf of the parent Message.
func (f *Field) InOneOf() bool
// OneOf returns the OneOf that this field is apart of. Nil is returned if
// the field is not within a OneOf.
func (f *Field) OneOf() pgs.OneOf
// Type returns the FieldType of this Field.
func (f *Field) Type() pgs.FieldType {
return f.field.Type()
}
// Required returns whether or not the field is labeled as required. This
// will only be true if the syntax is proto2.
func (f *Field) Required() bool {
return f.field.Required()
}
// SetMessage ...
func (f *Field) SetMessage(m pgs.Message) {
f.field.SetMessage(m)
}
// SetOneOf ...
func (f *Field) SetOneOf(o pgs.OneOf) {
f.field.SetOneOf(o)
}
// AddType ...
func (f *Field) AddType(t pgs.FieldType) {
f.field.AddType(t)
}
// Accept ...
func (f *Field) Accept(v pgs.Visitor) error {
return f.field.Accept(v)
}
var _ pgs.Field = (*Field)(nil)
package genproto
import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
pgs "github.com/lyft/protoc-gen-star"
)
// File describes the contents of a single proto file.
type File struct {
file pgs.File
}
// Name of the entity
func (f *File) Name() pgs.Name {
return f.file.Name()
}
// FullyQualifiedName is the fully qualified name of the entity. For example, a message 'HelloRequest' in a 'helloworld' package takes the form of '.helloworld.HelloRequest'.
func (f *File) FullyQualifiedName() string {
return f.file.FullyQualifiedName()
}
//Syntax identifies whether this entity is encoded with proto2 or proto3 syntax.
func (f *File) Syntax() pgs.Syntax {
return f.file.Syntax()
}
// Package returns the container package for this entity.
func (f *File) Package() pgs.Package {
return f.file.Package()
}
// File returns this file
func (f *File) File() pgs.File {
return f
}
// BuildTarget identifies whether or not generation should be performed on this entity. Use this flag to determine if the file was targeted in the protoc run or if it was loaded as an external dependency.
func (f *File) BuildTarget() bool {
return f.file.BuildTarget()
}
// Descriptor returns the underlying descriptor for the proto file
func (f *File) Descriptor() *descriptor.FileDescriptorProto {
return f.file.Descriptor()
}
// InputPath returns the input FilePath. This is equivalent to the value
// returned by Name.
func (f *File) InputPath() pgs.FilePath {
return f.file.InputPath()
}
// MapEntries noop
func (f *File) MapEntries() (me []pgs.Message) {
return nil
}
// SourceCodeInfo represents data about an entity from the source. Currently
// this only contains information about comments protoc associates with
// entities.
//
// All comments have their // or /* */ stripped by protoc. See the
// SourceCodeInfo documentation for more details about how comments are
// associated with entities.
func (f *File) SourceCodeInfo() pgs.SourceCodeInfo {
return f.file.SourceCodeInfo()
}
// SyntaxSourceCodeInfo returns the comment info attached to the `syntax`
// stanza of the file. This method is an alias of the SourceCodeInfo method.
func (f *File) SyntaxSourceCodeInfo() pgs.SourceCodeInfo {
return f.file.SyntaxSourceCodeInfo()
}
// PackageSourceCodeInfo returns the comment info attached to the `package`
// stanza of the file.
func (f *File) PackageSourceCodeInfo() pgs.SourceCodeInfo {
return f.file.PackageSourceCodeInfo()
}
// TransitiveImports returns all direct and transitive dependencies of this
// File. Use Imports to obtain only direct dependencies.
func (f *File) TransitiveImports() []pgs.File {
return f.file.TransitiveImports()
}
// UnusedImports returns all imported files that aren't used by the current
// File. Public imports are not included in this list.
func (f *File) UnusedImports() []pgs.File {
return f.file.UnusedImports()
}
// Dependents returns all files where the given file was directly or
// transitively imported.
func (f *File) Dependents() []pgs.File {
return f.file.Dependents()
}
// Services returns the services from this proto file.
func (f *File) Services() []pgs.Service {
return f.file.Services()
}
// Accept processes a Visitor
func (f *File) Accept(v pgs.Visitor) (err error) {
return f.file.Accept(v)
}
// AddDefExtension ...
func (f *File) AddDefExtension(ext pgs.Extension) {
f.file.AddDefExtension(ext)
}
// SetPackage ...
func (f *File) SetPackage(p pgs.Package) {
f.file.SetPackage(p)
}
//AddFileDependency ...
func (f *File) AddFileDependency(fl pgs.File) {
f.file.AddFileDependency(fl)
}
// AddDependent ...
func (f *File) AddDependent(fl pgs.File) {
f.file.AddDependent(fl)
}
// AddService ...
func (f *File) AddService(s pgs.Service) {
f.file.AddService(s)
}
// AddPackageSourceCodeInfo ...
func (f *File) AddPackageSourceCodeInfo(info pgs.SourceCodeInfo) {
f.file.AddPackageSourceCodeInfo(info)
}
// AddEnum ...
func (f *File) AddEnum(e pgs.Enum) {
f.file.AddEnum(e)
}
// AddMessage ...
func (f *File) AddMessage(msg pgs.Message) {
f.file.AddMessage(msg)
}
// AddMapEntry ...
func (f *File) AddMapEntry(msg pgs.Message) {
f.file.AddMapEntry(msg)
}
// ChildAtPath ...
func (f *File) ChildAtPath(path []int32) pgs.Entity {
return f.file.ChildAtPath(path)
}
// AddSourceCodeInfo ...
func (f *File) AddSourceCodeInfo(info pgs.SourceCodeInfo) {
f.file.AddSourceCodeInfo(info)
}
// AllEnums returns all top-level and nested enums from this entity.
func (f *File) AllEnums() []pgs.Enum {
return f.file.AllEnums()
}
// AllMessages returns all the top-level and nested messages from this Entity.
func (f *File) AllMessages() []pgs.Message {
return f.file.AllMessages()
}
// Imports includes external files directly required by this entity. Call
// TransitiveImports on File to get all transitive dependencies.
func (f *File) Imports() (i []pgs.File) {
return f.file.Imports()
}
// DefinedExtensions returns all Extensions defined on this entity.
func (f *File) DefinedExtensions() []pgs.Extension {
return f.file.DefinedExtensions()
}
// Extension extracts an extension from the entity's options, described by
// desc and populates the value ext. Ext must be a pointer type. An error
// will only be returned if there is a type mismatch between desc and ext.
// The ok value will be true if the extension was found. If the extension
// is NOT found, ok will be false and err will be nil.
func (f *File) Extension(desc *proto.ExtensionDesc, ext interface{}) (bool, error) {
return f.file.Extension(desc, ext)
}
// Enums returns the top-level enums from this entity. Nested enums
// are not included.
func (f *File) Enums() []pgs.Enum {
return f.file.Enums()
}
// Messages returns the top-level messages from this entity. Nested
// messages are not included.
func (f *File) Messages() []pgs.Message {
return f.file.Messages()
}
var _ pgs.File = (*File)(nil)
package genproto
import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
pgs "github.com/lyft/protoc-gen-star"
)
// Message describes a proto message. Messages can be contained in either
// another Message or File, and may house further Messages and/or Enums. While
// all Fields technically live on the Message, some may be contained within
// OneOf blocks.
type Message struct {
msg pgs.Message
}
var _ pgs.Message = (*Message)(nil)
// Name is the Name of the entity
func (m *Message) Name() pgs.Name {
return m.msg.Name()
}
//FullyQualifiedName is the fully qualified name of the entity. For example, a message 'HelloRequest' in a 'helloworld' package takes the form of '.helloworld.HelloRequest'.
func (m *Message) FullyQualifiedName() string {
return m.msg.FullyQualifiedName()
}
// Syntax identifies whether this entity is encoded with proto2 or proto3 syntax.
func (m *Message) Syntax() pgs.Syntax {
return m.msg.Syntax()
}
// Package returns the container package for this entity.
func (m *Message) Package() pgs.Package {
return m.msg.Package()
}
// File returns the File containing this entity.
func (m *Message) File() pgs.File {
return m.msg.File()
}
// BuildTarget identifies whether or not generation should be performed on
// this entity. Use this flag to determine if the file was targeted in the
// protoc run or if it was loaded as an external dependency.
func (m *Message) BuildTarget() bool {
return m.msg.BuildTarget()
}
// SourceCodeInfo returns the SourceCodeInfo associated with the entity.
// Primarily, this struct contains the comments associated with the Entity.
func (m *Message) SourceCodeInfo() pgs.SourceCodeInfo {
return m.msg.SourceCodeInfo()
}
// Descriptor returns the underlying proto descriptor for this message
func (m *Message) Descriptor() *descriptor.DescriptorProto {
return m.msg.Descriptor()
}
// Parent returns either the File or Message that directly contains this
// Message.
func (m *Message) Parent() pgs.ParentEntity {
return m.msg.Parent()
}
// Enums returns the top-level enums from this entity. Nested enums
// are not included.
func (m *Message) Enums() []pgs.Enum {
return m.msg.Enums()
}
// Messages returns the top-level messages from this entity. Nested
// messages are not included.
func (m *Message) Messages() []pgs.Message {
return m.msg.Messages()
}
// Fields returns all fields on the message, including those contained within
// OneOf blocks.
func (m *Message) Fields() []pgs.Field {
return m.msg.Fields()
}
// OneOfs returns the OneOfs contained within this Message.
func (m *Message) OneOfs() []pgs.OneOf {
return m.msg.OneOfs()
}
// MapEntries returns the MapEntry message types contained within this
// Entity. These messages are not returned by the Messages or AllMessages
// methods. Map Entry messages are typically not exposed to the end user.
func (m *Message) MapEntries() []pgs.Message {
return m.msg.MapEntries()
}
// NonOneOfFields returns all fields not contained within OneOf blocks.
func (m *Message) NonOneOfFields() []pgs.Field {
return m.msg.NonOneOfFields()
}
// OneOfFields returns only the fields contained within OneOf blocks.
func (m *Message) OneOfFields() []pgs.Field {
return m.msg.NonOneOfFields()
}
// Extensions returns all of the Extensions applied to this Message.
func (m *Message) Extensions() []pgs.Extension {
return m.msg.Extensions()
}
// Dependents returns all of the messages where message is directly or
// transitively used.
func (m *Message) Dependents() []pgs.Message {
return m.msg.Dependents()
}
// IsMapEntry identifies this message as a MapEntry. If true, this message is
// not generated as code, and is used exclusively when marshaling a map field
// to the wire format.
func (m *Message) IsMapEntry() bool {
return m.msg.IsMapEntry()
}
// IsWellKnown identifies whether or not this Message is a WKT from the
// `google.protobuf` package. Most official plugins special case these types
// and they usually need to be handled differently.
func (m *Message) IsWellKnown() bool {
return m.msg.IsWellKnown()
}
// WellKnownType returns the WellKnownType associated with this field. If
// IsWellKnown returns false, UnknownWKT is returned.
func (m *Message) WellKnownType() pgs.WellKnownType {
return m.msg.WellKnownType()
}
// SetParent ...
func (m *Message) SetParent(p pgs.ParentEntity) {
m.msg.SetParent(p)
}
// GetDependents ...
func (m *Message) GetDependents(set map[string]pgs.Message) {
m.msg.GetDependents(set)
}
//AddDefExtension ...
func (m *Message) AddDefExtension(ext pgs.Extension) {
m.msg.AddDefExtension(ext)
}
// Accept processes a Visitor
func (m *Message) Accept(v pgs.Visitor) error {
return m.msg.Accept(v)
}
// AddField adds a Field to the message
func (m *Message) AddField(f pgs.Field) {
m.msg.AddField(f)
}
// AddExtension ...
func (m *Message) AddExtension(e pgs.Extension) {
m.msg.AddExtension(e)
}
// AddEnum ...
func (m *Message) AddEnum(e pgs.Enum) {
m.msg.AddEnum(e)
}
// AddMessage ...
func (m *Message) AddMessage(msg pgs.Message) {
m.msg.AddMessage(msg)
}
// AddOneOf ...
func (m *Message) AddOneOf(o pgs.OneOf) {
m.msg.AddOneOf(o)
}
// AddMapEntry ...
func (m *Message) AddMapEntry(msg pgs.Message) {
m.msg.AddMapEntry(msg)
}
// AddDependent ...
func (m *Message) AddDependent(msg pgs.Message) {
m.msg.AddDependent(msg)
}
// ChildAtPath ...
func (m *Message) ChildAtPath(path []int32) pgs.Entity {
return m.msg.ChildAtPath(path)
}
// AddSourceCodeInfo ...
func (m *Message) AddSourceCodeInfo(info pgs.SourceCodeInfo) {
m.msg.AddSourceCodeInfo(info)
}
// AllEnums returns all top-level and nested enums from this entity.
func (m *Message) AllEnums() []pgs.Enum {
return m.msg.AllEnums()
}
// AllMessages returns all the top-level and nested messages from this Entity.
func (m *Message) AllMessages() []pgs.Message {
return m.msg.AllMessages()
}
// Imports includes external files directly required by this entity. Call
// TransitiveImports on File to get all transitive dependencies.
func (m *Message) Imports() (i []pgs.File) {
return m.msg.Imports()
}
// DefinedExtensions returns all Extensions defined on this entity.
func (m *Message) DefinedExtensions() []pgs.Extension {
return m.msg.DefinedExtensions()
}
// Extension extracts an extension from the entity's options, described by
// desc and populates the value ext. Ext must be a pointer type. An error
// will only be returned if there is a type mismatch between desc and ext.
// The ok value will be true if the extension was found. If the extension
// is NOT found, ok will be false and err will be nil.
func (m *Message) Extension(desc *proto.ExtensionDesc, ext interface{}) (bool, error) {
return m.msg.Extension(desc, ext)
}
var _ pgs.Message = (*Message)(nil)
package genproto
import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
pgs "github.com/lyft/protoc-gen-star"
)
var _ pgs.OneOf = (*OneOf)(nil)
// OneOf describes a OneOf block within a Message. OneOfs behave like C++
// unions, where only one of the contained fields will exist on the Message
type OneOf struct {
oneof pgs.OneOf
}
// Descriptor returns the underlying proto descriptor for this OneOf
func (o *OneOf) Descriptor() *descriptor.OneofDescriptorProto {
return o.oneof.Descriptor()
}
// Message returns the parent message for this OneOf.
func (o *OneOf) Message() pgs.Message {
return o.oneof.Message()
}
// Fields returns all fields contained within this OneOf.
func (o *OneOf) Fields() []pgs.Field {
return o.oneof.Fields()
}
// SetMessage ...
func (o *OneOf) SetMessage(m pgs.Message) {
o.oneof.SetMessage(m)
}
// AddField ...
func (o *OneOf) AddField(f pgs.Field) {
o.oneof.AddField(f)
}
// Name of the entity
func (o *OneOf) Name() pgs.Name {
return o.oneof.Name()
}
// FullyQualifiedName is the fully qualified name of the entity.
// For example, a message 'HelloRequest' in a 'helloworld' package
// takes the form of '.helloworld.HelloRequest'.
func (o *OneOf) FullyQualifiedName() string {
return o.oneof.FullyQualifiedName()
}
// Syntax identifies whether this entity is encoded with proto2 or proto3
// syntax.
func (o *OneOf) Syntax() pgs.Syntax {
return o.oneof.Syntax()
}
// Package returns the container package for this entity.
func (o *OneOf) Package() pgs.Package {
return o.oneof.Package()
}
// Imports includes external files directly required by this entity. Call
// TransitiveImports on File to get all transitive dependencies.
func (o *OneOf) Imports() []pgs.File {
return o.oneof.Imports()
}
// File returns the File containing this entity.
func (o *OneOf) File() pgs.File {
return o.oneof.File()
}
// Extension extracts an extension from the entity's options, described by
// desc and populates the value ext. Ext must be a pointer type. An error
// will only be returned if there is a type mismatch between desc and ext.
// The ok value will be true if the extension was found. If the extension
// is NOT found, ok will be false and err will be nil.
func (o *OneOf) Extension(desc *proto.ExtensionDesc, ext interface{}) (ok bool, err error) {
return o.oneof.Extension(desc, ext)
}
// BuildTarget identifies whether or not generation should be performed on
// this entity. Use this flag to determine if the file was targeted in the
// protoc run or if it was loaded as an external dependency.
func (o *OneOf) BuildTarget() bool {
return o.oneof.BuildTarget()
}
// SourceCodeInfo returns the SourceCodeInfo associated with the entity.
// Primarily, this struct contains the comments associated with the Entity.
func (o *OneOf) SourceCodeInfo() pgs.SourceCodeInfo {
return o.oneof.SourceCodeInfo()
}
// ChildAtPath ...
func (o *OneOf) ChildAtPath(path []int32) pgs.Entity {
return o.oneof.ChildAtPath(path)
}
// AddSourceCodeInfo ...
func (o *OneOf) AddSourceCodeInfo(info pgs.SourceCodeInfo) {
o.oneof.AddSourceCodeInfo(info)
}
// Accept ...
func (o *OneOf) Accept(v pgs.Visitor) error {
return o.oneof.Accept(v)
}
var _ pgs.OneOf = (*OneOf)(nil)
package genproto
import pgs "github.com/lyft/protoc-gen-star"
//Package is a container that encapsulates all the files under a single package namespace.
type Package struct {
pkg pgs.Package
}
var _ pgs.Package = (*Package)(nil)
// ProtoName is the name of the proto package.
func (p *Package) ProtoName() pgs.Name {
return p.pkg.ProtoName()
}
// Files is all the files loaded for this Package
func (p *Package) Files() []pgs.File {
return p.pkg.Files()
}
// Accept ...
func (p *Package) Accept(v pgs.Visitor) (err error) {
return p.pkg.Accept(v)
}
// AddFile ...
func (p *Package) AddFile(f pgs.File) {
p.pkg.AddFile(f)
}
// SetComments ...
func (p *Package) SetComments(comments string) {
p.pkg.SetComments(comments)
}
var _ pgs.Package = (*Package)(nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment