proto

package
v0.0.0-...-d08e724 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurlyLeftBracket   lexer.TokenType = iota // {
	CurlyRightBracket                         // }
	SquareLeftBracket                         // [
	SquareRightBracket                        // ]
	SemiColon                                 // ;
	Colon                                     // :
	Ident
	StringValue
	Value
)

Variables

This section is empty.

Functions

func ParseOption

func ParseOption(value string, t *Type) interface{}

func ReadArrayEnd

func ReadArrayEnd(l *lexer.L) lexer.StateFunc

func ReadArrayStart

func ReadArrayStart(l *lexer.L) lexer.StateFunc

func ReadColon

func ReadColon(l *lexer.L) lexer.StateFunc

func ReadIdentifier

func ReadIdentifier(l *lexer.L) lexer.StateFunc

func ReadMessageEnd

func ReadMessageEnd(l *lexer.L) lexer.StateFunc

func ReadMessageStart

func ReadMessageStart(l *lexer.L) lexer.StateFunc

func ReadValue

func ReadValue(l *lexer.L) lexer.StateFunc

func ReadValueEnd

func ReadValueEnd(l *lexer.L) lexer.StateFunc

func TokenToString

func TokenToString(token lexer.TokenType) string

Types

type Context

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

Context captures the global parsing state of the files

func NewContext

func NewContext() *Context

func (*Context) AcceptProtoFile

func (c *Context) AcceptProtoFile(pkgName string, proto *parser.Proto)

func (*Context) GlobalScope

func (c *Context) GlobalScope() *Package

func (*Context) Package

func (c *Context) Package(name string) *Package

func (*Context) Packages

func (c *Context) Packages() []*Package

type Element

type Element interface {
	Name() string
	GetElementType() ElementType
}

type ElementType

type ElementType int
const (
	UnknownElementType ElementType = iota
	PackageElementType
	EnumElementType
	MessageElementType
	FieldElementType
	ServiceElementType
	RPCElementType
)

type Enum

type Enum struct {
	*Options
	// contains filtered or unexported fields
}

func NewEnum

func NewEnum(types *TypeDictionary) *Enum

func (*Enum) GetElementType

func (e *Enum) GetElementType() ElementType

func (*Enum) Name

func (e *Enum) Name() string

func (*Enum) Values

func (e *Enum) Values() []*EnumValue

func (Enum) VisitComment

func (n Enum) VisitComment(comment *parser.Comment)

func (Enum) VisitEmptyStatement

func (n Enum) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (*Enum) VisitEnum

func (e *Enum) VisitEnum(enum *parser.Enum) (next bool)

func (*Enum) VisitEnumField

func (e *Enum) VisitEnumField(field *parser.EnumField) (next bool)

func (Enum) VisitExtend

func (n Enum) VisitExtend(extend *parser.Extend) (next bool)

func (Enum) VisitExtensions

func (n Enum) VisitExtensions(extensions *parser.Extensions) (next bool)

func (Enum) VisitField

func (n Enum) VisitField(field *parser.Field) (next bool)

func (Enum) VisitGroupField

func (n Enum) VisitGroupField(field *parser.GroupField) (next bool)

func (Enum) VisitImport

func (n Enum) VisitImport(i *parser.Import) (next bool)

func (Enum) VisitMapField

func (n Enum) VisitMapField(field *parser.MapField) (next bool)

func (Enum) VisitMessage

func (n Enum) VisitMessage(message *parser.Message) (next bool)

func (Enum) VisitOneof

func (n Enum) VisitOneof(oneof *parser.Oneof) (next bool)

func (Enum) VisitOneofField

func (n Enum) VisitOneofField(field *parser.OneofField) (next bool)

func (*Enum) VisitOption

func (e *Enum) VisitOption(option *parser.Option) (next bool)

func (Enum) VisitPackage

func (n Enum) VisitPackage(p *parser.Package) (next bool)

func (Enum) VisitRPC

func (n Enum) VisitRPC(rpc *parser.RPC) (next bool)

func (Enum) VisitReserved

func (n Enum) VisitReserved(reserved *parser.Reserved) (next bool)

func (Enum) VisitService

func (n Enum) VisitService(service *parser.Service) (next bool)

func (Enum) VisitSyntax

func (n Enum) VisitSyntax(syntax *parser.Syntax) (next bool)

type EnumValue

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

func (*EnumValue) Identifier

func (e *EnumValue) Identifier() string

func (*EnumValue) Number

func (e *EnumValue) Number() string

type ExtensionType

type ExtensionType int
const (
	UnknownExtension ExtensionType = iota
	FileExtension
	MessageExtension
	FieldExtension
	OneOfExtension
	EnumExtension
	EnumValueExtension
	ServiceExtension
	MethodExtension
)

type Field

type Field struct {
	*Options
	// contains filtered or unexported fields
}

func NewField

func NewField(types *TypeDictionary) *Field

func (*Field) FieldNumber

func (f *Field) FieldNumber() string

func (*Field) GetElementType

func (f *Field) GetElementType() ElementType

func (*Field) IsRepeated

func (f *Field) IsRepeated() bool

func (*Field) Name

func (f *Field) Name() string

func (*Field) Type

func (f *Field) Type() *Type

func (Field) VisitComment

func (n Field) VisitComment(comment *parser.Comment)

func (Field) VisitEmptyStatement

func (n Field) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (Field) VisitEnum

func (n Field) VisitEnum(enum *parser.Enum) (next bool)

func (Field) VisitEnumField

func (n Field) VisitEnumField(field *parser.EnumField) (next bool)

func (Field) VisitExtend

func (n Field) VisitExtend(extend *parser.Extend) (next bool)

func (Field) VisitExtensions

func (n Field) VisitExtensions(extensions *parser.Extensions) (next bool)

func (*Field) VisitField

func (f *Field) VisitField(field *parser.Field) (next bool)

func (Field) VisitGroupField

func (n Field) VisitGroupField(field *parser.GroupField) (next bool)

func (Field) VisitImport

func (n Field) VisitImport(i *parser.Import) (next bool)

func (Field) VisitMapField

func (n Field) VisitMapField(field *parser.MapField) (next bool)

func (Field) VisitMessage

func (n Field) VisitMessage(message *parser.Message) (next bool)

func (Field) VisitOneof

func (n Field) VisitOneof(oneof *parser.Oneof) (next bool)

func (Field) VisitOneofField

func (n Field) VisitOneofField(field *parser.OneofField) (next bool)

func (*Field) VisitOption

func (f *Field) VisitOption(option *parser.Option) (next bool)

func (Field) VisitPackage

func (n Field) VisitPackage(p *parser.Package) (next bool)

func (Field) VisitRPC

func (n Field) VisitRPC(rpc *parser.RPC) (next bool)

func (Field) VisitReserved

func (n Field) VisitReserved(reserved *parser.Reserved) (next bool)

func (Field) VisitService

func (n Field) VisitService(service *parser.Service) (next bool)

func (Field) VisitSyntax

func (n Field) VisitSyntax(syntax *parser.Syntax) (next bool)

type Message

type Message struct {
	*Options
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(types *TypeDictionary) *Message

func (*Message) Enum

func (m *Message) Enum(name string) *Enum

func (*Message) Enums

func (m *Message) Enums() []*Enum

func (*Message) Field

func (m *Message) Field(name string) *Field

func (*Message) Fields

func (m *Message) Fields() []*Field

func (*Message) GetElementType

func (m *Message) GetElementType() ElementType

func (*Message) IsOneOf

func (m *Message) IsOneOf() bool

func (*Message) Message

func (m *Message) Message(name string) *Message

func (*Message) Messages

func (m *Message) Messages() []*Message

func (*Message) Name

func (m *Message) Name() string

func (*Message) Type

func (m *Message) Type() *Type

func (Message) VisitComment

func (n Message) VisitComment(comment *parser.Comment)

func (Message) VisitEmptyStatement

func (n Message) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (*Message) VisitEnum

func (m *Message) VisitEnum(enum *parser.Enum) (next bool)

func (Message) VisitEnumField

func (n Message) VisitEnumField(field *parser.EnumField) (next bool)

func (Message) VisitExtend

func (n Message) VisitExtend(extend *parser.Extend) (next bool)

func (Message) VisitExtensions

func (n Message) VisitExtensions(extensions *parser.Extensions) (next bool)

func (*Message) VisitField

func (m *Message) VisitField(field *parser.Field) (next bool)

func (Message) VisitGroupField

func (n Message) VisitGroupField(field *parser.GroupField) (next bool)

func (Message) VisitImport

func (n Message) VisitImport(i *parser.Import) (next bool)

func (Message) VisitMapField

func (n Message) VisitMapField(field *parser.MapField) (next bool)

func (*Message) VisitMessage

func (m *Message) VisitMessage(message *parser.Message) (next bool)

func (*Message) VisitOneof

func (m *Message) VisitOneof(oneof *parser.Oneof) (next bool)

func (Message) VisitOneofField

func (n Message) VisitOneofField(field *parser.OneofField) (next bool)

func (*Message) VisitOption

func (m *Message) VisitOption(option *parser.Option) (next bool)

func (Message) VisitPackage

func (n Message) VisitPackage(p *parser.Package) (next bool)

func (Message) VisitRPC

func (n Message) VisitRPC(rpc *parser.RPC) (next bool)

func (Message) VisitReserved

func (n Message) VisitReserved(reserved *parser.Reserved) (next bool)

func (Message) VisitService

func (n Message) VisitService(service *parser.Service) (next bool)

func (Message) VisitSyntax

func (n Message) VisitSyntax(syntax *parser.Syntax) (next bool)

type OneOf

type OneOf struct {
	OneOfName string
	Fields    []*Field
}

func NewOneOf

func NewOneOf(name string) *OneOf

func (*OneOf) AddField

func (o *OneOf) AddField(f *Field)

type Option

type Option struct {
	OptionName  string
	OptionValue string
	// contains filtered or unexported fields
}

func (Option) VisitComment

func (n Option) VisitComment(comment *parser.Comment)

func (Option) VisitEmptyStatement

func (n Option) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (Option) VisitEnum

func (n Option) VisitEnum(enum *parser.Enum) (next bool)

func (Option) VisitEnumField

func (n Option) VisitEnumField(field *parser.EnumField) (next bool)

func (Option) VisitExtend

func (n Option) VisitExtend(extend *parser.Extend) (next bool)

func (Option) VisitExtensions

func (n Option) VisitExtensions(extensions *parser.Extensions) (next bool)

func (Option) VisitField

func (n Option) VisitField(field *parser.Field) (next bool)

func (Option) VisitGroupField

func (n Option) VisitGroupField(field *parser.GroupField) (next bool)

func (Option) VisitImport

func (n Option) VisitImport(i *parser.Import) (next bool)

func (Option) VisitMapField

func (n Option) VisitMapField(field *parser.MapField) (next bool)

func (Option) VisitMessage

func (n Option) VisitMessage(message *parser.Message) (next bool)

func (Option) VisitOneof

func (n Option) VisitOneof(oneof *parser.Oneof) (next bool)

func (Option) VisitOneofField

func (n Option) VisitOneofField(field *parser.OneofField) (next bool)

func (Option) VisitOption

func (n Option) VisitOption(option *parser.Option) (next bool)

func (Option) VisitPackage

func (n Option) VisitPackage(p *parser.Package) (next bool)

func (Option) VisitRPC

func (n Option) VisitRPC(rpc *parser.RPC) (next bool)

func (Option) VisitReserved

func (n Option) VisitReserved(reserved *parser.Reserved) (next bool)

func (Option) VisitService

func (n Option) VisitService(service *parser.Service) (next bool)

func (Option) VisitSyntax

func (n Option) VisitSyntax(syntax *parser.Syntax) (next bool)

type Options

type Options struct {
	Options []*Option
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(parent Element, types *TypeDictionary) *Options

func (*Options) AddOption

func (o *Options) AddOption(name string, value string)

func (*Options) Get

func (o *Options) Get(name string) interface{}

func (*Options) Has

func (o *Options) Has(name string) bool

func (Options) VisitComment

func (n Options) VisitComment(comment *parser.Comment)

func (Options) VisitEmptyStatement

func (n Options) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (Options) VisitEnum

func (n Options) VisitEnum(enum *parser.Enum) (next bool)

func (Options) VisitEnumField

func (n Options) VisitEnumField(field *parser.EnumField) (next bool)

func (Options) VisitExtend

func (n Options) VisitExtend(extend *parser.Extend) (next bool)

func (Options) VisitExtensions

func (n Options) VisitExtensions(extensions *parser.Extensions) (next bool)

func (Options) VisitField

func (n Options) VisitField(field *parser.Field) (next bool)

func (Options) VisitGroupField

func (n Options) VisitGroupField(field *parser.GroupField) (next bool)

func (Options) VisitImport

func (n Options) VisitImport(i *parser.Import) (next bool)

func (Options) VisitMapField

func (n Options) VisitMapField(field *parser.MapField) (next bool)

func (Options) VisitMessage

func (n Options) VisitMessage(message *parser.Message) (next bool)

func (Options) VisitOneof

func (n Options) VisitOneof(oneof *parser.Oneof) (next bool)

func (Options) VisitOneofField

func (n Options) VisitOneofField(field *parser.OneofField) (next bool)

func (*Options) VisitOption

func (o *Options) VisitOption(option *parser.Option) (next bool)

func (Options) VisitPackage

func (n Options) VisitPackage(p *parser.Package) (next bool)

func (Options) VisitRPC

func (n Options) VisitRPC(rpc *parser.RPC) (next bool)

func (Options) VisitReserved

func (n Options) VisitReserved(reserved *parser.Reserved) (next bool)

func (Options) VisitService

func (n Options) VisitService(service *parser.Service) (next bool)

func (Options) VisitSyntax

func (n Options) VisitSyntax(syntax *parser.Syntax) (next bool)

type Package

type Package struct {
	*Options
	// contains filtered or unexported fields
}

func NewPackage

func NewPackage(name string, types *TypeDictionary) *Package

func (*Package) Enum

func (p *Package) Enum(name string) *Enum

func (*Package) Enums

func (p *Package) Enums() []*Enum

func (*Package) Extension

func (p *Package) Extension(extType ExtensionType, pkgName string) []*Message

func (*Package) Extensions

func (p *Package) Extensions() map[ExtensionType]map[string][]*Message

func (*Package) GetElementType

func (p *Package) GetElementType() ElementType

func (*Package) Message

func (p *Package) Message(name string) *Message

func (*Package) Messages

func (p *Package) Messages() []*Message

func (*Package) Name

func (p *Package) Name() string

func (*Package) Service

func (p *Package) Service(s string) *Service

func (*Package) Services

func (p *Package) Services() []*Service

func (Package) VisitComment

func (n Package) VisitComment(comment *parser.Comment)

func (Package) VisitEmptyStatement

func (n Package) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (*Package) VisitEnum

func (p *Package) VisitEnum(enum *parser.Enum) (next bool)

func (Package) VisitEnumField

func (n Package) VisitEnumField(field *parser.EnumField) (next bool)

func (*Package) VisitExtend

func (p *Package) VisitExtend(extend *parser.Extend) (next bool)

func (Package) VisitExtensions

func (n Package) VisitExtensions(extensions *parser.Extensions) (next bool)

func (Package) VisitField

func (n Package) VisitField(field *parser.Field) (next bool)

func (Package) VisitGroupField

func (n Package) VisitGroupField(field *parser.GroupField) (next bool)

func (Package) VisitImport

func (n Package) VisitImport(i *parser.Import) (next bool)

func (Package) VisitMapField

func (n Package) VisitMapField(field *parser.MapField) (next bool)

func (*Package) VisitMessage

func (p *Package) VisitMessage(message *parser.Message) (next bool)

func (Package) VisitOneof

func (n Package) VisitOneof(oneof *parser.Oneof) (next bool)

func (Package) VisitOneofField

func (n Package) VisitOneofField(field *parser.OneofField) (next bool)

func (*Package) VisitOption

func (p *Package) VisitOption(option *parser.Option) (next bool)

func (Package) VisitPackage

func (n Package) VisitPackage(p *parser.Package) (next bool)

func (Package) VisitRPC

func (n Package) VisitRPC(rpc *parser.RPC) (next bool)

func (Package) VisitReserved

func (n Package) VisitReserved(reserved *parser.Reserved) (next bool)

func (*Package) VisitService

func (p *Package) VisitService(service *parser.Service) (next bool)

func (Package) VisitSyntax

func (n Package) VisitSyntax(syntax *parser.Syntax) (next bool)

type Parser

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

func NewParser

func NewParser(files []string, includeDirectors []string) *Parser

func (*Parser) GetContext

func (p *Parser) GetContext() *Context

func (*Parser) Parse

func (p *Parser) Parse() error

type RPC

type RPC struct {
	*Options
	RPCName                  string
	RequestMessageType       *Type
	ResponseMessageType      *Type
	RequestMessageStreaming  bool
	ResponseMessageStreaming bool
	// contains filtered or unexported fields
}

func NewRPC

func NewRPC(types *TypeDictionary) *RPC

func (*RPC) GetElementType

func (r *RPC) GetElementType() ElementType

func (*RPC) Name

func (r *RPC) Name() string

func (RPC) VisitComment

func (n RPC) VisitComment(comment *parser.Comment)

func (RPC) VisitEmptyStatement

func (n RPC) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (RPC) VisitEnum

func (n RPC) VisitEnum(enum *parser.Enum) (next bool)

func (RPC) VisitEnumField

func (n RPC) VisitEnumField(field *parser.EnumField) (next bool)

func (RPC) VisitExtend

func (n RPC) VisitExtend(extend *parser.Extend) (next bool)

func (RPC) VisitExtensions

func (n RPC) VisitExtensions(extensions *parser.Extensions) (next bool)

func (RPC) VisitField

func (n RPC) VisitField(field *parser.Field) (next bool)

func (RPC) VisitGroupField

func (n RPC) VisitGroupField(field *parser.GroupField) (next bool)

func (RPC) VisitImport

func (n RPC) VisitImport(i *parser.Import) (next bool)

func (RPC) VisitMapField

func (n RPC) VisitMapField(field *parser.MapField) (next bool)

func (RPC) VisitMessage

func (n RPC) VisitMessage(message *parser.Message) (next bool)

func (RPC) VisitOneof

func (n RPC) VisitOneof(oneof *parser.Oneof) (next bool)

func (RPC) VisitOneofField

func (n RPC) VisitOneofField(field *parser.OneofField) (next bool)

func (*RPC) VisitOption

func (r *RPC) VisitOption(option *parser.Option) (next bool)

func (RPC) VisitPackage

func (n RPC) VisitPackage(p *parser.Package) (next bool)

func (*RPC) VisitRPC

func (r *RPC) VisitRPC(rpc *parser.RPC) (next bool)

func (RPC) VisitReserved

func (n RPC) VisitReserved(reserved *parser.Reserved) (next bool)

func (RPC) VisitService

func (n RPC) VisitService(service *parser.Service) (next bool)

func (RPC) VisitSyntax

func (n RPC) VisitSyntax(syntax *parser.Syntax) (next bool)

type Service

type Service struct {
	*Options
	// contains filtered or unexported fields
}

func NewService

func NewService(types *TypeDictionary) *Service

func (*Service) GetElementType

func (s *Service) GetElementType() ElementType

func (*Service) Name

func (s *Service) Name() string

func (*Service) RPC

func (s *Service) RPC(name string) *RPC

func (*Service) RPCs

func (s *Service) RPCs() []*RPC

func (Service) VisitComment

func (n Service) VisitComment(comment *parser.Comment)

func (Service) VisitEmptyStatement

func (n Service) VisitEmptyStatement(statement *parser.EmptyStatement) (next bool)

func (Service) VisitEnum

func (n Service) VisitEnum(enum *parser.Enum) (next bool)

func (Service) VisitEnumField

func (n Service) VisitEnumField(field *parser.EnumField) (next bool)

func (Service) VisitExtend

func (n Service) VisitExtend(extend *parser.Extend) (next bool)

func (Service) VisitExtensions

func (n Service) VisitExtensions(extensions *parser.Extensions) (next bool)

func (Service) VisitField

func (n Service) VisitField(field *parser.Field) (next bool)

func (Service) VisitGroupField

func (n Service) VisitGroupField(field *parser.GroupField) (next bool)

func (Service) VisitImport

func (n Service) VisitImport(i *parser.Import) (next bool)

func (Service) VisitMapField

func (n Service) VisitMapField(field *parser.MapField) (next bool)

func (Service) VisitMessage

func (n Service) VisitMessage(message *parser.Message) (next bool)

func (Service) VisitOneof

func (n Service) VisitOneof(oneof *parser.Oneof) (next bool)

func (Service) VisitOneofField

func (n Service) VisitOneofField(field *parser.OneofField) (next bool)

func (*Service) VisitOption

func (s *Service) VisitOption(option *parser.Option) (next bool)

func (Service) VisitPackage

func (n Service) VisitPackage(p *parser.Package) (next bool)

func (*Service) VisitRPC

func (s *Service) VisitRPC(rpc *parser.RPC) (next bool)

func (Service) VisitReserved

func (n Service) VisitReserved(reserved *parser.Reserved) (next bool)

func (*Service) VisitService

func (s *Service) VisitService(service *parser.Service) (next bool)

func (Service) VisitSyntax

func (n Service) VisitSyntax(syntax *parser.Syntax) (next bool)

type Type

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

func (*Type) GetEnum

func (t *Type) GetEnum() *Enum

func (*Type) GetFullyQualifiedName

func (t *Type) GetFullyQualifiedName() string

func (*Type) GetMessage

func (t *Type) GetMessage() *Message

func (*Type) GetNativeType

func (t *Type) GetNativeType() string

func (*Type) IsEnum

func (t *Type) IsEnum() bool

func (*Type) IsMessage

func (t *Type) IsMessage() bool

func (*Type) IsNative

func (t *Type) IsNative() bool

type TypeDictionary

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

func NewTypeDictionary

func NewTypeDictionary() *TypeDictionary

func (*TypeDictionary) RegisterEnum

func (d *TypeDictionary) RegisterEnum(enum *Enum)

func (*TypeDictionary) RegisterExtension

func (d *TypeDictionary) RegisterExtension(extends string, msg *Message)

func (*TypeDictionary) RegisterMessage

func (d *TypeDictionary) RegisterMessage(m *Message) *Type

Jump to

Keyboard shortcuts

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