data

package
v0.1.4-0...-0a7b149 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2019 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comments

type Comments struct {
	Leading         string
	Trailing        string
	LeadingDetached []string
}

Comments describe code comments

func (*Comments) String

func (c *Comments) String() string

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data is type assigned to "dot" when evaluating templates

func New

func New(req *plugin.CodeGeneratorRequest) *Data

New returns a new Data describing the code generator request

func (*Data) EnumValues

func (d *Data) EnumValues() EnumValueSlice

EnumValues returns a slice of defined enum values

func (*Data) Enums

func (d *Data) Enums() EnumSlice

Enums returns a slice of defined enums

func (*Data) Fields

func (d *Data) Fields() FieldSlice

Fields returns a slice of defined fields

func (*Data) Files

func (d *Data) Files() FileSlice

Files returns a slice of defined files

func (*Data) Messages

func (d *Data) Messages() MessageSlice

Messages returns a slice of defined messages

func (*Data) Methods

func (d *Data) Methods() MethodSlice

Methods returns a slice of defined methods

func (*Data) Oneofs

func (d *Data) Oneofs() OneofSlice

Oneofs returns a slice of defined oneofs

func (*Data) PackagesToGenerate

func (d *Data) PackagesToGenerate() []string

PackagesToGenerate returns a slice containing all package names used in files to generate

func (*Data) Services

func (d *Data) Services() ServiceSlice

Services returns a slice of defined services

type Enum

type Enum struct {
	Name     string
	Meta     meta.EnumMetadata      // Custom metadata extensions defined for protoc-gen-template
	Options  descriptor.EnumOptions // Globally-defined enum metadata
	Comments Comments
	// contains filtered or unexported fields
}

Enum describes a protobuf enum

func (Enum) File

func (e Enum) File() File

File returns the containing file

func (Enum) IsDeprecated

func (e Enum) IsDeprecated() bool

IsDeprecated returns true if the enumeration's file or any enclosing messages are deprecated, or if its deprecation option is true

func (Enum) IsNested

func (e Enum) IsNested() bool

IsNested returns true if the enum is embedded in a message

func (Enum) IsVisible

func (e Enum) IsVisible() bool

IsVisible returns true if the enumeration's file and any enclosing messages are visibile and its visibility metadata is `PUBLIC`

func (Enum) Parent

func (e Enum) Parent() *Message

Parent returns the enum's parent when embedded in a message, else nil

func (Enum) String

func (e Enum) String() string

func (Enum) Values

func (e Enum) Values() EnumValueSlice

Values returns a slice of the enum's values

type EnumSlice

type EnumSlice []Enum

EnumSlice is a slice of enums

func (EnumSlice) NotDeprecated

func (s EnumSlice) NotDeprecated() EnumSlice

NotDeprecated returns the non-deprecated values in the slice

func (EnumSlice) NotNested

func (s EnumSlice) NotNested() EnumSlice

NotNested returns the non-nested values in the slice

func (EnumSlice) ToGenerate

func (s EnumSlice) ToGenerate() EnumSlice

ToGenerate returns the values in the slice defined in files to be generated

func (EnumSlice) Visible

func (s EnumSlice) Visible() EnumSlice

Visible returns the visible values in the slice

type EnumValue

type EnumValue struct {
	Name     string
	Meta     meta.EnumValueMetadata      // Custom metadata extensions defined for protoc-gen-template
	Options  descriptor.EnumValueOptions // Globally-defined enum value metadata
	Comments Comments
	Number   int32
	// contains filtered or unexported fields
}

EnumValue describes a protobuf enum value

func (EnumValue) IsDeprecated

func (e EnumValue) IsDeprecated() bool

IsDeprecated returns true if the enumeration value's parent is deprecated or its deprecation option is true

func (EnumValue) IsVisible

func (e EnumValue) IsVisible() bool

IsVisible returns true if the enumeration value's parent is visible and its visibility metadata is `PUBLIC`

func (EnumValue) Parent

func (e EnumValue) Parent() Enum

Parent returns the enum for which this is a value

func (EnumValue) String

func (e EnumValue) String() string

type EnumValueSlice

type EnumValueSlice []EnumValue

EnumValueSlice is a slice of enum values

func (EnumValueSlice) NotDeprecated

func (s EnumValueSlice) NotDeprecated() EnumValueSlice

NotDeprecated returns the non-deprecated values in the slice

func (EnumValueSlice) Visible

func (s EnumValueSlice) Visible() EnumValueSlice

Visible returns the visible values in the slice

type Field

type Field struct {
	Name     string
	Meta     meta.FieldMetadata      // Custom metadata extensions defined for protoc-gen-template
	Options  descriptor.FieldOptions // Globally-defined field metadata
	Comments Comments
	Number   int32
	Label    descriptor.FieldDescriptorProto_Label
	Type     descriptor.FieldDescriptorProto_Type
	// For numeric types, contains the original text representation of the value.
	// For booleans, "true" or "false".
	// For strings, contains the default text contents (not escaped in any way).
	// For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
	// TODO(kenton):  Base-64 encode?
	DefaultValue string
	// JSON name of this field. The value is set by protocol compiler. If the
	// user has set a "json_name" option on this field, that option's value
	// will be used. Otherwise, it's deduced from the field's name by converting
	// it to camelCase.
	JSONName string
	// contains filtered or unexported fields
}

Field describes a protobuf message field

func (Field) IsDeprecated

func (f Field) IsDeprecated() bool

IsDeprecated returns true if the field's parent or type are deprecated or if its deprecation option is true

func (Field) IsOneof

func (f Field) IsOneof() bool

IsOneof returns true if the field is part of a oneof

func (Field) IsRepeated

func (f Field) IsRepeated() bool

IsRepeated is true if the field's label is 'REPEATED'

func (Field) IsTypeBool

func (f Field) IsTypeBool() bool

IsTypeBool is true if the field's type is 'bool'

func (Field) IsTypeBytes

func (f Field) IsTypeBytes() bool

IsTypeBytes is true if the field's type is 'bytes'

func (Field) IsTypeDouble

func (f Field) IsTypeDouble() bool

IsTypeDouble is true if the field's type is 'double'

func (Field) IsTypeEnum

func (f Field) IsTypeEnum() bool

IsTypeEnum is true if the field's type is an enum

func (Field) IsTypeFixed32

func (f Field) IsTypeFixed32() bool

IsTypeFixed32 is true if the field's type is 'fixed32'

func (Field) IsTypeFixed64

func (f Field) IsTypeFixed64() bool

IsTypeFixed64 is true if the field's type is 'fixed64'

func (Field) IsTypeFloat

func (f Field) IsTypeFloat() bool

IsTypeFloat is true if the field's type is 'float'

func (Field) IsTypeGroup

func (f Field) IsTypeGroup() bool

IsTypeGroup is true if the field's type is 'group'

func (Field) IsTypeInt32

func (f Field) IsTypeInt32() bool

IsTypeInt32 is true if the field's type is 'int32'

func (Field) IsTypeInt64

func (f Field) IsTypeInt64() bool

IsTypeInt64 is true if the field's type is 'int64'

func (Field) IsTypeMessage

func (f Field) IsTypeMessage() bool

IsTypeMessage is true if the field's type is a message

func (Field) IsTypeSfixed32

func (f Field) IsTypeSfixed32() bool

IsTypeSfixed32 is true if the field's type is 'sfixed32'

func (Field) IsTypeSfixed64

func (f Field) IsTypeSfixed64() bool

IsTypeSfixed64 is true if the field's type is 'sfixed64'

func (Field) IsTypeSint32

func (f Field) IsTypeSint32() bool

IsTypeSint32 is true if the field's type is 'sint32'

func (Field) IsTypeSint64

func (f Field) IsTypeSint64() bool

IsTypeSint64 is true if the field's type is 'sint64'

func (Field) IsTypeString

func (f Field) IsTypeString() bool

IsTypeString is true if the field's type is 'string'

func (Field) IsTypeUint32

func (f Field) IsTypeUint32() bool

IsTypeUint32 is true if the field's type is 'uint32'

func (Field) IsTypeUint64

func (f Field) IsTypeUint64() bool

IsTypeUint64 is true if the field's type is 'uint64'

func (Field) IsVisible

func (f Field) IsVisible() bool

IsVisible returns true if the field's parent and type is visible and its visibility metadata `PUBLIC`

func (Field) Oneof

func (f Field) Oneof() *Oneof

Oneof returns the oneof this field is a member of, else nil

func (Field) Parent

func (f Field) Parent() Message

Parent returns the fields's parent message

func (Field) String

func (f Field) String() string

func (Field) TypeEnum

func (f Field) TypeEnum() *Enum

TypeEnum returns the enum type if the field is enum-typed

func (Field) TypeMessage

func (f Field) TypeMessage() *Message

TypeMessage returns the message type if the field is message-typed, else nil

func (Field) TypeNameString

func (f Field) TypeNameString() string

TypeNameString returns a prettified string descripton of a field's type

Examples:

{Type: "TYPE_STRING", TypeName: nil, Label: OPTIONAL}			-> "string"
{Type: "TYPE_STRING", TypeName: nil, Label: REQUIRED}			-> "string"
{Type: "TYPE_STRING", TypeName: nil, Label: REPEATED}			-> "[]string"
{Type: "TYPE_BYTES", TypeName: nil, Label: REPEATED}			-> "bytes"
{Type: "TYPE_MESSAGE", TypeName: ".pkg.Msg, Label: OPTIONAL}	-> "pkg.Msg"
{Type: "TYPE_ENUM", TypeName: ".pkg.Enm, Label: OPTIONAL}		-> "pkg.Enm"

type FieldSlice

type FieldSlice []Field

FieldSlice is a slice of fields

func (FieldSlice) NotDeprecated

func (s FieldSlice) NotDeprecated() FieldSlice

NotDeprecated returns the non-deprecated values in the slice

func (FieldSlice) Visible

func (s FieldSlice) Visible() FieldSlice

Visible returns the visible values in the slice

type File

type File struct {
	Package      string
	Name         string
	Comments     Comments
	Meta         meta.FileMetadata      // Custom metadata extensions defined for protoc-gen-template
	Options      descriptor.FileOptions // Globally-defined file metadata
	Generate     bool                   // Generate is true if the file is included in FileToGenerate
	Dependencies []string               // Dependencies lists the names of files imported by this file.
	Syntax       string                 // Syntax is of the proto file - proto2/proto3
	// contains filtered or unexported fields
}

File describes a protobuf source file

func (File) Enums

func (f File) Enums() EnumSlice

Enums returns a slice of the file's enums

func (File) GoPackageImport

func (f File) GoPackageImport() string

GoPackageImport returns the go import path for the file's package

  1. If the file's GoPackage option is set and contains the `;` character, returns any content before the character
  2. If the file's GoPackage options is set and doesn't contain the `;` character, returns the GoPackage value
  3. Returns the directory portion of the file's Name value
  4. Returns the file's Name value

func (File) GoPackageName

func (f File) GoPackageName() string

GoPackageName returns a package name for importing the file:

  1. If the file's GoPackage option is set and contains the `;` character, returns any content after the character
  2. If the file's GoPackage options is set and doesn't contain the `;` character, returns the basename portion of the GoPackage value
  3. Returns the basename portion of file's Name value

func (File) IsDeprecated

func (f File) IsDeprecated() bool

IsDeprecated returns true if the file's deprecation option is true

func (File) IsVisible

func (f File) IsVisible() bool

IsVisible returns true if the visibility metadata of the file is `PUBLIC`

func (File) Messages

func (f File) Messages() MessageSlice

Messages returns a slice of the file's messages

func (File) Services

func (f File) Services() ServiceSlice

Services returns a slice of the file's services

func (File) String

func (f File) String() string

type FileSlice

type FileSlice []File

FileSlice is a slice of files

func (FileSlice) NotDeprecated

func (s FileSlice) NotDeprecated() FileSlice

NotDeprecated returns the non-deprecated values in the slice

func (FileSlice) ToGenerate

func (s FileSlice) ToGenerate() FileSlice

ToGenerate returns the values in the slice to be generated

func (FileSlice) Visible

func (s FileSlice) Visible() FileSlice

Visible returns the visible values in the slice

type Message

type Message struct {
	Name          string
	Meta          meta.MessageMetadata      // Custom metadata extensions defined for protoc-gen-template
	Options       descriptor.MessageOptions // Globally-defined message metadata
	Comments      Comments
	ReservedTags  []descriptor.DescriptorProto_ReservedRange
	ReservedNames []string // Reserved field names, which may not be used by fields in the same message.
	// contains filtered or unexported fields
}

Message describes a protobuf message definition

func (Message) Enums

func (m Message) Enums() EnumSlice

Enums returns a slice of the message's enums

func (Message) Fields

func (m Message) Fields() FieldSlice

Fields returns a slice of the message's fields

func (Message) File

func (m Message) File() File

File returns the containing file

func (Message) IsDeprecated

func (m Message) IsDeprecated() bool

IsDeprecated returns true if the message's file or any enclosing messages are deprecated, or if its deprecation option is true

func (Message) IsNested

func (m Message) IsNested() bool

IsNested returns true if the message is embedded in another message

func (Message) IsVisible

func (m Message) IsVisible() bool

IsVisible returns true if the message's file and any enclosing message are visible, and its visibility metadata is `PUBLIC`

func (Message) Messages

func (m Message) Messages() MessageSlice

Messages returns a slice of nested messages

func (Message) Oneofs

func (m Message) Oneofs() OneofSlice

Oneofs returns a slice of the message's oneofs

func (Message) Parent

func (m Message) Parent() *Message

Parent returns the messages's parent when embedded in a message, else nil

func (Message) Root

func (m Message) Root() Message

Root returns the outermost ancestor of the message

func (Message) String

func (m Message) String() string

type MessageSlice

type MessageSlice []Message

MessageSlice is a slice of messages

func (MessageSlice) NotDeprecated

func (s MessageSlice) NotDeprecated() MessageSlice

NotDeprecated returns the non-deprecated values in the slice

func (MessageSlice) NotNested

func (s MessageSlice) NotNested() MessageSlice

NotNested returns the non-nested values in the slice

func (MessageSlice) ToGenerate

func (s MessageSlice) ToGenerate() MessageSlice

ToGenerate returns the values in the slice defined in files to be generated

func (MessageSlice) Visible

func (s MessageSlice) Visible() MessageSlice

Visible returns the visible values in the slice

type Method

type Method struct {
	Name            string
	Meta            meta.MethodMetadata      // Custom metadata extensions defined for protoc-gen-template
	Options         descriptor.MethodOptions // Globally-defined service metadata
	Comments        Comments
	ClientStreaming bool
	ServerStreaming bool
	// contains filtered or unexported fields
}

Method describes a protobuf service method

func (Method) InputType

func (m Method) InputType() Message

InputType returns the method's input type

func (Method) IsDeprecated

func (m Method) IsDeprecated() bool

IsDeprecated returns true if the method's service or any of its input/output messages are deprecated, or its deprecation option is true

func (Method) IsVisible

func (m Method) IsVisible() bool

IsVisible returns true if the method's service and its input/output messages are visible, and its visibility metadata is `PUBLIC`

func (Method) OutputType

func (m Method) OutputType() Message

OutputType returns the method's output type

func (Method) Parent

func (m Method) Parent() Service

Parent returns the method's parent service

func (Method) String

func (m Method) String() string

type MethodSlice

type MethodSlice []Method

MethodSlice is a slice of methods

func (MethodSlice) NotDeprecated

func (s MethodSlice) NotDeprecated() MethodSlice

NotDeprecated returns the non-deprecated values in the slice

func (MethodSlice) Visible

func (s MethodSlice) Visible() MethodSlice

Visible returns the visible values in the slice

type Oneof

type Oneof struct {
	Name     string
	Options  descriptor.OneofOptions // Globally-defined message metadata
	Comments Comments
	// contains filtered or unexported fields
}

Oneof describes a protobuf message definition

func (Oneof) Fields

func (o Oneof) Fields() FieldSlice

Fields returns a slice of the oneof's fields

func (Oneof) IsDeprecated

func (o Oneof) IsDeprecated() bool

IsDeprecated returns true if the oneof's parent message is deprecated

func (Oneof) IsVisible

func (o Oneof) IsVisible() bool

IsVisible returns true if the oneof's parent message is visible

func (Oneof) Parent

func (o Oneof) Parent() Message

Parent returns the method's parent service

func (Oneof) String

func (o Oneof) String() string

type OneofSlice

type OneofSlice []Oneof

OneofSlice is a slice of oneofs

func (OneofSlice) NotDeprecated

func (s OneofSlice) NotDeprecated() OneofSlice

NotDeprecated returns the non-deprecated values in the slice

func (OneofSlice) Visible

func (s OneofSlice) Visible() OneofSlice

Visible returns the visible values in the slice

type Service

type Service struct {
	Name     string
	Meta     meta.ServiceMetadata      // Custom metadata extensions defined for protoc-gen-template
	Options  descriptor.ServiceOptions // Globally-defined service metadata
	Comments Comments
	// contains filtered or unexported fields
}

Service describes a protobuf service

func (Service) File

func (s Service) File() File

File returns the containing file

func (Service) IsDeprecated

func (s Service) IsDeprecated() bool

IsDeprecated returns true if the service's file is deprecated or its deprecation option is true

func (Service) IsVisible

func (s Service) IsVisible() bool

IsVisible returns true if the service's file is visible and its visibility metadata is `PUBLIC`

func (Service) Methods

func (s Service) Methods() MethodSlice

Methods returns a slice of the service's methods

func (Service) String

func (s Service) String() string

type ServiceSlice

type ServiceSlice []Service

ServiceSlice is a slice of services

func (ServiceSlice) NotDeprecated

func (s ServiceSlice) NotDeprecated() ServiceSlice

NotDeprecated returns the non-deprecated values in the slice

func (ServiceSlice) ToGenerate

func (s ServiceSlice) ToGenerate() ServiceSlice

ToGenerate returns the values in the slice defined in files to be generated

func (ServiceSlice) Visible

func (s ServiceSlice) Visible() ServiceSlice

Visible returns the visible values in the slice

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL