descriptor

package
v0.0.0-...-fe632b3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SyntaxPath is location path number for syntax statement
	SyntaxPath = "12" // syntax
	// PackagePath is location path number for package statement
	PackagePath = "2" // syntax
	// MessagePath is location path number for message statement
	MessagePath = "4" // message_type
	// EnumPath is location path number for enum statement
	EnumPath = "5" // enum_type
	// MessageFieldPath is location path number for message field statement
	MessageFieldPath = "2" // field
	// MessageMessagePath is location path number for sub-message statement
	MessageMessagePath = "3" // nested_type
	// MessageEnumPath is location path number for sub-enum statement
	MessageEnumPath = "4" // enum_type
)

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(s string) string

CamelCase converts the string into camel case string

func GetPathForField

func GetPathForField(desc *Descriptor, index int) string

GetPathForField returns the path associated with the field

func GoPackageName

func GoPackageName(pkg string) string

GoPackageName converts proto package name into go package name.

Types

type Descriptor

type Descriptor struct {
	*descriptor.DescriptorProto

	Path string // The SourceCodeInfo path as comma-separated integers.
	// contains filtered or unexported fields
}

Descriptor wraps a DescriptorProto.

func (*Descriptor) File

func (c *Descriptor) File() *descriptor.FileDescriptorProto

func (*Descriptor) PackageName

func (c *Descriptor) PackageName() string

PackageName returns the Go package name for the file the common object belongs to.

func (*Descriptor) TypeName

func (d *Descriptor) TypeName() []string

TypeName returns a cached typename vector.

type EnumDescriptor

type EnumDescriptor struct {
	*descriptor.EnumDescriptorProto
	// contains filtered or unexported fields
}

EnumDescriptor wraps a EnumDescriptorProto.

func (*EnumDescriptor) File

func (c *EnumDescriptor) File() *descriptor.FileDescriptorProto

func (*EnumDescriptor) PackageName

func (c *EnumDescriptor) PackageName() string

PackageName returns the Go package name for the file the common object belongs to.

func (*EnumDescriptor) TypeName

func (e *EnumDescriptor) TypeName() (s []string)

TypeName returns a cached typename vector.

type FileDescriptor

type FileDescriptor struct {
	*descriptor.FileDescriptorProto
	Desc []*Descriptor // All the messages defined in this file.

	Proto3 bool // whether to generate proto3 code for this file
	// contains filtered or unexported fields
}

FileDescriptor wraps a FileDescriptorProto.

func (*FileDescriptor) GetComment

func (d *FileDescriptor) GetComment(path string) string

GetComment returns the comment associated with the element at a given path.

func (*FileDescriptor) GetLineNumber

func (d *FileDescriptor) GetLineNumber(path string) string

GetLineNumber returns line number for the path.

type FileDescriptorSetParser

type FileDescriptorSetParser struct {
	Param             map[string]string // Command-line parameters.
	PackageImportPath string            // Go import path of the package we're generating code for
	ImportMap         map[string]string // Mapping from .proto file name to import path

	Pkg map[string]string // The names under which we import support packages

	PackageName string            // What we're calling ourselves.
	AllFiles    []*FileDescriptor // All files in the tree
	// contains filtered or unexported fields
}

FileDescriptorSetParser parses the FileDescriptorSetProto and creates an intermediate object that is used to create Model struct.

func CreateFileDescriptorSetParser

func CreateFileDescriptorSetParser(fds *descriptor.FileDescriptorSet, importMap map[string]string, packageImportPath string) *FileDescriptorSetParser

CreateFileDescriptorSetParser builds a FileDescriptorSetParser instance.

func (*FileDescriptorSetParser) BuildTypeNameMap

func (g *FileDescriptorSetParser) BuildTypeNameMap()

BuildTypeNameMap creates a map of type name to the wrapper Object associated with it.

func (*FileDescriptorSetParser) DefaultPackageName

func (g *FileDescriptorSetParser) DefaultPackageName(obj Object) string

DefaultPackageName returns a full packagen name for the underlying Object type.

func (*FileDescriptorSetParser) Enums

Enums return a complete list of enums in the file descriptor set

func (*FileDescriptorSetParser) Messages

Messages return a complete list of messages in the file descriptor set

func (*FileDescriptorSetParser) ObjectNamed

func (g *FileDescriptorSetParser) ObjectNamed(typeName string) Object

ObjectNamed returns the descriptor for the message or enum with that name.

func (*FileDescriptorSetParser) TypeName

func (g *FileDescriptorSetParser) TypeName(obj Object) string

TypeName returns a full name for the underlying Object type.

func (*FileDescriptorSetParser) WrapTypes

WrapTypes creates wrapper types for messages, enumse and file inside the FileDescriptorSet.

type Object

type Object interface {
	PackageName() string // The name we use in our output (a_b_c), possibly renamed for uniqueness.
	TypeName() []string
	File() *descriptor.FileDescriptorProto
}

Object is a shared interface implemented by EnumDescriptor and Descriptor

Jump to

Keyboard shortcuts

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