protoidl: go.uber.org/protoidl Index | Files

package proto

import "go.uber.org/protoidl"

Index

Package Files

comment.go enum.go extensions.go field.go group.go import.go message.go oneof.go option.go package.go parent_accessor.go parser.go proto.go range.go reserved.go service.go syntax.go token.go visitor.go walk.go

func Walk Uses

func Walk(proto *Proto, handlers ...Handler)

Walk recursively pays a visit to all Visitees of a Proto and calls each handler with it.

type Comment Uses

type Comment struct {
    Position scanner.Position
    // Lines are comment text lines without prefixes //, ///, /* or suffix */
    Lines      []string
    Cstyle     bool // refers to /* ... */,  C++ style is using //
    ExtraSlash bool // is true if the comment starts with 3 slashes
}

Comment one or more comment text lines, either in c- or c++ style.

func (*Comment) Accept Uses

func (c *Comment) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Comment) Merge Uses

func (c *Comment) Merge(other *Comment)

Merge appends all lines from the argument comment.

func (Comment) Message Uses

func (c Comment) Message() string

Message returns the first line or empty if no lines.

type Documented Uses

type Documented interface {
    Doc() *Comment
}

Documented is for types that may have an associated comment (not inlined).

type Enum Uses

type Enum struct {
    Position scanner.Position
    Comment  *Comment
    Name     string
    Elements []Visitee
    Parent   Visitee
}

Enum definition consists of a name and an enum body.

func (*Enum) Accept Uses

func (e *Enum) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Enum) Doc Uses

func (e *Enum) Doc() *Comment

Doc is part of Documented

type EnumField Uses

type EnumField struct {
    Position scanner.Position
    Comment  *Comment
    Name     string
    Integer  int
    // ValueOption is deprecated, use Elements instead
    ValueOption   *Option
    Elements      []Visitee // such as Option and Comment
    InlineComment *Comment
    Parent        Visitee
}

EnumField is part of the body of an Enum.

func (*EnumField) Accept Uses

func (f *EnumField) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*EnumField) Doc Uses

func (f *EnumField) Doc() *Comment

Doc is part of Documented

type Extensions Uses

type Extensions struct {
    Position      scanner.Position
    Comment       *Comment
    Ranges        []Range
    InlineComment *Comment
    Parent        Visitee
}

Extensions declare that a range of field numbers in a message are available for third-party extensions. proto2 only

func (*Extensions) Accept Uses

func (e *Extensions) Accept(v Visitor)

Accept dispatches the call to the visitor.

type Field Uses

type Field struct {
    Position      scanner.Position
    Comment       *Comment
    Name          string
    Type          string
    Sequence      int
    Options       []*Option
    InlineComment *Comment
    Parent        Visitee
}

Field is an abstract message field.

type Group Uses

type Group struct {
    Position scanner.Position
    Comment  *Comment
    Name     string
    Optional bool
    Repeated bool
    Required bool
    Sequence int
    Elements []Visitee
    Parent   Visitee
}

Group represents a (proto2 only) group. https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#group_field

func (*Group) Accept Uses

func (g *Group) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Group) Doc Uses

func (g *Group) Doc() *Comment

Doc is part of Documented

type Handler Uses

type Handler func(v Visitee)

Handler is a type of function that accepts a Visitee.

func WithEnum Uses

func WithEnum(apply func(*Enum)) Handler

WithEnum returns a Handler that will call the apply function when the Visitee is a Enum.

func WithMessage Uses

func WithMessage(apply func(*Message)) Handler

WithMessage returns a Handler that will call the apply function when the Visitee is a Message.

func WithOneof Uses

func WithOneof(apply func(*Oneof)) Handler

WithOneof returns a Handler that will call the apply function when the Visitee is a Oneof.

func WithOption Uses

func WithOption(apply func(*Option)) Handler

WithOption returns a Handler that will call the apply function when the Visitee is a Option.

func WithRPC Uses

func WithRPC(apply func(*RPC)) Handler

WithRPC returns a Handler that will call the apply function when the Visitee is a RPC.

func WithService Uses

func WithService(apply func(*Service)) Handler

WithService returns a Handler that will call the apply function when the Visitee is a Service.

type Import Uses

type Import struct {
    Position      scanner.Position
    Comment       *Comment
    Filename      string
    Kind          string // weak, public, <empty>
    InlineComment *Comment
    Parent        Visitee
}

Import holds a filename to another .proto definition.

func (*Import) Accept Uses

func (i *Import) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Import) Doc Uses

func (i *Import) Doc() *Comment

Doc is part of Documented

type Literal Uses

type Literal struct {
    Position scanner.Position
    Source   string
    IsString bool
}

Literal represents intLit,floatLit,strLit or boolLit

func (Literal) SourceRepresentation Uses

func (l Literal) SourceRepresentation() string

SourceRepresentation returns the source (if quoted then use double quote).

type MapField Uses

type MapField struct {
    *Field
    KeyType string
}

MapField represents a map entry in a message.

func (*MapField) Accept Uses

func (f *MapField) Accept(v Visitor)

Accept dispatches the call to the visitor.

type Message Uses

type Message struct {
    Position scanner.Position
    Comment  *Comment
    Name     string
    IsExtend bool
    Elements []Visitee
    Parent   Visitee
}

Message consists of a message name and a message body.

func (*Message) Accept Uses

func (m *Message) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Message) Doc Uses

func (m *Message) Doc() *Comment

Doc is part of Documented

type NamedLiteral Uses

type NamedLiteral struct {
    *Literal
    Name string
    // PrintsColon is true when the Name must be printed with a colon suffix
    PrintsColon bool
}

NamedLiteral associates a name with a Literal

type NormalField Uses

type NormalField struct {
    *Field
    Repeated bool
    Optional bool // proto2
    Required bool // proto2
}

NormalField represents a field in a Message.

func (*NormalField) Accept Uses

func (f *NormalField) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*NormalField) Doc Uses

func (f *NormalField) Doc() *Comment

Doc is part of Documented

type OneOfField Uses

type OneOfField struct {
    *Field
}

OneOfField is part of Oneof.

func (*OneOfField) Accept Uses

func (o *OneOfField) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*OneOfField) Doc Uses

func (o *OneOfField) Doc() *Comment

Doc is part of Documented Note: although Doc() is defined on Field, it must be implemented here as well.

type Oneof Uses

type Oneof struct {
    Position scanner.Position
    Comment  *Comment
    Name     string
    Elements []Visitee
    Parent   Visitee
}

Oneof is a field alternate.

func (*Oneof) Accept Uses

func (o *Oneof) Accept(v Visitor)

Accept dispatches the call to the visitor.

type Option Uses

type Option struct {
    Position            scanner.Position
    Comment             *Comment
    Name                string
    Constant            Literal
    IsEmbedded          bool
    AggregatedConstants []*NamedLiteral
    InlineComment       *Comment
    Parent              Visitee
}

Option is a protoc compiler option

func (*Option) Accept Uses

func (o *Option) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Option) Doc Uses

func (o *Option) Doc() *Comment

Doc is part of Documented

type Package Uses

type Package struct {
    Position      scanner.Position
    Comment       *Comment
    Name          string
    InlineComment *Comment
    Parent        Visitee
}

Package specifies the namespace for all proto elements.

func (*Package) Accept Uses

func (p *Package) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Package) Doc Uses

func (p *Package) Doc() *Comment

Doc is part of Documented

type Parser Uses

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

Parser represents a parser.

func NewParser Uses

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func (*Parser) Filename Uses

func (p *Parser) Filename(f string)

Filename is for reporting. Optional.

func (*Parser) Parse Uses

func (p *Parser) Parse() (*Proto, error)

Parse parses a proto definition. May return a parse or scanner error.

type Proto Uses

type Proto struct {
    Filename string
    Elements []Visitee
}

Proto represents a .proto definition

func (*Proto) Accept Uses

func (proto *Proto) Accept(v Visitor)

Accept dispatches the call to the visitor.

type RPC Uses

type RPC struct {
    Position       scanner.Position
    Comment        *Comment
    Name           string
    RequestType    string
    StreamsRequest bool
    ReturnsType    string
    StreamsReturns bool
    Elements       []Visitee
    InlineComment  *Comment
    Parent         Visitee

    // Options field is DEPRECATED, use Elements instead.
    Options []*Option
}

RPC represents an rpc entry in a message.

func (*RPC) Accept Uses

func (r *RPC) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*RPC) Doc Uses

func (r *RPC) Doc() *Comment

Doc is part of Documented

type Range Uses

type Range struct {
    From, To int
    Max      bool
}

Range is to specify number intervals (with special end value "max")

func (Range) SourceRepresentation Uses

func (r Range) SourceRepresentation() string

SourceRepresentation return a single number if from = to. Returns <from> to <to> otherwise unless Max then return <from> to max.

type Reserved Uses

type Reserved struct {
    Position      scanner.Position
    Comment       *Comment
    Ranges        []Range
    FieldNames    []string
    InlineComment *Comment
    Parent        Visitee
}

Reserved statements declare a range of field numbers or field names that cannot be used in a message.

func (*Reserved) Accept Uses

func (r *Reserved) Accept(v Visitor)

Accept dispatches the call to the visitor.

type Service Uses

type Service struct {
    Position scanner.Position
    Comment  *Comment
    Name     string
    Elements []Visitee
    Parent   Visitee
}

Service defines a set of RPC calls.

func (*Service) Accept Uses

func (s *Service) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Service) Doc Uses

func (s *Service) Doc() *Comment

Doc is part of Documented

type Syntax Uses

type Syntax struct {
    Position      scanner.Position
    Comment       *Comment
    Value         string
    InlineComment *Comment
    Parent        Visitee
}

Syntax should have value "proto"

func (*Syntax) Accept Uses

func (s *Syntax) Accept(v Visitor)

Accept dispatches the call to the visitor.

func (*Syntax) Doc Uses

func (s *Syntax) Doc() *Comment

Doc is part of Documented

type Visitee Uses

type Visitee interface {
    Accept(v Visitor)
    // contains filtered or unexported methods
}

Visitee is implemented by all Proto elements.

type Visitor Uses

type Visitor interface {
    //VisitProto(p *Proto)
    VisitMessage(m *Message)
    VisitService(v *Service)
    VisitSyntax(s *Syntax)
    VisitPackage(p *Package)
    VisitOption(o *Option)
    VisitImport(i *Import)
    VisitNormalField(i *NormalField)
    VisitEnumField(i *EnumField)
    VisitEnum(e *Enum)
    VisitComment(e *Comment)
    VisitOneof(o *Oneof)
    VisitOneofField(o *OneOfField)
    VisitReserved(r *Reserved)
    VisitRPC(r *RPC)
    VisitMapField(f *MapField)
    // proto2
    VisitGroup(g *Group)
    VisitExtensions(e *Extensions)
}

Visitor is for dispatching Proto elements.

Package proto imports 8 packages (graph). Updated 2018-04-10. Refresh now. Tools for package owners.